Skip to content

feat(proxy): auto-enable drop_params for Codex user agents - #34068

Merged
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_codex_auto_drop_params
Jul 21, 2026
Merged

mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_codex_auto_drop_params

Conversation

@mateo-berri

Copy link
Copy Markdown
Contributor

Relevant issues

Complements #33228 and #34058 (Codex CLI against bedrock_mantle/ Responses deployments)

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

All runs below were captured at commit d2b573c against the real OpenAI API (real spend), proxy booted with

model_list:
  - model_name: gpt-5.6-sol
    litellm_params:
      model: openai/gpt-5.6-sol
      api_key: os.environ/OPENAI_API_KEY

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

Control at the same commit: a non-Codex client sending a param OpenAI does not accept still gets the normal error, so nothing changed for other clients

curl -s http://localhost:26433/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.6-sol","thinking":{"type":"enabled","budget_tokens":1024},"messages":[{"role":"user","content":"Reply with exactly: ok"}]}'
{"error":{"message":"litellm.UnsupportedParamsError: openai does not support parameters: ['thinking'], for model=gpt-5.6-sol. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n...","code":"400"}}

The identical body with a Codex user agent succeeds because the proxy now injects drop_params: true for it

curl -s http://localhost:26433/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" \
  -H "User-Agent: codex_exec/0.144.5 (Mac OS 26.4.0; arm64) WarpTerminal (codex_exec; 0.144.5)" \
  -d '{"model":"gpt-5.6-sol","thinking":{"type":"enabled","budget_tokens":1024},"messages":[{"role":"user","content":"Reply with exactly: ok"}]}'
{"id":"chatcmpl-E3uvt26pRA1GDsOTQrxQuLOvn64R1","model":"gpt-5.6-sol","choices":[{"finish_reason":"stop","message":{"content":"ok","role":"assistant"}}]}

Real Codex CLI end to end through the same proxy

$ npx -y @openai/codex@0.144.5 exec --skip-git-repo-check -s read-only \
    -c model_provider=litellm \
    -c 'model_providers.litellm.name="litellm"' \
    -c 'model_providers.litellm.base_url="http://localhost:26433/v1"' \
    -c 'model_providers.litellm.wire_api="responses"' \
    -c 'model_providers.litellm.env_key="LITELLM_KEY"' \
    -m gpt-5.6-sol "Reply with exactly: codex ua auto drop works"
codex
codex ua auto drop works
tokens used
10,570

Proxy debug log from those runs, showing the genuine Codex user agent and the injected flag

'user_agent': 'codex_exec/0.144.5 (Mac OS 26.4.0; arm64) WarpTerminal (codex_exec; 0.144.5)'
'drop_params': True

Type

🆕 New Feature

Changes

Claude Code user agents already get drop_params enabled automatically by the proxy so client-specific params do not fail requests routed to providers that reject them. Codex has the same problem: since 0.144 it sends service_tier: "priority" whenever a speed tier is selected in ~/.codex/config.toml, which some providers reject (Bedrock Mantle only accepts auto and default, see #34058)

This PR extends the existing mechanism to Codex. is_codex_user_agent matches the shared codex_ prefix of codex_cli_rs/ (TUI), codex_exec/ (exec mode), and codex_vscode/ (IDE extension), and should_auto_drop_params_for_claude_code is renamed to should_auto_drop_params_for_agentic_cli and covers both clients. Precedence is unchanged: an explicit drop_params from the caller or in the operator's litellm_settings always wins over the default, and non-matching user agents are untouched

Together with #33228 and #34058 this makes Codex against bedrock_mantle/ Responses deployments work with zero extra proxy configuration

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends automatic parameter dropping to Codex clients. The main changes are:

  • Recognizes Codex TUI, exec, and IDE user agents
  • Preserves explicit caller and operator settings
  • Adds focused tests for Codex detection and configuration precedence

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • Explicit caller and operator settings still take precedence.
  • Tests cover the documented Codex variants and preserve existing behavior.

Important Files Changed

Filename Overview
litellm/proxy/litellm_pre_call_utils.py Adds Codex user-agent detection and extends the existing automatic drop_params behavior without changing explicit-setting precedence
tests/test_litellm/proxy/test_litellm_pre_call_utils.py Adds Codex user-agent and precedence cases while retaining the existing Claude Code and unrelated-client coverage

Reviews (1): Last reviewed commit: "feat(proxy): auto-enable drop_params for..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 30.97%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
✅ 27 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_completion_streaming 58.8 ms 34.6 ms +69.66%
⚡ test_response_to_model_response_object 543.5 µs 411.8 µs +31.99%
⚡ test_cost_per_token_openai 597.7 µs 520 µs +14.95%
⚡ test_cost_per_token_anthropic 602.6 µs 527.2 µs +14.29%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing litellm_codex_auto_drop_params (d2b573c) with litellm_internal_staging (214945a)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (9ad8698) during the generation of this report, so 214945a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@mateo-berri
mateo-berri merged commit 7e66f00 into litellm_internal_staging Jul 21, 2026
80 checks passed
@mateo-berri
mateo-berri deleted the litellm_codex_auto_drop_params branch July 21, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants