Skip to content

Conversation

@clutchski
Copy link

@clutchski clutchski commented Feb 5, 2026

Summary

  • Move Bedrock Anthropic payload mutations (strip model/stream, inject anthropic_version) into lingua's transform_request -- the router just calls transform_request, gets Bytes back, done
  • Change Bedrock Anthropic models from "format": "converse" to "format": "anthropic" in catalog
  • Use spec.format instead of provider.format() in the router so Bedrock Anthropic models get transformed to Anthropic format
  • Add add_provider_for_format() and add_model_override() on RouterBuilder so Bedrock can serve both Converse and Anthropic format models
  • Add bedrock_messages_event_stream for Bedrock Anthropic streaming (base64-encoded AWS binary event stream)
  • Add invoke_url format-aware routing (/invoke for Anthropic, /converse for Converse)
  • No mutate_payload, no transform_request_to_value, no TransformResultValue

Test plan

  • Unit tests for is_bedrock_anthropic_model detection
  • Unit test verifying mutations applied (model/stream stripped, anthropic_version injected, max_tokens preserved)
  • Unit test verifying non-Bedrock Anthropic models still passthrough
  • Bedrock invoke_url tests (Converse vs Anthropic endpoints)
  • Bedrock Messages event stream base64 decoding tests
  • Router multi-format provider test (OpenAI/Anthropic/Converse through same provider)
  • cargo test passes across full workspace
  • cargo check passes for gateway

🤖 Generated with Claude Code

@clutchski clutchski force-pushed the matt/bedrock-composite branch from bb26d61 to 9f3cf0a Compare February 5, 2026 20:52
@clutchski clutchski requested review from knjiang and remh February 5, 2026 21:03
@clutchski clutchski force-pushed the matt/bedrock-composite branch from e3c34ba to 028bb3b Compare February 6, 2026 21:35
@clutchski clutchski changed the title Make Bedrock a composite provider: Converse + Anthropic Messages API Eliminate double-parse for Bedrock Anthropic payloads Feb 9, 2026
@clutchski clutchski changed the title Eliminate double-parse for Bedrock Anthropic payloads Push Bedrock Anthropic payload mutations into lingua Feb 9, 2026
Add support for routing Bedrock Anthropic models (e.g.
us.anthropic.claude-3-5-sonnet-20241022-v2:0) through the native
Anthropic Messages API instead of the Converse API.

Key changes:
- Catalog: Bedrock Anthropic models now use format "anthropic"
- Lingua: transform_request applies Bedrock mutations (strip model/stream,
  inject anthropic_version) when target is Anthropic and model name
  matches the Bedrock pattern
- Router: use spec.format instead of provider.format() so Bedrock
  Anthropic models get Anthropic-format payloads; add model_overrides
  and add_provider_for_format for multi-format provider routing
- Streaming: add bedrock_messages_event_stream for decoding Bedrock's
  base64-encoded invoke-with-response-stream events
- Bedrock provider: format-aware invoke_url routing (/invoke for
  Anthropic, /converse for Converse)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clutchski clutchski force-pushed the matt/bedrock-composite branch from b4579e5 to 7cfb9cd Compare February 9, 2026 21:56
clutchski and others added 3 commits February 9, 2026 17:07
…ences

- Make is_bedrock_anthropic_model public so the gateway can reuse it for
  Bedrock Anthropic model routing overrides (single shared function).
- Strip whitespace-only stop sequences in apply_bedrock_anthropic_mutations.
  Bedrock's Anthropic Messages API rejects stop sequences like "\n" that
  contain only whitespace. The direct Anthropic API has the same restriction.
  OpenAI accepts them. This is a lossy transformation documented in comments.
- Add tests for whitespace stop sequence filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants