Skip to content

Bug: CodexErrorDetails::AgentLimitReached { max_threads } drops max_threads from Display and model-facing collab spawn error #64537

Backlog

Description

@zsicheng0214

Version / Commit

  • Observed in: codex-cli 0.172.0 (codex exec --json)
  • Verified on main (065e18b)

Summary

CodexErrorDetails::AgentLimitReached { max_threads } explicitly carries the configured max_threads: usize value, but its thiserror #[error(...)] format string omits {max_threads} and renders only "agent thread limit reached". Because collab_spawn_error forwards format!("collab spawn failed: {err}") to the model, a model hitting the concurrency cap receives "collab spawn failed: agent thread limit reached" with no indication of what the limit is (or that closing/waiting on active agents frees slots).

Source Location (main @ 065e18b)

  1. Error Display omits max_threads — codex-rs/protocol/src/error.rs:152-153:
    #[error("agent thread limit reached")]
    AgentLimitReached { max_threads: usize },
  2. Model-facing spawn error — codex-rs/core/src/tools/handlers/multi_agents_common.rs:68-78:
    pub(crate) fn collab_spawn_error(err: CodexErr) -> FunctionCallError {
        match err.details() {
            ...
            _ => FunctionCallError::RespondToModel(format!("collab spawn failed: {err}")),
        }
    }

Reproduction

  1. Run a multi-agent workflow that attempts to spawn more concurrent subagents than agents.max_threads (e.g., spawning 5 parallel subagents under a lower thread cap).
  2. Observe the tool error returned to the model:
    collab spawn failed: agent thread limit reached
    
    The max_threads value already present on AgentLimitReached { max_threads } is discarded.

(Reproduced during TraceTrial-Bench Core-95 multi-agent evaluation on C6-infra-research-subagent-001 with [email protected].)

Expected Behavior

Interpolate {max_threads} in CodexErrorDetails::AgentLimitReached (e.g., #[error("agent thread limit reached (max_threads={max_threads})")] or in collab_spawn_error) so both logs and the model know the active thread cap and can plan batching/closing accordingly.

Activity

  1. added
    bug
    CLI
    subagent
    on Nov 29, 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

    CLIbugsubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions