Skip to content

V2 custom-model parent emits empty spawn_agent arguments for custom-model children #290

Closed as not planned

Description

@brunoflma

Client or integration

Codex CLI / Codex App

Provider or upstream service

Multiple custom providers (provider-agnostic reproduction)

OpenCodex version

2.7.31

Endpoint or capability

/v1/responses, V2 collaboration surface, custom-model parent spawning a custom-model child through spawn_agent.

Current behavior

When the active parent is itself a routed custom model and it is instructed to create a child using another routed custom model, the parent repeatedly attempts to call spawn_agent without its required arguments.

The Codex tool router receives an empty or incomplete argument object and rejects every attempt because message is missing. No child task is successfully created, and the parent keeps retrying until the run times out.

Observed error:

codex_core::tools::router: error=failed to parse function arguments:
missing field `message` at line 1 column 2

In the controlled reproduction this happened repeatedly (12 malformed attempts) without progress.

This is separate from, but related to, #92. Issue #92 covers a native parent creating a custom child whose NEW_TASK body is unreadable backend ciphertext. This report covers a custom parent creating a custom child, where the failure happens earlier: the parent does not produce a valid spawn_agent call.

Expected behavior

A routed custom parent should receive the complete V2 spawn_agent tool contract, emit the required self-contained message and task_name fields, apply the custom child model override, and create exactly one child task.

The child should receive the plaintext task, execute it, and return the requested sentinel without retries.

Minimal redacted reproduction

1. Configure OpenCodex with at least two routed custom models in the Codex catalog.
2. Use a routed custom model as the active parent model.
3. Ask the parent to create exactly one child with:
   - model: a routed custom model
   - reasoning_effort: medium
   - fork_turns: none
   - message: a short self-contained instruction requiring an exact sentinel
4. Observe the Codex stderr/tool-router events.

Example instruction:

Create exactly one sub-agent using a routed custom model.
Use reasoning_effort="medium" and fork_turns="none".
The child message must be self-contained and require the exact response:
CUSTOM-CHILD-SENTINEL OK
Wait for the child and return only its response.

Actual response or error

The parent repeatedly says it will create the child, but each tool call is rejected:

failed to parse function arguments: missing field `message`

No valid child response is produced and the run eventually times out.

Controls

Likely failure boundary

The failure appears to be in the collaboration tool schema/argument path exposed to routed custom models:

  • the model is aware that it should call spawn_agent;
  • the required argument contract is not followed or is not preserved;
  • the client receives {} or an incomplete object;
  • Codex rejects it before child creation.

This suggests that hidden model/effort guidance alone is insufficient if the adapter or injected tool contract does not preserve the required public fields such as message and task_name.

Proposed solution

  1. Ensure routed custom parents receive the complete V2 spawn_agent schema, including required message and task_name fields.
  2. Preserve collaboration tool schemas through provider-specific request translation instead of relying only on prompt guidance.
  3. Validate the translated schema at the OpenCodex boundary before sending the request upstream.
  4. If a model returns {} or omits message, fail once with an actionable compatibility error rather than allowing an unbounded retry loop.
  5. Add a regression matrix covering:
  6. Until full V2 support is available, document the reliable workaround:
    • feature native models for sub-agents; or
    • use the documented V1 mode for heterogeneous/custom-model delegation where supported.

Additional context

No credentials, provider-specific identifiers, request headers, or private payloads are included in this report.

Activity

  1. lidge-jun commented on Jul 23, 2026

    @lidge-jun
    Owner

    Thanks for the detailed report. We traced the spawn_agent argument flow on current dev: OpenCodex preserves the received spawn_agent parameter schema through the Responses→chat translation and preserves non-empty provider argument deltas on the way back. It does normalize a tool call that arrives with zero argument bytes to {} so the Responses item stays valid JSON — which matches your symptom, but doesn't tell us where the bytes vanished.

    To pin the boundary we'd need one sanitized four-boundary capture from a failing session:

    1. the incoming spawn_agent tool schema Codex sends (additional_tools)
    2. the outgoing provider-side tool schema
    3. the raw provider tool-call arguments
    4. the emitted Responses argument events

    That distinguishes an empty Codex-side schema, a model/provider structured-tool limitation, and an OpenCodex translation defect. Note this is separate from #92: #290 fails before child creation, while #92 loses the task body after a valid spawn.

    Until then, ocx v2 mode v1 is the reliable surface for heterogeneous/custom-model delegation; omitting model (inheriting the parent model) is another workaround, though not proof of V2 structured-call support. Keeping this open as needs-info — happy to dig further with the capture.

  2. added
    needs-info
    on Jul 23, 2026
  3. lidge-jun commented on Jul 23, 2026

    @lidge-jun
    Owner

    Closing this for now as needs-info without a response: we traced the argument flow on current dev and OpenCodex preserves the spawn_agent schema and non-empty argument deltas end-to-end, so without the four-boundary capture requested above we cannot determine where the argument bytes vanish (Codex-side schema, model/provider emission, or translation).

    If you can attach the sanitized capture from a failing session (incoming additional_tools schema, outgoing provider tool schema, raw provider tool-call arguments, emitted Responses argument events), please comment here — we'll reopen immediately and dig in.

  4. brunoflma commented on Jul 23, 2026

    @brunoflma
    Author

    Thanks — here is the requested sanitized four-boundary capture from one failing custom-parent → custom-child V2 session.

    Environment:

    • OpenCodex capture version: 2.7.33 (isolated reproduction)
    • Current installed OpenCodex version: 2.7.35
    • Codex CLI: 0.145.0
    • Node: 24.16.0
    • OS: Windows 11 x64, build 26200
    • Parent and requested child were both routed custom models. Local usage data confirmed that the custom child override was requested, resolved, and routed through a custom provider (HTTP 200). Provider/model identifiers are intentionally redacted.

    The failing request was the Codex CLI /v1/responses path, where the declaration arrived in top-level body.tools; Codex Desktop carries the equivalent declaration inside the additional_tools input item.

    1. Incoming spawn_agent schema

    Sanitized shape observed at the parser boundary:

    {
      "source": "body.tools",
      "type": "function",
      "name": "spawn_agent",
      "strict": false,
      "parameters": {
        "type": "object",
        "properties": {
          "agent_type": { "type": "string" },
          "fork_turns": { "type": "string" },
          "message": { "type": "string", "encrypted": true },
          "model": { "type": "string" },
          "reasoning_effort": { "type": "string" },
          "task_name": { "type": "string" }
        },
        "required": ["task_name", "message"],
        "additionalProperties": false
      }
    }

    2. Outgoing provider-side tool schema

    The translated chat-completions tool retained the same required contract:

    {
      "type": "function",
      "function": {
        "name": "spawn_agent",
        "parameters": {
          "type": "object",
          "properties": {
            "agent_type": { "type": "string" },
            "fork_turns": { "type": "string" },
            "message": { "type": "string", "encrypted": true },
            "model": { "type": "string" },
            "reasoning_effort": { "type": "string" },
            "task_name": { "type": "string" }
          },
          "required": ["task_name", "message"],
          "additionalProperties": false
        },
        "strict": false
      }
    }

    3. Raw provider tool-call arguments

    The provider returned the function call with a present string argument field, but the string contained zero bytes:

    {
      "name": "spawn_agent",
      "hasArguments": true,
      "arguments": "",
      "byteLength": 0
    }

    The same zero-byte result was observed on three consecutive attempts in the longer run.

    4. Emitted Responses argument events

    No response.function_call_arguments.delta event was emitted because there were no argument bytes. The captured events were:

    {
      "type": "response.output_item.added",
      "item": {
        "type": "function_call",
        "name": "spawn_agent",
        "arguments": ""
      }
    }

    followed by normalization at completion:

    {
      "type": "response.function_call_arguments.done",
      "arguments": "{}"
    }

    Codex then rejected the call:

    codex_core::tools::router: failed to parse function arguments:
    missing field `message` at line 1 column 2
    

    This capture pins the loss before the OpenCodex Responses event bridge: the incoming and outgoing schemas are complete, but the custom model/provider emits a spawn_agent call with a zero-byte argument string; OpenCodex then normalizes that empty string to {} as described in your comment.

    Additional version note: after updating the main installation to 2.7.35, two custom-parent/custom-child probe windows (30 s and 50 s) did not emit a spawn_agent tool call, so there were no boundaries 3–4 to capture on that version. The complete failing capture above was therefore collected against an isolated 2.7.33 instance, without downgrading the main installation.

    Please reopen if this is sufficient; I can run a targeted follow-up capture on 2.7.35 if you provide a preferred trace hook or reproduction prompt.

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

    needs-info

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions