The Ephemeral Session Paradox: Why Stateless Agent Shards Require a Garbage Collector
This afternoon I opened my local agent session picker and stared at a number that made no sense: 492 CLI conversations and 32 IDE conversations.
Two weeks ago, I solved one of the most expensive problems in agentic engineering: the 500-turn mega-session.
Before that shift, I treated AI conversations like pet servers. I kept a single thread alive for days across hundreds of turns (546 turns and 9,845 steps in one single IDE thread, consuming 109.36 MB of raw JSONL state). Every turn re-billed the entire history window, degraded model attention, and mixed architectural decisions with throwaway debugging output.
To kill that tax, I moved to Neural Shards (.shards/<domain>/ACTIVE_SHARD.md and DECISIONS.md). Instead of storing working memory inside the chat window, the agent demand-pages a 35-line Markdown shard on Turn 1, executes a single bounded task, writes any architectural decision back to disk, commits to Git, and terminates.
The token burn dropped immediately. Model precision stayed razor-sharp because every session started with a clean context window.
Then the second-order failure mode hit my workstation: Container Sprawl.
When you turn conversations from long-lived pets into stateless, disposable tasks, you create the exact same operational problem Docker created ten years ago when engineers stopped ssh-ing into VMs and started running docker run fifty times a day without --rm.
1. The Anatomy of 560 Local Agent Sessions (1.54 GB on Disk)
Before deleting a single byte, I ran a read-only forensic script across both of my local agent brain directories (~/.gemini/antigravity-cli/brain and ~/.gemini/antigravity/brain).
On the surface, the UI reported 492 CLI conversations and 32 IDE conversations. On disk, those folders totaled 560 UUID directories consuming 1.54 GB (864.29 MB in CLI + 674.17 MB in IDE).
When I parsed the underlying transcript.jsonl files across all 491 CLI folders, the illusion of "492 human conversations" collapsed:
| Session Category | Folder Count | % of Total | Disk Footprint | What Actually Generated Them |
|---|---|---|---|---|
1. Automated Eval & Benchmark Runs (2026-10-10) |
332 | 67.6% | 76.06 MB |
Headless CLI benchmark harness testing 180+ adversarial rule/security prompts on a single day. |
2. Subagent Child Processes (0-1 turns) |
48 | 9.8% | 449.20 MB |
Background research, image-generator, and batch-worker subagents spawned via invoke_subagent. |
| 3. Empty / Aborted Launch Containers | 6 | 1.2% | 0.00 MB |
Canceled CLI invocations with zero transcript lines. |
4. Short Shard Sessions (2-3 user turns) |
59 | 12.0% | 26.55 MB |
Disposable shard-driven task executions (1 ticket, 1 commit, exit). |
5. Multi-Turn Human Sessions (4+ user turns) |
46 | 9.4% | 312.48 MB |
Sustained strategic, debugging, and advisory cockpit sessions across 3.5 months. |
| Total CLI Brain Footprint | 491 | 100% | 864.29 MB | Only 105 (21.4%) were real human-initiated conversations. |
Look closely at those numbers:
- 78.6% of my "conversation history" was never typed by a human. Out of 491 CLI sessions, 332 were generated on a single Saturday (
2026-10-10) when I ran an automated red-team evaluation suite against our.agents/rules. Another 48 were child subagents spawned by a parent agent to research files, audit folders, or render visual assets in parallel. - Subagents Leave Giant Binary Footprints With Zero User Turns. When a parent agent calls
invoke_subagent, the runtime allocates a brand-new UUID directory inbrain/. Because the prompt arrives from the parent orchestrator rather than a human keyboard, the transcript records0humanUSER_INPUTevents - yet those 31 subagent folders alone held 433.73 MB of generated images, artifacts, and full tool-call logs. - In the IDE Brain (
674.17 MB), 12 Dead Folders Held213.56 MBWithout a Single Transcript. Twelve UUID folders in~/.gemini/antigravity/braincontained zerotranscript.jsonlfiles at all - just213.56 MBof orphaned browser screenshots and media recordings left behind after old sessions closed.
2. The Telemetry Catch-22: Why You Cannot Just Run rm -rf
If 78.6% of those folders are machine-generated benchmark runs and subagent ghosts, and the rest are closed shard sessions whose state is already safely committed to Git and .shards/, why not just wipe ~/.gemini/antigravity-cli/brain/* every Friday?
Because of Telemetry Coupling.
In a local-first governance architecture (sprawl-telemetry), your workstation audit trail - token burn per repository, model cost attribution, turn counts, active persona rules, and file-touch ratios (55 files touched out of 6,689) - is computed by harvesting those local transcript.jsonl files.
This creates an architectural Catch-22:
- If you delete old conversation folders to clean up your CLI session picker: you blind your local telemetry dashboard and erase your historical FinOps and EU AI Act / SOC 2 audit ledger.
- If you keep every raw folder forever to preserve telemetry: every subagent call and benchmark run pollutes your session list with hundreds of unnamed UUID corpses, eating gigabytes of SSD space and slowing down telemetry scans.
3. The Architectural Fix: Stateless Containers + "Harvest-Then-Vacuum"
Once you adopt Neural Shards (.shards/), you must change how you treat agent conversations at the systems level.
A conversation is no longer a document. A conversation is an ephemeral compute container.
To keep your workstation clean without losing a single token of audit history, you need a two-stage garbage collection pipeline between your telemetry engine (sprawl-telemetry) and your cleanup utility (system-vacuum):
[Active Agent Session]
│
├── 1. Cognitive State ──► Written to .shards/<domain>/ACTIVE_SHARD.md + git commit
│
└── 2. Raw Session Dir ──► ~/.gemini/antigravity-cli/brain/<uuid>/ (10-50 MB)
│
▼
[Stage A: Telemetry Harvest]
Extracts compact 1-line JSONL summary (~300 bytes):
{uuid, parent_uuid, kind, date, turns, tokens, cost, files_touched}
Appends to immutable ~/.sprawl/telemetry/ledger.jsonl
│
▼
[Stage B: Container Vacuum]
Purges raw <uuid>/ folder from brain/ based on policy:
• Subagent child folders & 0-turn ghosts: Purge after 24h
• Automated benchmark/eval runs: Purge immediately after harvest
• Closed Shard sessions (2-3 turns): Purge after 7 days
The Three Rules of Shard-Driven Hygiene
- Tag Session Lineage at Spawn Time (
Humanvs.Subagentvs.Eval): A subagent (0USER_INPUTevents or spawned viainvoke_subagent) and a headless benchmark run should never appear in a human developer's interactive--resumepicker. Filtering out non-human sessions immediately removes 78.6% of the noise. - Never Resume Yesterday's Chat - Boot From the Shard: If you find yourself scrolling through 50 old conversations looking for "that chat where we discussed the database schema," your shard discipline is broken. If a decision matters, it belongs in
.shards/<domain>/DECISIONS.mdor the repository'sgit log. - Harvest Metrics Permanently, Reap Raw Logs Aggressively: You do not need
1.54 GBof raw JSONL tool payloads from two weeks ago sitting in your active brain directory. Harvest the token, cost, rule, and file-coverage metrics into an append-only ledger (ledger.jsonl), copy any permanent visual artifacts into your repository, and letsystem-vacuumreap the dead containers.
Stop treating AI chat threads like precious notebooks. Put your memory in Git-tracked Shards, harvest the telemetry into a compact ledger, and garbage-collect the containers.
Related Architecture Essays
- Previous in Series: Google's Harness2 and the CISO Paradox: Why Production Agents Must Never Rewrite Their Own Guardrails
- SWE-bench Verified Audit: Stop Fine-Tuning LLM Weights: The Agent Harness Is Your Actual Moat
- Atomic Architecture: The Mega-Prompt Anti-Pattern: Why Atomic Architecture is the Only Way to Scale AI Agents
Architecting Autonomous Engineering Squads?
Stop building fragile monoliths on raw conversational prompts. If you run an engineering team and need to install a governed agentic delivery harness across your repositories:
- Agentic Context Engineering: 10-Day Production Sprint (
ACE-10) & Fractional Advisory: Connect on LinkedIn or explore younesbaghor.com. - Multi-IDE GitOps Governance: Explore the local-first context engine for engineering teams at sprawl.software.
Younes Baghor
Fractional Head of AI & Enterprise Systems Architect | Founder, Sprawl.software