Preserving Agent Code Artifacts Across Context Compaction in ChatGPT Work
Simon Willison tested ChatGPT Work with GPT-6 Astra to build OpenStreetMap running routes. While it successfully generated interactive D3 visualizations and GPX files over 27 minutes, context compaction erased the underlying Python scripts.

Impact: Medium
Why it matters
Configure long-running agents to write Python execution scripts to disk immediately so context compaction does not erase reproducibility.
TL;DR
- 01ChatGPT Work runs multi-step data pipelines autonomously using Overpass and Nominatim APIs over long intervals.
- 02Visualizations inside ChatGPT Work require CDN scripts restricted to allow-listed origins like jsDelivr, cdnjs, and unpkg.
- 03Thread compaction erases executed Python code; agents must explicitly write logic to files to ensure reproducibility.
Key facts
- Execution Duration
- 27 minutes
- Primary Model
- GPT-6 Astra (Max)
- Output Artifacts
- GPX, GeoJSON, HTML visualization
- Visualization Engine
- D3 v7.9.0
Long-Horizon Execution with External APIs
Simon Willison evaluated ChatGPT Work powered by GPT-6 Astra (Max) on a complex geospatial generation prompt. The model was instructed to calculate 5K and 10K running loops starting from a residential address using OpenStreetMap data. Over a 27-minute execution window, the agent queried Nominatim to resolve location coordinates, used the Overpass API to fetch local road and trail geometry, and executed local graph calculations to generate closed-loop routes.
The system delivered downloadable GPX and GeoJSON files alongside an interactive web component saved to /workspace/el-granada-5k-share.html. The interactive route map utilized the platform's visualize skill to embed D3 (version 7.9.0) directly inside the interface.
Content Security Policy Constraints
The visualize skill operates under a strict Content Security Policy (CSP). External resources can only be retrieved from explicit allow-listed content delivery networks:
cdnjs.cloudflare.comesm.shcdn.jsdelivr.netunpkg.comfonts.googleapis.comandfonts.gstatic.comfonts.bunny.net
All unlisted origins are rejected silently, requiring agents to vendor assets or depend strictly on approved CDNs for data visualizations.
The Context Compaction Pitfall
The test highlighted an architectural problem with agent transparency: thread compaction. Because the ChatGPT interface hides raw code execution steps and later compacts older dialogue context, the Python script used to fetch Overpass data and calculate the routes became unrecoverable. For production agentic engineering, frameworks must persist pre-compacted tool calls and raw code blocks to disk artifacts before LLM compaction runs.
Try it in 2 minutes
You are generating a long-running data pipeline. Save all intermediate Python scripts to /workspace/scripts/ before executing them, and ensure all HTML visualizations import libraries exclusively from cdn.jsdelivr.net or cdnjs.cloudflare.com.markdown
✓ When to use
- When orchestrating autonomous agents that aggregate public APIs (Nominatim, Overpass) and export structured spatial data.
- When rendering zero-install interactive D3 charts and maps directly inside the agent workspace.
✕ When NOT to use
- Do not rely on chat history as a code repository for long-running workflows where thread compaction will be triggered.
- Avoid using arbitrary third-party script sources in ChatGPT visualizer artifacts outside the CDN allowlist.
What to do today
- Add an explicit prompt instruction requiring agents to save all generated Python scripts as files in /workspace.
- Ensure all script dependencies injected into web visualizers use allowed CDN endpoints like jsdelivr or unpkg.
- Extract raw tool execution logs before agent dialogues hit token context limits and compact.
Sources