openai / openai/codex

`codex exec --ephemeral` fails to spawn a custom subagent with `no thread with id`; non-ephemeral succeeds after global agent placement

Open
#41,474 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI exec session subagent windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Summary

I am seeing a custom-subagent spawn failure in Codex CLI on Windows. The failure is deterministic in --ephemeral mode and reports:

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

The message resembles the thread-lifecycle symptom described in #35781, but my reproduction uses a user-requested custom agent rather than a memory consolidation agent.

Environment

  • Codex CLI: codex-cli 0.150.0-alpha.8
  • OS: Windows 10 Home, 10.0.19045, x64
  • Model: gpt-5.6-terra
  • Command mode: codex exec --strict-config --skip-git-repo-check
  • The diagnostic prompt forbids networking, external services, secret access, writes, and deletion.

Reproduction

  1. Define chief-secretary.toml and researcher.toml with name, description, developer_instructions, and sandbox_mode = "read-only".
  2. Ask the root session to delegate once to chief-secretary, which is instructed to delegate once to researcher.
  3. Run the command in each mode below.
Project-scoped agents only (<project>/.codex/agents/)
  • Normal mode: failed previously with collab spawn failed: no thread with id: <root-session-id>.
  • --ephemeral: failed previously with the same error.
Global agents also present (~/.codex/agents/)
  • Normal mode: completed with final output responded; no no thread with id router error appeared. The CLI output did not expose a child-agent identity, so this only confirms the requested diagnostic completed without the router error.
  • --ephemeral: failed with the same error, before the delegated agent started.

Example failing invocation:

codex exec --strict-config --skip-git-repo-check --ephemeral -C <project> "<read-only prompt requesting chief-secretary -> researcher delegation>"

Expected behavior

The custom subagent should start in both normal and ephemeral modes, or ephemeral mode should reject the workflow before it exposes a spawn tool that cannot resolve the caller thread.

Actual behavior

Non-ephemeral behavior changes when the agent definition is globally available, but ephemeral mode still fails with a lookup for its own root session ID.

Request

Could this be related to the thread-registration or teardown path described in #35781? If not, please advise which redacted diagnostic fields or rollout details would help isolate the custom-agent/ephemeral path.

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 by reproducing the custom-agent delegation with the failing codex exec --ephemeral invocation on Windows, then compare it with normal mode and the project-scoped versus global agent setups. Read the thread-registration and teardown discussion in #35781. Done means ephemeral custom-agent spawning succeeds, or the workflow is rejected before exposing an unusable spawn path.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.