Skip to content

xAI Responses API rejects the namespace tool type, so scans through a custom xAI provider fail #2412

Open

Description

@mdsummers

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-security 0.5.0 (bundled @openai/codex 0.163.0)
  • Linux, node:22-bookworm-slim container, 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

Request

  1. Send namespace tools as plain function tools 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.
  2. 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-cost is enforced.

Happy to test a fix against xAI.

Activity

  1. added
    bugSomething isn't working
    area:providersModel providers, custom endpoints, model selection, and provider-specific settings.
    on Nov 15, 2026
  2. mldangelo-oai commented on Nov 15, 2026

    @mldangelo-oai
    Collaborator

    Reproduced on 173483d7 with Codex Security 0.10.0 and bundled Codex 0.167.1. A Standard scan of a one-file fixture passed --dry-run without making a model request. On the first real request to a loopback Responses endpoint, Codex declared both collaboration and mcp__codex_security as 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_agent call, Codex sent an agent_message in its third request. With features.multi_agent_v2.max_concurrent_threads_per_session=1, the same call returned agent thread limit reached. Neither request in that run contained an agent_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.

  3. AdityaxDeore commented on Nov 17, 2026

    @AdityaxDeore

    I'm implementing this — a loopback Responses compatibility proxy: for non-OpenAI Responses providers, flatten the namespace tool declarations to plain function tools 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 (scripted collaboration.spawn_agent call, agent_message replay) with the bundled Codex 0.167.1. No --provider xai preset in this one — that's a follow-up.

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

    area:providersModel providers, custom endpoints, model selection, and provider-specific settings.bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址