Repository navigation
fix(claude): strip Claude Code's rotating billing line before Responses instructions - #6634
Conversation
…es instructions (#6627)
|
✅ Deterministic PR hygiene checks passed. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (2)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughClaude-to-Responses translation now removes a leading ChangesClaude-to-Responses translation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk is identified; the change is ready for normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change removes request-varying metadata before forwarding instructions. Existing controls keep shared cache keys separate from session identity, and no new privilege or access path was identified. Some security coverage remains incomplete. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Maintainer integration (lidge-jun, dev only) — compatibility-bug sweep 2026-10-05.
|
Summary
Claude Code opens its system prompt with
x-anthropic-billing-header: cc_version=…; cc_entrypoint=…; cch=…;, andcchchanges on every request. When a Claude Code request is translated to a Responses destination (for examplemeta-museor an OpenAI model), that line became the first bytes ofinstructionsand also fed the system-derived fallbackprompt_cache_key, so the prefix and the key rotated every turn and the upstream prompt cache never hit (reporter measured 0.7% cached vs 96.5% for Codex on the same account).systemToInstructionsnow strips that line only at the prompt start: from a string system, or from the first text block of a system array (dropping the block if nothing else is left). The regex is the same start-anchored one the Antigravity adapter already uses (src/adapters/google.ts). Native Anthropic passthrough does not use this translation and keeps the client preamble; the translated Anthropic adapter rebuilds its own identity block and never signs billing text, so no destination depended on the line.Before:
instructions = "x-anthropic-billing-header: …cch=abc;\nYou are Claude Code…"(changes every turn). After:instructions = "You are Claude Code…"and the fallback key is stable across turns. The reporter verified this exact patch: cached tokens went from 0 to ~99% on turns 2–5 on two machines.Closes #6627
Verification
tests/claude-integration/claude-inbound.test.ts: rotatingcchon a string system (instructions and fallback key stable), header-only first array block dropped, header-plus-text block stripped, later mention and leading whitespace preserved, header-only system leaves no instructions and no system-derived key.bun run typecheck,bun run structure:check,bun scripts/file-size-ratchet.ts,bun run privacy:scan— all pass.Checklist
devstructure/clients/claude-desktop.md)Summary by CodeRabbit