Repository navigation
fix(codex): subagent lanes, per-request Context, compactions and interrupts - #52
Conversation
EntelligenceAI PR SummaryCodex ingestion now records context per request, surfaces compactions and user interrupts, and excludes copied parent history from subagent rollouts to prevent duplicate turns and token counts. Codex Desktop subagents are linked to their parent session and included as map lanes, with spawn calls linked to the corresponding lanes; guardian reviews and other agents remain separate or unchanged. flowchart TD
classDef newBehavior fill:#dcfce7,stroke:#16a34a,color:#14532d;
A["Codex JSONL rollouts"] --> B["Index and link subagent threads"]
B --> C["Parse requests, compactions, and interrupts"]
C --> D["Build map with per-request events"]
B --> E["Read child rollout spans"]
D --> F["Match spawn calls to subagent lanes"]
E --> F
class A,B,C,D,E,F newBehavior;
Review Scorecard
Safe to merge with a low blast radius; code quality rated Excellent (5/5): the review found nothing to flag. Key Findings:
Evaluated against
|
WalkthroughAdds end-to-end Codex subagent support, from rollout parsing and parent-child discovery to session-map lanes and request-level cost events. The update also handles fork-history trimming, compactions, interruptions, and prompt detection, documents Desktop support, and adds synthetic-rollout regression coverage. ChangesFiles
Codex ingestion now discovers and links nested subagent rollouts, trims copied parent history, and records thread, parent, agent-path, compaction, and interruption metadata. Parsing also distinguishes injected context from user prompts and handles subagent first turns without counting task instructions as user prompts. Files
Session-map construction now adds subagent lanes, links launches to parent-child sessions, assigns launch sequence numbers, and emits Codex LLM events per cost event. Discovery traverses nested subagents within depth and source-size limits; map building also handles compactions and interruptions and omits user events from subagent lanes. Files
Documents Codex support in the Desktop app, including subagent lanes, parent-session rollup behavior, and reading compactions and interrupts. Files
Adds synthetic-rollout regression coverage for parsing, fork-history trimming, usage, compactions, interrupts, subagent discovery and linkage, and edge cases including missing parents, cycles, truncated spawn output, and unavailable spans. |
|
nice one @21lakshh, merging 🚀 |
Summary
Fixes the Codex data loss reported in #47 and #49. All changes are in the Codex read path, and maps for other agents are unchanged.
#47: Context, compactions, interrupts
llmevent per request (fromllm.cost_events) instead of one per turn. Context is now the largest single request, not a turn's summed total. Tokens and cost are unchanged.compactedrecord becomes acompactionevent. Its "before" tokens are the last request's input whenlatest_token_usage_recordis null.turn_abortedwith reasoninterruptedbecomes aninterruptederror, counted once per Esc.#49: subagents and "#" prompts
agent_message, so its tool calls are kept. No instruction text is stored.#is a prompt. Only<…>,# AGENTS.md instructionsand the IDE extension's# Context from my IDE setupcount as injected.thread_source: subagent) drops the parent history copied in beforesubagent_history_start_ordinal._<window>file that started at or before it) and is folded into the parent map as a lane, with thespawn_agentcall as its launch.role: subagentwith itsparentSessionId, so the session list, Insights and Run health skip it, as they already do for Claude Code and Antigravity subagents. Its work is counted once, in the parent.Edge cases (found in review, each with a test):
parent_thread_idis never folded.spawn_agentoutput longer than the 2,000-character cap still links to its lane.The README's Codex row is updated to match.
Closes #47
Closes #49
Test plan
Ran:
make check: lint, 1363 Python tests (16 new intests/core/test_codex_threads.py, using synthetic rollouts only), 354 viewer tests, and the clean check.mainand once with this branch (Python 3.11 both times). That covers 192 Codex, 90 Claude Code, 34 Antigravity and 3 Cursor sessions. The diff:#-prompt session is no longer dropped.agent_messagebodies andspawn_agentmessages: 0 hits.Before and after, one pair per fix (dark theme). The screenshots were built with
--no-titles --path-mode hashed, and repo names are replaced withrepo-a…f.#47 Context. For the same session, the Context lane goes from 10.7M max (per-turn sums) to 217.9K max (the largest single request):
#47 Compactions. The rollout has 3
compactedrecords; Compactions goes from 0 to 3. The drops are visible in the Context lane above ("216.5K→0"):#47 Interrupts. The rollout has 2
turn_abortedrecords with reasoninterrupted. Agent orchestration goes from 0 to 2, and "interrupted by user ×2" appears:#49 A: subagent tool calls. A parent whose subagents take their input from
agent_message. Before, that work was missing; one of those subagents had 165 calls and showed 0. After, the parent has 5 subagent lanes, including "Sub 2 · 165 calls". Agents go from 1 to 6 and tool calls from 175 to 568:#49 B: a prompt starting with
#. The Apr 2 session (8 calls) was dropped. It now appears between Apr 5 and Apr 1:#49 C: subagents no longer listed as main sessions. The Sep 13 group in the session list. Before, there were 3 subagent rows ("3 prompts", the copied parent history) next to their parent. After, there is one parent row with "8 subagents". The list goes from 97 to 36 Codex sessions:
#49 C: the parent shows its subagents. Agents go from 1 to 9, and the Subagents lane from (0) to (8). The Subagents sidebar tab lists them. Context goes from 12.6M to 220.3K, and tool calls from 338 to 765:
Existing maps rebuild on the next version bump (
builtWith), or withagentplay build --rebuild --agents codex.make checkpasses