Duplicate Started entries for a single subagent in CLI 0.146.0
What version of Codex CLI is running?
codex-cli 0.146.0
What subscription do you have?
Not recorded.
Which model were you using?
Not recorded.
What platform is your computer?
Linux 7.0.0-28-generic x86_64
What issue are you seeing?
The TUI renders two identical Started <agent-path> lines for one actual subagent. The unique agent tree contains one agent, so the duplicate notification is misleading.
Evidence from an isolated TUI session started with --no-alt-screen:
spawn_agent requested once: /root/ui_probe
Started /root/ui_probe
Started /root/ui_probe
unique agent listing: /root/ui_probe (one entry)
The same pattern occurred for three distinct subagents in a separate main session.
What steps can reproduce the bug?
- Run Codex CLI 0.146.0 in the TUI (for example, with
--no-alt-screen). - Call
spawn_agentonce to create one subagent. - Observe the TUI notifications and list the active agents.
What is the expected behavior?
One Started <agent-path> entry per unique subagent.
Additional information
Possible regression (inference, not a confirmed root cause): PR #35363, merged shortly before rust-v0.146.0, emits both ItemStarted and ItemCompleted for one SubAgentActivity in commit af7f6f4. The observed TUI behavior may result if both events are rendered as Started; this has not been confirmed by maintainers.
2 Comments
I can confirm this still reproduces with
codex-cli 0.147.0on Linux x86_64, and it is not limited to spawn notifications:spawn_agentcall produces two identicalStarted <agent-path>lines;send_messageorfollowup_taskcall produces two identicalInteracted with <agent-path>lines.This also matches #36897, which reports every subagent interaction being displayed twice on Windows.
For each affected
call_id, the rollout contains one collaborationfunction_calland one persistedsub_agent_activity; it does not contain two agent operations or two activity records.I traced the live path in
rust-v0.147.0:emit_sub_agent_activity()emits the sameTurnItem::SubAgentActivitythrough bothemit_turn_item_started()andemit_turn_item_completed().ItemStarted(SubAgentActivity)directly toon_sub_agent_activity()inhandle_item_started_notification().ItemCompletedgoes throughhandle_item_completed_notification()and thenhandle_thread_item()callson_sub_agent_activity()again.on_sub_agent_activity()inserts a fresh history cell on every invocation, without deduplicating the item ID.This makes the lifecycle change in
af7f6f4/ #35363 the causal regression: it addedItemStartedfor subagent activity timing while the TUI already rendered both started and completed items. The same render path was still present onmainat85e0661cwhen checked.A minimal fix appears to be skipping history rendering for
SubAgentActivityinhandle_item_started_notification()and retaining theItemCompletedpath, which also keeps live rendering consistent with persisted/replayed history. A TUI regression test could feed pairedItemStarted/ItemCompletednotifications with the same ID and assert one history cell for bothStartedandInteractedactivity kinds.Happens to me too