bug(model-sources): multi-agent capability does not preserve client collaboration tools
Codex can complete ordinary requests through an OpenAI-compatible Model Source while failing to use subagents. A source can advertise multi_agent_version: "v2" to the client, yet codex-lb still removes the client-supplied collaboration namespace from the upstream Responses request. Source-provided base instructions are also lost in the catalog projection.
Environment and scope
- Observed on a self-built fork based on
1.25.0-beta.6, before fork commit00164ab0; Docker Compose deployment, Codex CLI0.156.1. - Enabled OpenAI-compatible Model Source with Responses, streaming, and tools support; custom model slug (
custom/coderbelow is an anonymized example). - HTTP Responses transport. The successful fix does not require WebSocket support or changing the source credential.
- Inspected upstream
mainat09a140fa: the same catalog projection and tool-filter behavior are still present. The deployed end-to-end verification below was on the fork, not a clean upstream-main deployment.
Reproduction
-
Configure a Responses-capable source backed by a model whose own Codex catalog advertises multi-agent support.
-
Store the upstream capability metadata on its source model. The relevant excerpt is:
{ "tool_mode": "code_mode_only", "multi_agent_version": "v2", "base_instructions": "Example upstream coding instructions", "experimental_supported_tools": [], "use_responses_lite": false } -
Fetch
GET /backend-api/codex/modelsorGET /v1/models?client_version=0.156.1. The source entry'sbase_instructionsis empty despite being declared. The other raw capability fields can pass through when actually stored. -
Refresh the client's catalog, select the custom model with
supports_websockets = false, and ask Codex to spawn one child using the same model. Use a normal persisted session. -
Observe the source-bound request: the client-supplied
type: "namespace",name: "collaboration"tool declaration is removed unlessnamespacewas separately added toexperimental_supported_tools. Ordinaryfunctiontools still survive.
For a deterministic route test, use a recording upstream stub to inspect tools. For an end-to-end test against a real Codex-compatible backend, use Codex's actual reserved collaboration schema; an abbreviated hand-written spawn_agent schema may itself be rejected by the backend.
Root cause
- Missing imported metadata can disable client tool assembly. In the affected setup, the model import initially retained only a subset of upstream fields and omitted
tool_mode/multi_agent_version. Existing raw metadata passthrough already preserves these keys when present; this is an import/configuration prerequisite, not evidence that the serializer drops every capability field. - Base instructions are lost.
_to_upstream_modelnever setsUpstreamModel.base_instructions. The Codex serializer excludes that key from raw extras and emits the empty first-class field instead. - Catalog capability and request filtering disagree.
source_model_supported_tool_typesonly considers search and explicit experimental tool-type declarations._source_tool_type_supportedtherefore rejectsnamespaceeven when the source model declares multi-agent support.
Proposed upstream change
- Project a string-valued
raw_metadata_json.base_instructionsintoUpstreamModel.base_instructions; retain the existing empty default otherwise. - Derive
namespacesupport from a non-blank stringmulti_agent_versioninsource_model_supported_tool_types. Keep the existing explicit experimental-tool opt-in and conservative behavior for undeclared sources. - Preserve the client's complete namespace declaration and matching tool choices. Do not fabricate or rewrite reserved collaboration schemas.
- Document that custom-model imports and locally pinned
model_catalog_jsonfiles must retain/refresh upstream capability metadata. Keep transport and Responses Lite settings aligned with the source's verified support. - Retain capability filtering for other hosted/custom tools. This issue does not propose unconditional forwarding of every tool type, new runtime settings, or changes to replay namespace stripping.
Acceptance criteria
- [ ] Both Codex catalog routes preserve valid source base instructions and multi-agent metadata.
- [ ] v1/v2 declarations allow client namespace tools through both
/v1/responsesand/backend-api/codex/responses, including trailing-slash equivalents. - [ ] Complete namespace schemas and matching tool choices survive when another unsupported tool is filtered.
- [ ] Missing, blank, or malformed multi-agent declarations retain conservative filtering; explicit
experimental_supported_tools: ["namespace"]remains supported. - [ ] Generic function tools and existing search/custom tool opt-ins retain their behavior.
- [ ] A real parent/child Codex session completes through the custom HTTP source, with model/provider inheritance verified in session records.
- [ ] OpenSpec requirements/context and regression tests are updated together.
Working implementation and verification
Reference implementation: fork commit 00164ab0. It contains the small catalog change, route/unit coverage, and archived OpenSpec artifacts; it should be ported as a focused change rather than merging the fork's unrelated history.
- Isolated commit checkout: 79 focused tests passed; repository lint and typecheck passed. Full local CI was not completed because Rust/Cargo was unavailable on the host; this is not a claim of a green upstream CI matrix.
- Strict validation of the change passed. Whole-spec validation had the same 15 pre-existing failing specs before and after the change.
- Deployed the fix to three HA backends and verified a real Codex parent/child using the same custom model and HTTP provider. Child returned
DEPLOY_CHILD_OK; parent returnedDEPLOY_SUBAGENT_OK; the parent-child relationship and completion were checked in persisted session records. - Existing replicas can use the explicit
namespaceexperimental-tool opt-in as a workaround after restoring missing capability metadata. The patch makes the extra wire-type declaration unnecessary for models already advertising multi-agent support.
Related: #1184 (injected tools: [] and reserved-schema handling) and #1185 (HTTP bridge metadata/deduplication). This report concerns Model Source catalog projection and source-specific tool filtering; those closed issues address different paths.
Confirmed on main 09a140fa9. _to_upstream_model (app/modules/model_sources/catalog.py:36-93) never sets base_instructions. source_model_supported_tool_types (catalog.py:219-238) ignores multi_agent_version, so _source_tool_type_supported (app/modules/proxy/api.py:5381) drops the client's namespace tool. A focused PR against main is welcome. The base_instructions projection can land on its own. Inferring namespace from multi_agent_version changes the source tool contract, so it needs an OpenSpec MODIFIED delta and a maintainer ack. Until then, the experimental_supported_tools: ["namespace"] opt-in is the workaround.
Hi, I'd like to work on the remaining namespace half of this issue. I understand #2525 already merged the base_instructions part, so my plan is to reproduce the collaboration-namespace loss, preserve declared collaboration namespaces in the catalog and proxy, add the required OpenSpec MODIFIED delta, and add a test covering client collaboration tools. I aim to open a PR by 4 Nov. Please confirm this approach and the OpenSpec delta are still wanted — thank you!
Quick update: the PR is open as #2724, opened 10 Nov — later than the 4 Nov aim in my comment above. It covers the remaining namespace half (catalog fix, tests, OpenSpec delta). Thank you!