Root agent gets stuck emitting `wait` instead of a requested second `spawn_agent` call

Open
#35,541 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
rust

Research direction

Start by inspecting the full session rollout under the Codex sessions directory, focusing on the recorded spawn_agent and wait function calls after the first child completes. Compare the expected typed delegation with the repeated wait calls using nonexistent cell_id values. Done means the second request emits spawn_agent or a concrete validation/runtime error instead of an unrelated wait call.

Written by the indexing model from the issue text.

Description

app bug subagent tool-calls windows-os
What version of Codex CLI is running?

codex-cli 0.145.0

Which model were you using?

gpt-5.6-sol

What platform is your computer?

Windows, Codex Desktop, PowerShell.

What happened?

After one successful typed subagent delegation, the root agent became stuck selecting the wait tool when it was explicitly asked to spawn a second typed subagent.

The first delegation worked. The full rollout contained a normal call similar to:

response_item.type = function_call
response_item.name = spawn_agent
arguments.agent_type = custom-planner
arguments.task_name = plan_task
arguments.fork_turns = none

Later, the user explicitly requested a second typed checker subagent. The assistant said it was starting that subagent, but the full session rollout recorded wait, not spawn_agent:

response_item.type = function_call
response_item.name = wait
arguments.cell_id = wrong
arguments.yield_time_ms = 1000

The tool then correctly returned:

exec cell wrong not found

This repeated many times with placeholder cell IDs such as wrong, dummy, x, and not-a-cell. Repeating the user request in a fresh turn did not recover tool selection. No second spawn_agent function call, child-start activity, or child thread appeared in the full rollout.

The typed subagent facility itself was available: the earlier spawn_agent succeeded in the same session. The visible schema required task_name; an initial call without it failed as expected, and retrying with task_name succeeded.

This is distinct from #34919. In #34919 the subagent genuinely spawns and the full rollout contains the spawn, while the public exec JSON stream omits it. Here the full rollout itself contains an incorrect wait function call and no second spawn occurred.

Steps to reproduce
  1. Start a Codex Desktop task with typed custom agents available.
  2. Call spawn_agent with agent_type, task_name, and fork_turns: none.
  3. Wait for a relatively long-running child, including one or more wait_agent timeouts.
  4. After the child completes, explicitly request a second typed subagent with a different agent_type and task_name.
  5. Inspect the full session rollout under the Codex sessions directory.
  6. Observe that subsequent attempted delegation may be emitted as function_call.name: wait with a nonexistent cell_id, and repeated requests do not recover.

I do not yet have a minimal deterministic reproduction outside the long conversation, so this may be model tool-call perseveration, app-side tool selection/serialization state, or interaction between the two.

Expected behavior

An explicit request to start the second typed subagent should emit a spawn_agent function call, or return a concrete spawn_agent validation/runtime error.

The root agent should not silently substitute the unrelated exec-cell wait tool, especially with a nonexistent placeholder cell_id.

Privacy note

All agent names, task names, paths, session identifiers, call identifiers, repository details, provider details, and timestamps above are sanitized or omitted. No credentials or user data are included.

Dominant language
Rust
Stars
125k
Forks
19.5k
Avg merge
1m
Merged PRs (30d)
1k

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.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.