Skip to content

Multi-agent: spawn_agent fails with 'not found' when re-spawning after worker death #14719

Closed

Description

@joeykrug

Bug

When using Codex CLI multi-agent ([features] multi_agent = true), if a spawned worker agent dies mid-run, the coordinator's attempt to spawn_agent a replacement fails with not found.

Environment

  • Codex CLI version: latest (March 2026)
  • Config: multi_agent = true, max_threads = 8, max_depth = 2
  • Running via: codex exec --dangerously-bypass-approvals-and-sandbox through an unbuffer PTY wrapper

Reproduction

  1. Start Codex with a multi-agent task that spawns 3 worker agents
  2. Workers start successfully (spawn_agent ... pending init)
  3. One worker crashes or is interrupted mid-execution
  4. Coordinator detects the dead worker and attempts to spawn a replacement:
    spawn_agent(call_B5FBNHPxBfpcYsN4hHnR5qLn, prompt="You are taking over PR #46303 from an interrupted worker...") not found:
    
  5. The spawn_agent call fails with not found even though it should create a fresh agent with a new session ID

Expected Behavior

spawn_agent should always be able to create a new agent session, even when a previous worker has died. The dead worker's session ID should not prevent new spawns.

Actual Behavior

spawn_agent returns not found when attempting to create a replacement worker after another worker has died. This appears to crash the coordinator thread — the entire Codex process exits without writing its normal result JSON, suggesting an unhandled error path.

Possible Causes

  1. Dead worker's session slot isn't cleaned up in the internal registry, preventing new spawns
  2. max_threads limit counts dead sessions toward the cap
  3. The not found error may relate to something other than the session (file/tool reference from dead worker's context)

Additional Context

  • Initial spawn_agent calls succeed — the feature works for the first spawn
  • A broken skill file (missing field description) logged ERROR on each spawn but didn't prevent initial spawns from succeeding
  • The coordinator was able to use send_input to communicate with live workers before the crash
  • Running through unbuffer PTY (needed for Codex to produce output in non-interactive mode)

Logs

[collab] spawn_agent(call_whV7OWzXK2Rc4l3mfV3kFFXW, prompt="You own PR #46303...") pending init:
  agent: 019cee4d-f3b0-72c1-aab3-0782d817756f
[collab] spawn_agent(call_DdKH6eHKZataSda6gpD9QRMF, prompt="You own PR #46417...") pending init:
  agent: 019cee4d-f438-7132-9029-5e2b90f955d2
[collab] spawn_agent(call_cwRO0EdzlkNKIf1flbbX4Aqn, prompt="You own PR #46454...") pending init:
...
[later, after worker death]
spawn_agent(call_B5FBNHPxBfpcYsN4hHnR5qLn, prompt="You are taking over PR #46303 from an interrupted worker...") not found:

Activity

  1. added
    bug
    CLI
    tool-calls
    on Mar 14, 2026
  2. github-actions commented on Mar 14, 2026

    @github-actions
    Contributor
  3. added
    agent
    and removed
    CLI
    tool-calls
    on Mar 14, 2026
  4. jif-oai commented on Mar 17, 2026

    @jif-oai
    Contributor

    This is a known issue. We will work on a fix

  5. jif-oai commented on Mar 19, 2026

    @jif-oai
    Contributor

    This has been fixed

  6. added
    subagent
    and removed
    agent
    on Apr 11, 2026
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

    bugsubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions