Feed
Where represents the byte accumulation and the duration. In the observed cases, this reached approximately per child process, with event throughputs exceeding .
Insane Codex Disk Usage from Subagents · Issue #34061 · openai/codex
jezell
2026.07.20
·GitHub·by igor#Codex#Subagents#Disk Usage#Performance#Logging
Key Points
- 1The Codex CLI experienced a critical failure where subagent session logs consumed over 755 GiB of disk space, nearly exhausting the system's storage capacity.
- 2Analysis reveals that a single resumed parent thread generated thousands of child sessions, characterized by excessive event logging and the repeated retention of massive tool-output and compaction payloads.
- 3The report highlights a urgent need for implementing disk quotas, automatic log rotation, event deduplication, and rate-limiting to prevent similar runaway session growth and data loss in future versions.
The provided document details a critical performance bug (#34061) in the Codex CLI (v0.144.6) where subagent session logs caused near-total disk exhaustion on macOS. The issue involves the uncontrolled generation and persistence of JSONL session files, which consumed approximately 755 GiB of storage across 2,393 subagent files spawned from a single resumed parent thread.
Core Issues and Technical Observations
The investigation identified an "event amplification" phenomenon where high-frequency telemetry and state snapshots were stored in an unoptimized, unbounded manner. Diagnostic analysis revealed several specific technical failure modes:- Excessive Event Frequency: A single child session running for ~199 seconds generated 353,255 JSONL records. This included 185,461
event_msg/token_countrecords and 36,295event_msg/patch_apply_endrecords, indicating a lack of rate-limiting or coalescing for high-frequency internal events. - Compaction and Payload Bloat: The persistence mechanism failed to implement deduplication. Large
compactedrecords (snapshots of state) andcustom_tool_call_outputdata were stored in full within each individual session file rather than being referenced or content-addressed. One representative session reached ~925 MiB, with 175 compacted records accounting for over 571 MiB. - Resume Lifecycle Leak: The
codex resumecommand appears to trigger a leak where long-running parent threads continuously spawn new subagent logs. This effectively "replicates" parent-level state into every child session, leading to exponential growth in local metadata storage. - Resource Exhaustion: Because these processes held file handles open for the duration of the execution, the system was unable to reclaim space, leading to a state where the APFS Data volume reached 99–100% capacity.
Quantitative Metadata Analysis
The data illustrates a pattern of runaway persistence. Analysis of the affected files shows a sharp acceleration in storage growth over nine days in July 2026. A single parent thread ID (019ee8d1-...) was linked to 731.5 GiB of log data. The intensity of the logging can be expressed as:Where represents the byte accumulation and the duration. In the observed cases, this reached approximately per child process, with event throughputs exceeding .
Recommended Remediation and Safeguards
The reporter proposes several technical mitigations to enforce bounded resource usage:- Quota Management: Implementation of configurable global and per-session storage quotas.
- Deduplication: Transitioning to content-addressing for state snapshots to prevent redundant storage of
compactedortool_outputrecords. - Telemetry Coalescing: Replacing high-frequency
token_countevents with summarized or throttled data points. - Automatic Rotation: Integration of age or size-based retention policies to prevent historical logs from exhausting the primary filesystem.
- Diagnostic Feedback: The introduction of "Codex doctor" commands to safely identify and prune sessions, providing the user with visibility into disk usage before the system reaches critical capacity.