Skip to content

fix(proxy): strip unsupported reasoning params for GPT-5 via LiteLLM/SSO#176

Open
amdmax wants to merge 4 commits intomainfrom
fix/litellm-openai-models
Open

fix(proxy): strip unsupported reasoning params for GPT-5 via LiteLLM/SSO#176
amdmax wants to merge 4 commits intomainfrom
fix/litellm-openai-models

Conversation

@amdmax
Copy link
Collaborator

@amdmax amdmax commented Feb 27, 2026

Summary

  • Two-layer sanitization for GPT-5 models failing through LiteLLM and ai-run-sso because AI SDKs auto-inject unsupported reasoning params (reasoningSummary, reasoning_summary, reasoning)
  • Proxy-level (RequestSanitizerPlugin): strips params for ai-run-sso path, scoped to codemie-code and codemie-opencode agents only
  • OpenCode plugin (ReasoningSanitizerPlugin): strips params for direct LiteLLM path via temp file injection
  • LangGraph agent: useResponsesApi: false prevents injection at source
  • Shell hooks injection and SQLite session discovery for OpenCode sessions
  • Comprehensive test coverage: 57 new tests across 4 test files covering source validation, proxy stripping, temp file lifecycle, and beforeRun integration

Test plan

  • All 1782 unit tests pass (npm run test:unit)
  • ESLint passes with zero warnings
  • Manual verification: run codemie-code with CODEMIE_PROVIDER=litellm against GPT-5 model
  • Manual verification: run codemie-code with CODEMIE_PROVIDER=ai-run-sso against GPT-5 model
  • Verify reasoningEffort is preserved (not stripped)

Maksym Diabin and others added 4 commits February 27, 2026 14:25
AI SDKs (@langchain/openai, @ai-sdk/openai-compatible) detect GPT-5
and o-series as "reasoning models" and inject `reasoningSummary` /
`reasoning` params that LiteLLM/Azure proxies reject with:
"Unknown parameter: 'reasoningSummary'"

Changes:
- Add RequestSanitizerPlugin proxy plugin that strips unsupported
  reasoning params before forwarding requests upstream
- Scope plugin to codemie-code and codemie-opencode agents only
- In codemie-code agent: add inline param stripping for direct
  (non-proxy) SSO requests and force Completions API via
  useResponsesApi: false for LiteLLM compatibility

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
…etch

useResponsesApi: false already prevents LangChain from injecting reasoning
params at the source. The proxy request-sanitizer plugin covers the SSO path.
No need for duplicate stripping in the agent's fetch wrapper.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
Cover two-layer sanitization for GPT-5 models through LiteLLM and ai-run-sso:
- reasoning-sanitizer-source: plugin string validation (14 tests)
- request-sanitizer.plugin: proxy-level param stripping (21 tests)
- inject-sanitizer: temp file lifecycle management (8 tests)
- codemie-code-reasoning: beforeRun integration — provider mapping, plugin injection, cleanup (14 tests)
- Fix existing codemie-code-plugin.test.ts with reasoning-sanitizer mock

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
Missing source files that tests depend on:
- reasoning-sanitizer-source.ts: plugin source as string constant
- inject-sanitizer.ts: temp file write/cleanup lifecycle
- index.ts: barrel exports
- codemie-code.plugin.ts: updated imports and plugin injection

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
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