Support newer Claude Code request fields for Grok#56
Open
hassaans wants to merge 1 commit into
Open
Conversation
Claude Code >= 2.1 sends four request shapes the Grok translator rejects, which makes current Claude Code unusable against the Grok provider: 400 unsupported Grok request field: diagnostics 400 unsupported system block 400 unsupported tool field: eager_input_streaming 400 tool result supports text children only Each is accepted and dropped rather than forwarded, matching how cache_control is already handled (verified, then not sent upstream): - diagnostics: request diagnostics with no Grok equivalent. - cache_control.scope: Claude Code now sends `scope: "global"` alongside type/ttl. valid_cache_control only permitted type/ttl, so any block carrying it failed as "unsupported system block" - the block itself was fine, only the scope key was unrecognised. - eager_input_streaming: a per-tool streaming hint with no Grok equivalent. - tool_reference children inside tool_result: carry no text for the model, so they are skipped while the text children are preserved. Unknown fields are still rejected: an unrecognised cache_control scope, unknown top-level/tool/tool_result keys and non-text tool_result children all continue to fail loudly, and the existing rejection tests are unchanged. Field shapes were taken from a captured Claude Code 2.1.197 request.
Contributor
|
This does fix the issues |
Owner
|
2.1.212 appears to work for me Not sure how to reproduce |
Author
|
Context on the use case, since reproduction came up: this is for running Claude Code's Remote Control (claude.ai / the mobile app) with Grok as the model backend, through claude-code-proxy. The rejected fields come from the Remote Control / claude.ai-driven request path, not from a plain local Happy to attach a full captured request body if it's useful for a regression fixture. |
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.
Claude Code >= 2.1 sends four request shapes the Grok translator rejects. Together they make current Claude Code unusable against the Grok provider — every request from a real session fails with one of:
Approach
Each field is accepted and dropped rather than forwarded, matching how
cache_controlis already handled (verified, then not sent upstream). I deliberately did not loosen the translator into ignoring unknown fields — the fail-loud behaviour is clearly intentional, so unknown fields still bail and every existing rejection test is unchanged.diagnosticscache_control.scopescope: "global"alongsidetype/ttl.valid_cache_controlonly permittedtype/ttl, so any block carrying it failed asunsupported system block— the system block itself was fine, only thescopekey was unrecognised.eager_input_streamingtool_referencechildren intool_resultStill rejected
An unrecognised
cache_controlscope, unknown top-level/tool/tool_resultkeys, and non-texttool_resultchildren all continue to fail loudly. Addedgrok_translation_rejects_unknown_cache_control_scopeto cover the new surface.Verification
cargo test --locked: 592 passing, 0 failures.cargo fmt --checkclean. No new clippy warnings.