openai / openai/codex

Analytics drops late subagent activity after parent turn has already terminated

Open
#43,221 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app bug subagent
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Affected version

Windows Codex Desktop OpenAI.Codex 26.901.5280.0, bundled codex-cli 0.153.4.

Summary

In a completed multi-agent session, a child subagent finished after the parent turn that spawned/waited on it had already terminated on a usage limit. The child's FINAL_ANSWER was delivered while the parent thread had started a new turn.

Codex accepted the inter-agent communication and continued normally, but codex_analytics::reducer emitted:

dropping sub-agent activity tool count update: missing turn state

with the old terminated parent turn id.

This appears to lose the collaboration/subagent tool-count analytics for a valid late child completion.

Observed ordering
  1. Parent thread has turn A running with a subagent.
  2. Turn A terminates (in this reproduction because of a usage-limit error).
  3. Parent thread starts turn B.
  4. The child finishes and sends FINAL_ANSWER back to the parent path.
  5. Codex logs receipt of InterAgentCommunication from the child during turn B.
  6. The analytics reducer immediately warns that it is dropping the sub-agent activity tool-count update because turn A's state is missing.
  7. Turn B continues and completes normally.

The warning in this reproduction referenced turn A, not the currently running turn B.

Impact

I did not observe an execution failure from this warning. The impact appears limited to analytics correctness: a legitimate late subagent activity/tool-count update is discarded after the originating parent turn has already been evicted from reducer state.

Current source

The current default branch still contains this explicit warning-and-return path in codex-rs/analytics/src/reducer.rs:

tracing::warn!(
    thread_id = %notification.thread_id,
    turn_id = %notification.turn_id,
    "dropping sub-agent activity tool count update: missing turn state"
);
return;

So this does not appear specific to the installed 0.153.4 binary.

Expected behavior

Late subagent activity that is still valid and delivered to the parent thread should either:

  • retain enough terminal turn metadata to attribute the collaboration tool count to its originating turn, or
  • be attributed through a defined late-event path without silently losing the count.

At minimum, the reducer should have regression coverage for a subagent activity notification arriving after the originating parent turn has completed/failed but while the parent thread remains active.

Additional notes
  • The child result itself was delivered successfully; this report is specifically about analytics reduction.
  • I searched for the exact warning text in open/closed issues and found no matching report.
  • No private prompt, repository content, credentials, or user data is included here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in codex-rs/analytics/src/reducer.rs at the warning-and-return path for a missing turn state, then trace how InterAgentCommunication activity updates are associated with parent turns. Add regression coverage for a late notification after the originating turn completes or fails while the parent thread remains active, and verify the valid subagent tool count is no longer silently dropped.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
analytics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.