Repository navigation
Conversation
…opic::Request Move message partitioning, assistant/reasoning/file/tool conversion and the Messages API body assembly out of the Anthropic provider into a transport-independent builder that returns the body without a model, so a transport that carries the model in the URL can reuse it. The provider prepends the model, producing the same hash in the same key order; the recorded cassettes still match. REASONING_FORMAT moves to Riffer::Wire::Anthropic and the provider constant aliases it. The two provider tests that called the moved private converters now go through build_request_params. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Riffer::Wire::Anthropic::Response reads a raw Messages API response hash into content, tool calls, reasoning parts, token usage and finish reason. Riffer::Wire::Anthropic::Stream turns raw stream event hashes into riffer stream events (text, reasoning, tool calls, web search), accumulates the final message, and raises IncompleteStreamError from finish! when message_stop never arrived. Both mirror what the Anthropic provider extracts from SDK objects; replaying every recorded Anthropic cassette through both paths yields identical results. Streamed tool call deltas carry the real id and name, which the SDK path does not know until the block ends. FINISH_REASONS and the tool-name encoding move to Riffer::Wire::Anthropic so the request builder, these parsers and the provider share them. The Anthropic provider itself keeps reading SDK objects for now. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
google_cloud/claude-* models route to Vertex AI's Anthropic endpoint: rawPredict and streamRawPredict under publishers/anthropic, with the Messages body from Riffer::Wire::Anthropic::Request minus the model plus anthropic_version "vertex-2023-10-16". Responses and SSE streams are parsed by Riffer::Wire::Anthropic::Response and ::Stream, so a stream that ends without message_stop raises IncompleteStreamError as the Anthropic provider does. Claude models get the XML skills adapter; everything else keeps the Gemini path. The VCR tests await cassettes; Claude is not yet enabled on the recording project. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Describe the claude-* routing, the rawPredict body (anthropic_version in place of the model), and the behaviour shared with the Anthropic provider: reasoning replay, web search, structured output, user_id metadata and IncompleteStreamError. List Claude in the provider overview and the tag mapping table. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
This branch has not been deployed
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.
Stacked on #482. Adds Claude models on Vertex AI to the
google_cloudprovider, and a sharedRiffer::Wire::Anthropiclibrary for building Anthropic requests and parsing responses without the anthropic gem.Why our own transport
Anthropic::VertexClientonly picks up ambient Application Default Credentials and has no way to pass in credentials, so it can't use the fiber-safe token refresh from #482. Claude requests go through the sameGoogleCloud::Clientas Gemini instead.Routing
Model ids starting with
claude-go topublishers/anthropic/models/{model}:rawPredictand:streamRawPredict, using the Anthropic Messages body plusanthropic_version: "vertex-2023-10-16". Every other model id goes to Gemini. Model ids may contain@(e.g.claude-haiku-4-5@20251001).Riffer::Wire::AnthropicNone of these classes depend on the google_cloud provider, so they can be reused if we replace the anthropic gem:
Request: the hash-building code moved out of the Anthropic provider, which now calls it. Existing Anthropic cassettes pass unchanged.Response/Stream: parse raw JSON and SSE events into riffer messages and stream events.StreamraisesIncompleteStreamErrorwhen there's nomessage_stop. Replaying all the existing Anthropic cassettes through these classes gives the same results as the SDK path (19 streams, 31 responses).Response/Streamis a follow-up.Other changes
Client#handle_api_error!handlesstreamRawPredicterrors, which come back wrapped in a JSON array."pending"andnil.Tests
Cassettes are recorded against
claude-haiku-5-5: generate, stream, tool calling (generate and stream), and reasoning replay with adaptive thinking.Commented out: the structured output and web search tests. Our org policy
constraints/vertexai.allowedPartnerModelFeaturesblocks those features on the recording project. They need an org-policy admin to allowpublishers/anthropic/models/claude-haiku-5-5:structured_outputsand:web_search, then the cassettes can be recorded.Commits
Riffer::Wire::Anthropic::RequestRiffer::Wire::Anthropicresponse and stream parsers🤖 Generated with Claude Code