Repository navigation
Conversation
The client option selected the beta resource but never reached request construction. Bedrock also needs the flag list in the invocation body.
Sending only the configured flags dropped mcp-client-2025-04-04 from a request with MCP servers, which the API then rejects. Add the default MCP beta unless an mcp-client- flag is already listed. Describe the option in the provider guide and the changelog.
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.
What this does
anthropic_betais an option of the Anthropic and Bedrock providers.AnthropicProvider#api_prompt_executerreads it to chooseclient.beta.messages, but the option is extracted from the provider's kwargs intooptions, so it never reachedcontext, andAnthropic::Requestnever saw it. The result onmain:generate_with :anthropic, anthropic_beta: "context-1m-2025-08-07"called the beta endpoint with noanthropic-betaheader, so the flag did nothing;mcp-client-2025-04-04, whatever was configured;anthropic_beta, and neither the SDK'sBedrockClientnorBedrock::BearerClientmoves it there.The change:
AnthropicProvider#initializecopiesoptions.anthropic_betainto the request context;Anthropic::Requestsplits the option on commas intobetas, and with MCP servers addsmcp-client-2025-04-04unless anmcp-client-flag is already listed (so adding a context beta does not drop the MCP one);BedrockProvider#api_prompt_executemovesbetasintorequest_options: { extra_body: { anthropic_beta: [...] } }, for both the SigV4 and the bearer-token client.The
anthropic_betaline indocs/providers/anthropic.mdnow says what the option takes and where it goes.Tests
test/providers/anthropic/beta_option_test.rb(WebMock, no cassettes):anthropic-betaheader on the Messages API;anthropic_betaarray;mcp-client-2025-04-04, and the default alone when nothing is configured;mcp-client-flag replaces the default (guard; passes before too);preview.The header, Bedrock body, MCP and preview tests fail on
main. The existing Anthropic and Bedrock provider and integration tests (test/providers/anthropic/,test/providers/bedrock/,test/integration/anthropic/) pass.Type of change
Scope check
Related issue
Fixes #750
Quality check
bin/rubocopon the changed files)gemfiles/rails8.gemfile: 4731 runs, 0 failures, 11 errors, 66 skips. The 11 errors are all inactionagent/test/cli_contract_test.rband are the same on unmodifiedmainin my environment (NoMethodError: undefined methodid' for an instance of Hashin rack-session under WebMock'sto_rack`), so they are unrelated to this change)docs/providers/anthropic.md, CHANGELOG entry)Ownership
API changes
Not verified against the live APIs: the tests check the outgoing HTTP request only. The Bedrock body field follows AWS's Anthropic Claude Messages API reference (
anthropic_betain the InvokeModel body).