Repository navigation
Description
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
- Native parent → native child: works with the same sentinel pattern,
fork_turns="none", andreasoning_effort="medium". - Custom parent → custom child: fails before child creation because
spawn_agent.messageis absent. - Native parent → custom child: tracked separately in V2 cross-provider sub-agent loses NEW_TASK body in encrypted_content #92.
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
- Ensure routed custom parents receive the complete V2
spawn_agentschema, including requiredmessageandtask_namefields. - Preserve collaboration tool schemas through provider-specific request translation instead of relying only on prompt guidance.
- Validate the translated schema at the OpenCodex boundary before sending the request upstream.
- If a model returns
{}or omitsmessage, fail once with an actionable compatibility error rather than allowing an unbounded retry loop. - Add a regression matrix covering:
- native parent → native child;
- native parent → custom child (V2 cross-provider sub-agent loses NEW_TASK body in encrypted_content #92);
- custom parent → native child;
- custom parent → custom child;
- V1 and V2 collaboration surfaces.
- 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
lidge-jun commentedon Jul 23, 2026
Thanks for the detailed report. We traced the spawn_agent argument flow on current
dev: OpenCodex preserves the receivedspawn_agentparameter 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:
spawn_agenttool schema Codex sends (additional_tools)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 v1is the reliable surface for heterogeneous/custom-model delegation; omittingmodel(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.lidge-jun commentedon Jul 23, 2026
Closing this for now as needs-info without a response: we traced the argument flow on current
devand 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.
brunoflma commentedon Jul 23, 2026
Thanks — here is the requested sanitized four-boundary capture from one failing custom-parent → custom-child V2 session.
Environment:
2.7.33(isolated reproduction)2.7.350.145.024.16.026200HTTP 200). Provider/model identifiers are intentionally redacted.The failing request was the Codex CLI
/v1/responsespath, where the declaration arrived in top-levelbody.tools; Codex Desktop carries the equivalent declaration inside theadditional_toolsinput item.1. Incoming
spawn_agentschemaSanitized 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.deltaevent 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:
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_agentcall 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 aspawn_agenttool call, so there were no boundaries 3–4 to capture on that version. The complete failing capture above was therefore collected against an isolated2.7.33instance, without downgrading the main installation.Please reopen if this is sufficient; I can run a targeted follow-up capture on
2.7.35if you provide a preferred trace hook or reproduction prompt.