fix(proxy): strip cache_control from OpenAI format conversion#3841
Merged
Conversation
cc10143
force-pushed
the
feat/capability-injection
branch
from
June 7, 2026 13:23
377b5d7 to
6bb3e62
Compare
…1231#3805) - Remove cache_control passthrough from system messages, text blocks, and tools to prevent 400 errors on strict OpenAI-compatible endpoints - Always simplify single text block content to plain string format - Fixes two format conversion bugs reported in issue farion1231#3805
cc10143
force-pushed
the
feat/capability-injection
branch
from
June 7, 2026 13:32
6bb3e62 to
7f01ef1
Compare
Owner
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
farion1231
approved these changes
Jun 8, 2026
farion1231
left a comment
Owner
There was a problem hiding this comment.
Thank you for your contribution!
1 task
AnXiYiZhi
pushed a commit
to AnXiYiZhi/DevCLaw-old
that referenced
this pull request
Jun 9, 2026
…1231#3841) * fix(proxy): strip cache_control from OpenAI format conversion (farion1231#3805) - Remove cache_control passthrough from system messages, text blocks, and tools to prevent 400 errors on strict OpenAI-compatible endpoints - Always simplify single text block content to plain string format - Fixes two format conversion bugs reported in issue farion1231#3805 * fix(proxy): apply cargo fmt to fix CI formatting check
4 tasks
gfunc
pushed a commit
to gfunc/cc-switch
that referenced
this pull request
Jun 19, 2026
…1231#3841) * fix(proxy): strip cache_control from OpenAI format conversion (farion1231#3805) - Remove cache_control passthrough from system messages, text blocks, and tools to prevent 400 errors on strict OpenAI-compatible endpoints - Always simplify single text block content to plain string format - Fixes two format conversion bugs reported in issue farion1231#3805 * fix(proxy): apply cargo fmt to fix CI formatting check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two format conversion bugs in
anthropic_to_openaithat cause 400 errors when routing Anthropic requests to strict OpenAI-compatible endpoints (GLM, Qwen, etc.):Bug 1: cache_control field leaks to OpenAI output
Anthropic's
cache_controlfield (e.g.{"type": "ephemeral"}) was being passed through to OpenAI-format messages, content blocks, and tools. Strict API validators reject unknown fields with400 Extra inputs are not permitted.Fix: Remove
cache_controlpassthrough from:normalize_openai_system_messagesBug 2: Content array not simplified to string for single text blocks
When a message contains a single text block (
[{"type": "text", "text": "Hello"}]), some strict backends expect"content": "Hello"(string) instead of"content": [{"type": "text", "text": "Hello"}](array). The previous code kept array format whencache_controlwas present, which prevented simplification.Fix: Always simplify single text block content to plain string, regardless of
cache_controlpresence.Related Issue
Closes #3805
Test Plan
test_regression_gh3805_no_cache_control_leak_to_openaivalidates:cache_controlin any messagecache_controlin content partssystemcontent is plain stringusercontent is plain stringcache_controlin tools