Repository navigation
Description
Summary
A scan configured with xAI (https://api.x.ai/v1) as a native custom provider passes the dry run and authenticates. The first model request is then rejected with HTTP 422, because Codex sends tools of type namespace and xAI's Responses API does not support that type. The Codex Security MCP tools and the collaboration tools are both sent this way, so no scan can get started.
Environment
@openai/codex-security0.5.0 (bundled@openai/codex0.163.0)- Linux,
node:22-bookworm-slimcontainer, GitLab CI - Protocol: Responses API (
wire_api = "responses") - Model:
grok-4.7
Reproduction
Any small repository works:
mkdir -p /tmp/probe && cd /tmp/probe
git init -q && echo 'print(1)' > app.py && git add -A \
&& git -c user.email=a@b.c -c user.name=p commit -qm init
export OPENAI_API_KEY="xai-..." # an xAI key; the CLI passes it to Codex as CODEX_API_KEY
npx --yes @openai/codex-security@0.5.0 scan . \
--auth api-key --model grok-4.7 --effort low \
--codex 'model_provider="xai"' \
--codex 'model_providers.xai.name="xAI"' \
--codex 'model_providers.xai.base_url="https://api.x.ai/v1"' \
--codex 'model_providers.xai.wire_api="responses"' \
--codex 'model_providers.xai.env_key="CODEX_API_KEY"'Observed in CI with the same flags and configuration.
Observed
[00:01] Scan phase: preflight (0/3 files).
unexpected status 422 Unprocessable Entity: {"error":"Failed to deserialize the JSON body into the target type: tools[7].type: unknown variant `namespace`, expected one of `function`, `web_search`, `x_search`, `image_generation`, `collections_search`, `file_search`, `code_execution`, `code_interpreter`, `mcp`, `shell`, `tool_search`"}, url: https://api.x.ai/v1/responses
When captured against a local mock endpoint, the request had tool types function, namespace and web_search. The namespace entries are collaboration and mcp__codex_security.
Expected
The scan runs on a Responses-compatible provider that supports function tools but not namespace.
Notes
- Codex 0.163.0's
model_providers.<id>.capabilitiesaccepts onlyexternal_web_accessandremote_compaction. There is no setting to disable or flatten namespaced tools for a custom provider (see Clarify the compatibility contract fornamespace_toolson a user-definedmodel_providercodex#48847 and Custom Responses provider intermittently fails with nativenamespacetool routing errors codex#32318, the same failure on OpenRouter). - Two more open Codex issues affect xAI once the tools are accepted: Replayed reasoning items send "content": null, which the Responses API schema does not permit codex#47733 (
"content": nullon replayed reasoning) and Local compaction sends tool_choice=auto with empty tools, causing xAI/Grok HTTP 400 codex#46773 (tool_choicewith an empty tool list during compaction). - Cost:
estimateScanCosthas no pricing for xAI models, so--max-costcannot stop a scan through this provider.
Request
- Send
namespacetools as plainfunctiontools for providers that cannot accept them, either automatically for non-OpenAI providers or through a provider capability, and pin a Codex release that includes it. - Once that works, consider a built-in
--provider xai(XAI_API_KEY,https://api.x.ai/v1), following the Cheaper Inference addition (feat: add Cheaper Inference inference provider #1623), with pricing so--max-costis enforced.
Happy to test a fix against xAI.
Activity
mldangelo-oai commentedon Nov 15, 2026
Reproduced on
173483d7with Codex Security 0.10.0 and bundled Codex 0.167.1. A Standard scan of a one-file fixture passed--dry-runwithout making a model request. On the first real request to a loopback Responses endpoint, Codex declared bothcollaborationandmcp__codex_securityas namespaces. A fixture that rejected namespaces returned HTTP 422 with or without the one-thread setting.The replay case can also be reproduced offline. When the endpoint accepted namespaces and returned a scripted
collaboration.spawn_agentcall, Codex sent anagent_messagein its third request. Withfeatures.multi_agent_v2.max_concurrent_threads_per_session=1, the same call returnedagent thread limit reached. Neither request in that run contained anagent_message.#2437 documents the gateway workaround for single-threaded Standard scans. For direct support, the remaining acceptance test is a gateway-free Standard scan with delegation enabled that round-trips the scan-completion tool, replays a delegated message successfully, and seals its manifest. The fixtures above exercised the wire format. Live direct xAI inference remains unverified.
AdityaxDeore commentedon Nov 17, 2026
I'm implementing this — a loopback Responses compatibility proxy: for non-OpenAI Responses providers, flatten the
namespacetool declarations to plainfunctiontools on the way out and restore the namespace calls on the way back (JSON + streaming), so delegation and the scan-completion tool keep working. I reproduced the 422 against a loopback mock and verified the round-trip (scriptedcollaboration.spawn_agentcall,agent_messagereplay) with the bundled Codex 0.167.1. No--provider xaipreset in this one — that's a follow-up.