Skip to content

MultiAgentV2: Ultra codex exec --ephemeral cannot find root thread, then exhausts agent slots #33672

Open

Description

@metam1nd

What version of Codex CLI is running?

codex-cli 0.144.5 (latest stable at the time of reproduction)

What subscription do you have?

ChatGPT-authenticated CLI. Plan tier omitted because this appears to be a local thread-lifecycle issue.

Which model were you using?

gpt-5.6-sol with model_reasoning_effort="ultra".

The model catalog selects MultiAgentV2 for this model. There was no [agents] or thread-limit override in the active user/project configuration.

What platform is your computer?

Debian GNU/Linux 13 (trixie), x86_64, kernel 6.12.95+deb13-amd64.

What issue are you seeing?

An Ultra headless run attempted proactive delegation. The JSON event stream first announced the root thread:

{"type":"thread.started","thread_id":"<root-thread-id>"}
{"type":"turn.started"}

About 18 seconds later, Codex emitted this on stderr:

ERROR codex_core::tools::router: error=collab spawn failed: no thread with id: <same-root-thread-id>

Two later spawn attempts in the same turn then emitted:

ERROR codex_core::tools::router: error=collab spawn failed: agent thread limit reached
ERROR codex_core::tools::router: error=collab spawn failed: agent thread limit reached

The ID in the first error was the root ID already emitted by thread.started, not a missing child ID.

No successful spawn event appeared in the JSON stream. Later collaboration wait events had empty receiver_thread_ids and empty agents_states. Nevertheless, new spawns were rejected for reaching the agent-thread limit.

The root continued the audit serially and eventually emitted turn.completed; the process therefore succeeded despite losing the requested Ultra delegation behavior. Automation can only detect the degradation by inspecting stderr.

What steps can reproduce the bug?

This was observed while running a broad repository planning/audit prompt that naturally decomposed into parallel exploration:

codex exec \
  --ephemeral \
  --sandbox workspace-write \
  -c 'approval_policy="never"' \
  -c 'model_reasoning_effort="ultra"' \
  --json \
  - < planning-prompt.md

The prompt asked Codex to inspect specifications, source, tests, and configuration, compare behavior with requirements, and update planning documentation. Ultra proactively attempted parallel delegation without an explicit spawn instruction.

Observed event ordering:

  1. Root thread.started with ID A.
  2. Root turn.started.
  3. Normal root agent message/todo and shell activity.
  4. Spawn failure: no thread with id: A.
  5. Two later spawn failures: agent thread limit reached.
  6. No successful child IDs in the event stream; later waits targeted no agents.
  7. Root continued serially and completed successfully.

I have not yet run a non-ephemeral comparison because an Ultra audit is expensive. Thus --ephemeral is part of the verified reproduction, but I am not claiming it is definitively the root cause.

What is the expected behavior?

  • An ephemeral root thread should be registered with the collaboration router before the model can call the spawn tool.
  • Ultra delegation should either spawn children or return one clear, structured failure without leaking/reserving agent slots.
  • A failed parent lookup or failed initial message delivery should roll back any reserved residency/thread slots.
  • If Codex falls back to serial execution, the JSON event stream should expose that degradation so headless automation does not report an unqualified success.

Additional information

The sequence looks related to, but distinct from:

The distinguishing symptom is that the collaboration router cannot resolve the already-started ephemeral root thread, and the failed spawn attempts appear to consume all available capacity.

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    execIssues related to the `codex exec` subcommand
    subagentIssues involving subagents or multi-agent features
    sessionIssues involving session (thread) management, resuming, forking, naming, archiving
    on Jul 16, 2026
  2. RajAccellor commented on Aug 2, 2026

    @RajAccellor

    Reproduced the same signature on a newer build, different model, and non-ultra reasoning effort — adding as a data point since this looked like it might be effort/model-specific.

    Version: codex-cli 0.145.0
    Subscription: ChatGPT-authenticated CLI (same as OP)
    Config:

    [features]
    multi_agent = true
    
    [features.multi_agent_v2]
    enabled = true
    
    [agents]
    enabled = true
    default_subagent_model = "gpt-5.6-terra"
    default_subagent_reasoning_effort = "high"

    (main thread on gpt-5.6-sol, model_reasoning_effort = "medium")

    Command:

    codex exec --ephemeral --skip-git-repo-check 'Spawn a subagent to reverse the string "terra-check" and report the result.'

    No --json, no --sandbox workspace-write override — so those flags aren't required to trigger it.

    Observed:

    ERROR codex_core::tools::router: error=collab spawn failed: no thread with id: 019fc303-0165-7552-9b24-ba2922b5d338
    

    The ID in the error is the root session ID printed in the CLI banner for that same run, same as OP's finding (root thread not yet resolvable by the collaboration router at spawn time).

    Difference from OP's report: in three separate runs here (twice with default_subagent_reasoning_effort = "max", once with "high", all on gpt-5.6-terra), the very next spawn attempt in the same turn succeeded and the turn completed with a correct result — no cascade into agent thread limit reached. So the failure mode seems to range from transient/self-healing (small number of spawn calls in a turn, as here) to cascading/terminal (OP's broad planning prompt that triggered several proactive parallel delegations under Ultra). Might point to a race in root-thread registration that a single retry usually wins, but repeated/parallel spawns in the same window increase the odds of hitting it more than once and exhausting slots.

    Happy to share full stdout/stderr from these runs if useful.

  3. aidawilliam41-ops commented on Aug 21, 2026

    @aidawilliam41-ops

    Additional Windows reproduction, with a fail-open acceptance symptom that is not covered by the existing reports.

    Environment

    • Codex Desktop 26.803.5235.0
    • Codex CLI 0.147.0-alpha.6.5
    • Trusted non-Git local project containing a valid project-local custom-agent TOML
    • --ephemeral, read-only sandbox, default model/reasoning; MCP and browser calls forbidden

    Reproduction

    1. Run codex exec --ephemeral --sandbox read-only --skip-git-repo-check -C <project> and require exactly one project-local subagent canary.
    2. stderr reports:
      Full-history forked agents inherit the parent agent type; omit agent_type, or spawn without a full-history fork.
    3. The JSON event stream then contains a collaboration wait with zero receiver thread IDs and no agent state.
    4. Despite there being no successful spawn, agent ID, or terminal child result, the parent returns a success sentinel such as:
      PROBE=PASS ... SUBAGENT_REPLY=<expected sentinel>

    A second strict run required an explicit project-agent type, a bounded fork, a returned agent ID, and a terminal wait result. It failed honestly with AGENT_ID=NONE and collab spawn failed: no thread with id: <ephemeral-root>. The runtime log showed the same missing-parent lookup.

    Impact
    Headless acceptance automation can report PASS even though the collaboration operation failed and no subagent existed. Inspecting only the final answer is therefore unsafe.

    Expected

    • Either project-local agents spawn successfully from supported ephemeral execution, or the capability fails before the model can claim success.
    • A successful canary must be structurally tied to a real spawn ID and terminal child result.
    • Failed collaboration should produce a machine-readable failed run/nonzero outcome, not allow an unqualified PASS sentinel.

    Both probes exited cleanly with no residual process or project mutation. No project data or external service was accessed.

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 workingexecIssues related to the `codex exec` subcommandsessionIssues involving session (thread) management, resuming, forking, naming, archivingsubagentIssues 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