Skip to content

Bug: spawn_agent v2 exposes parameter task_name but validation error refers to nonexistent parameter agent_name #64539

Backlog

Description

@zsicheng0214

Version / Commit

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

Summary

In MultiAgentV2, spawn_agent exposes its required naming parameter to the model as task_name, but when a model passes an invalid value (such as a hyphenated name like "ledger-audit"), the validation error returned to the model cites agent_name ("agent_name must use only lowercase letters, digits, and underscores") — a parameter name that does not exist in the spawn_agent v2 tool schema.

Source Location (main @ 065e18b)

  1. Tool schema names the parameter task_name — codex-rs/core/src/tools/handlers/multi_agents_spec.rs:139-144 & 163:
    properties.insert(
        "task_name".to_string(),
        JsonSchema::string(Some(
            "Task name for the new agent. Use lowercase letters, digits, and underscores."
                .to_string(),
        )),
    );
    ...
    Some(vec!["task_name".to_string(), "message".to_string()]),
  2. Validation error hardcodes agent_name — codex-rs/protocol/src/agent_path.rs:143 and 229:
    Err("agent_name must use only lowercase letters, digits, and underscores".to_string())

Reproduction

  1. Run a MultiAgentV2 session where the model invokes spawn_agent with {"task_name": "ledger-audit", "message": "..."}.
  2. Observe the tool error returned to the model:
    agent_name must use only lowercase letters, digits, and underscores
    
    The model is told to fix agent_name, even though its tool call schema only has task_name.

(Reproduced during TraceTrial-Bench Core-95 evaluation on L4-pending-child-at-exit-001 with [email protected].)

Expected Behavior

  1. Report the actual schema parameter name (task_name) in spawn_agent v2 validation errors (e.g., "task_name must use only lowercase letters, digits, and underscores").
  2. Optionally add "pattern": "^[a-z0-9_]+$" to the task_name JSON Schema property so models see the machine-readable constraint up front.

Activity

  1. added
    bug
    CLI
    subagent
    on Nov 29, 2026
  2. akhil9tiet commented on Nov 29, 2026

    @akhil9tiet

    I'm interested in working on this — please assign it to me.

  3. akhil9tiet commented on Nov 29, 2026

    @akhil9tiet

    Verified against main. Root cause: spawn_agent v2 declares its naming parameter as task_name (codex-rs/core/src/tools/handlers/multi_agents_spec.rs:140,163), but the value is validated by the shared validate_agent_name in codex-rs/protocol/src/agent_path.rs, whose errors hardcode agent_name (:143 and :229). Failing path: the model calls spawn_agent with {"task_name": "ledger-audit", ...} → validation returns "agent_name must use only lowercase letters, digits, and underscores" → that string is returned to the model as the tool error, but the schema has no agent_name parameter, so the model has nothing valid to fix. Proposed fix: report the actual schema parameter name (task_name) in spawn_agent v2 validation errors — thread the field name through the validator (it is shared with AgentPath segment validation, so a blanket rename would mislabel path errors) — and optionally add "pattern": "^[a-z0-9_]+$" to the task_name schema property so the constraint is visible up front.

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