Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: normalize Codex Responses request body for compat with LiteLLM/Anthropic clients#7

Open
srizzo wants to merge 1 commit into
EvanZhouDev:main from
srizzo:fix/codex-responses-request-normalization
Open

fix: normalize Codex Responses request body for compat with LiteLLM/Anthropic clients #7
srizzo wants to merge 1 commit into
EvanZhouDev:main from
srizzo:fix/codex-responses-request-normalization

Conversation

@srizzo

@srizzo srizzo commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The Codex /v1/responses backend differs from the public OpenAI Responses API in two ways that matter for clients forwarding through openai-oauth (LiteLLM → Anthropic-format, Cursor, etc.):

  1. Codex reasoning models reject user / temperature / top_p. LiteLLM's Anthropic-Messages adapter forwards temperature by default (Claude Code sets it on every request), so every call errors out with:

    The feature "temperature" is not supported. temperature is not supported for reasoning models

    before the backend even starts generating.

  2. Codex uses the internal tool name web_search for what OpenAI publicly calls web_search_preview. It also defaults to cached-only mode and requires external_web_access: true for live searches. Without those two adjustments the tool is accepted but runs in cached mode, so the model returns plausible-looking but hallucinated results.

Additionally, when web_search_preview is renamed, a caller-supplied tool_choice that points at a specific function becomes stale (Codex returns Tool choice 'function' not found in 'tools' parameter). Reset it to \"auto\" in that case; \"none\" is preserved intact.

What changes

  • normalizeCodexResponsesBody in packages/openai-oauth-core/src/transport.ts:
    • delete normalized.user
    • delete normalized.temperature
    • delete normalized.top_p
    • Map tools[*].type === \"web_search_preview\"{ type: \"web_search\", external_web_access: true, ...rest }
    • If that rename happened and tool_choice !== \"none\", set it to \"auto\"
  • 6 new unit tests in packages/openai-oauth-core/test/transport.test.ts covering stripping, renaming, tool_choice handling in both the rename and no-rename paths, and preservation of sibling keys (e.g. search_context_size) on the web_search tool config.

None of these changes affect requests that don't carry the offending params or tools.

Related

Test plan

  • bun run test — all tests pass (+6 new)
  • Recommended reviewer verification:
    • bun run test
    • End-to-end with claude-codex and a WebSearch-capable prompt: confirm the backend performs a live search, e.g. the response mentions today's date or content that post-dates the model's knowledge cutoff.

...nthropic clients
The Codex `/v1/responses` backend differs from the public OpenAI Responses
API in two ways that matter for clients forwarding through openai-oauth:
1. Codex reasoning models reject `user`, `temperature`, and `top_p`.
 LiteLLM's Anthropic-Messages adapter forwards `temperature` by
 default (Claude Code sets it on every request), so every call errors
 out with "The feature 'temperature' is not supported. temperature is
 not supported for reasoning models" before the backend even starts
 generating. Strip these three params in `normalizeCodexResponsesBody`.
2. Codex uses the internal name `web_search` for the OpenAI WebSearch
 server tool (the public name is `web_search_preview`). It also
 defaults to cached-only mode and requires `external_web_access: true`
 to perform live searches; without it the tool accepts the call but
 returns cached results, causing models to hallucinate plausible but
 wrong results. When a `web_search_preview` tool is present in the
 request, rename it to `web_search`, inject `external_web_access: true`,
 and reset any function-pointing `tool_choice` to `"auto"` so it does
 not become stale after the rename (Codex returns "Tool choice
 'function' not found in 'tools' parameter" otherwise). `tool_choice:
 "none"` is preserved intact.
Neither change affects requests that do not carry the offending params
or tools. Tests cover stripping, renaming, tool_choice handling in both
the rename and no-rename paths, and preservation of sibling keys on the
web_search tool config.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /