Skip to content

The main agent is not aware of subagents spawned before context compaction, and reports no way to list them by itself #24281

Open

Description

@Func86

What version of Codex CLI is running?

codex-cli 0.133.0

What subscription do you have?

Pro Lite

Which model were you using?

gpt-5.5 (reasoning xhigh, summaries detailed)

What platform is your computer?

Linux 6.6.114.1-microsoft-standard-WSL2 x86_64 unknown

What terminal emulator and version are you using (if applicable)?

Windows Terminal

Codex doctor report

What issue are you seeing?

  1. A subagent is spawned to review a set of new plan documents prepared by the main agent for the repo
  2. The subagent finished, and the main agent updated the documents accordingly
  3. Context compacted automatically on the main agent
  4. The main agent did a diff review pass and reported to me
  5. I asked the main agent, "Can you get back with that subagent and allow one more round of review?"
  6. The main agent created a new subagent session instead, forking from the main session with all conversations between the main agent and me
  7. I noticed the issue and questioned the main agent; it reports that "the original subagent id was not available in the compacted context I had"
  8. I followed up further, and it reports "I can’t retrieve a list of prior spawned sessions with the tools currently exposed. I can only act on an agent id I already know."
  9. With the subagent ID provided by me from the /agents command, it can then resume the subagent and proceed correctly.

I see this as a mix of multiple issues:

  1. Awareness of previously spawned subagent IDs may not survive context compaction. I guess this is acceptable/expected if the subagent is not active.
  2. There is no way for the main agent to list previously spawned subagents when a resume is the correct orchestration.
  3. In this case, the main agent has the choice to resume the previous subagent (if the ID is available), start a fresh subagent session, or fork the main session with the user. It chose the worst action possible, since this subsequent "review" is not unbiased (as the user requested) at all, with the full conversation history between it and the user.

What steps can reproduce the bug?

Uploaded thread: 019e56bf-f74a-7de1-b0eb-46853ce69173

What is the expected behavior?

The agent should be able to list previously spawned subagents, and actively resume these sessions if beneficial.

Additional information

No response

Activity

  1. added
    CLIIssues related to the Codex CLI
    subagentIssues involving subagents or multi-agent features
    contextIssues related to context management (including compaction)
    on May 24, 2026
  2. github-actions commented on May 24, 2026

    @github-actions
    Contributor
  3. yui-stingray commented on May 24, 2026

    @yui-stingray

    One current-main data point from openai/codex@7d47056: there are now two related surfaces, but neither fully proves this repro is closed.

    On the client side, app-server exposes thread/loaded/list, and the TUI uses it after resume/fork/new to backfill the /agent picker from loaded threads. On the model/tool side, multi-agent v2 also has a list_agents tool that lists live agents in the current root thread tree.

    The caveat is that this still looks scoped to live/loaded agents: the tool description says “live agents”, and the existing tests cover omitting closed agents. So if the missing case is a prior closed or unloaded subagent after compaction, or if the reporter is on 0.133.0 before this tool is available to the model, the issue still seems useful. I would narrow the ask to making prior resumable subagents discoverable to the model, not just visible in the TUI.

  4. Func86 commented on May 26, 2026

    @Func86
    Author

    It really likes to fork the main session.

    › You forked our conversation. why?
    
    
    • Closed Bacon
    
    • I forked because the subagent tool says to use fork_context: true when the subagent should have exactly the same context. For a staged-change review
      against the whole plan, I chose that so it could see the prior decisions.
    
      That was a bad call in this workspace because your AGENTS.md explicitly says “Do not fork the main session with the user to start subagents.” I missed
      that constraint while following the tool guidance. I’ve shut the subagent down and won’t use a forked subagent here again.
    
    
    › Do you know what is "unbiased review" about?
    
    
    • Yes. “Unbiased review” means the reviewer should not inherit my assumptions, my implementation rationale, or the conversational framing that might make
      them defend the change.
    
      For this request, the better setup would have been:
    
      - spawn a reviewer without fork_context
      - give only the objective artifacts: repo path, staged diff, plan doc path, and review criteria
      - ask them to inspect the code independently and report findings
      - no edits, no knowledge of my prior explanations beyond what is written in docs/code
    
      By forking the conversation, I biased the reviewer with all previous discussion and my own decisions. That undermined the point of asking for an unbiased
      review.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIbugSomething isn't workingcontextIssues related to context management (including compaction)subagentIssues involving subagents or multi-agent features

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions