| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Apply `_strip_nonsemantic_system_lines()` in the Anthropic->OpenAI Chat request converter so the per-request `x-anthropic-billing-header` (with the regenerating `cch=<hash>`) does not defeat upstream prompt caching on the chat-completions path. Mirrors the fix landed for the Responses API converter in #62. If the cleaned system content is empty, the system message is dropped entirely instead of injecting an empty system role. Adds 5 chat-converter tests mirroring the Responses-API coverage: string-system stripping, block-system stripping, case-insensitive matching, header-only-system drops the message, and cross-request stability when only the `cch=` hash differs.
There was a problem hiding this comment.
This PR ensures Anthropic→OpenAI chat-completions requests don’t forward the per-request x-anthropic-billing-header: ... cch=<hash> prefix in system content, preventing prompt instability and cache defeats (matching the already-fixed Responses API behavior).
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ccproxy/llms/formatters/anthropic_to_openai/requests.py | Strips non-semantic billing header lines from chat system content and avoids emitting empty system messages. |
| tests/unit/llms/formatters/test_anthropic_to_openai_helpers.py | Adds targeted tests validating correct stripping and stability for the chat converter path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Follow-up to #62 addressing this Copilot review comment: _strip_nonsemantic_system_lines() was only applied to the Responses API path. convert__anthropic_message_to_openai_chat__request() still forwarded request.system verbatim, so Anthropic->OpenAI Chat requests continued to carry the per-request unique x-anthropic-billing-header: ...; cch=<hash>; prefix and could still defeat caching/prompt stability for the chat-completions endpoint.
Changes
ccproxy/llms/formatters/anthropic_to_openai/requests.py
Apply _strip_nonsemantic_system_lines() to both the str and list[TextBlock] system paths in the chat converter, mirroring the Responses-API path. If the cleaned content is empty, the system message is dropped entirely instead of injecting an empty system role.
Tests
Added 5 chat-converter tests in tests/unit/llms/formatters/test_anthropic_to_openai_helpers.py mirroring the Responses-API coverage:
Test plan