Repository navigation
Conversation
…g, messages config dispatch
|
Ishaan Jaffer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR adds support for the Confidence Score: 5/5Safe to merge — all remaining findings are P2 style/maintenance suggestions with no impact on runtime correctness. Route dispatch, URL construction, model-prefix stripping, SigV4 auth, and response flow are all correct. No P0/P1 issues found. No files require special attention, though the duplicated MANTLE_ENDPOINT_TEMPLATE across chat and messages transformation files is worth cleaning up.
|
| Filename | Overview |
|---|---|
| litellm/llms/bedrock/chat/mantle/transformation.py | Adds AmazonMantleConfig for /chat/completions; correctly overrides URL construction and strips the "mantle/" prefix before placing model ID in the body. MANTLE_ENDPOINT_TEMPLATE is duplicated from the messages sibling file. |
| litellm/llms/bedrock/messages/mantle_transformation.py | Adds AmazonMantleMessagesConfig for /messages; delegates to parent and re-injects model in the body after the parent strips it. Logic is correct; shares the duplicated MANTLE_ENDPOINT_TEMPLATE constant. |
| litellm/llms/bedrock/common_utils.py | Route dispatch for mantle added in get_bedrock_route, get_bedrock_chat_config, and get_bedrock_provider_config_for_messages_api. Consistent with existing explicit routes; minor concern with substring vs prefix check in _explicit_mantle_route. |
| tests/llm_translation/test_bedrock_mantle.py | E2E mocked tests verify URL, model body, and SigV4 header. Broad except Exception: pass around the completion call can mask response-parsing regressions. |
| tests/test_litellm/llms/bedrock/test_mantle.py | Unit tests cover route detection, URL construction, config dispatch, and prefix stripping for both /chat/completions and /messages. Solid coverage with no real network calls. |
| model_prices_and_context_window.json | Adds anthropic.claude-mythos-preview with 1M context, 128K output, zero cost (TBD), and correct capability flags. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["litellm.completion(model='bedrock/mantle/...')"] --> B["BedrockModelInfo.get_bedrock_route()"]
B -->|"'mantle/' in model"| C["route = 'mantle'"]
C --> D["get_bedrock_chat_config()"]
D --> E["AmazonMantleConfig"]
E --> F["get_complete_url()\n→ bedrock-mantle.{region}.api.aws/v1/messages"]
E --> G["transform_request()\n→ strip 'mantle/' prefix\n→ add model to body"]
G --> H["AWS SigV4 signing\nservice=bedrock"]
H --> I["POST bedrock-mantle.{region}.api.aws/v1/messages"]
J["litellm.anthropic_messages(model='bedrock/mantle/...')"] --> K["BedrockModelInfo.get_bedrock_provider_config_for_messages_api()"]
K -->|"_explicit_mantle_route(model)"| L["AmazonMantleMessagesConfig"]
L --> M["get_complete_url()\n→ same endpoint"]
L --> N["transform_anthropic_messages_request()\n→ strip prefix, inject model in body"]
N --> H
Reviews (1): Last reviewed commit: "add e2e tests for bedrock mantle: URL, b..." | Re-trigger Greptile
| else: | ||
| LiteLLMLoggingObj = Any | ||
|
|
||
| MANTLE_ENDPOINT_TEMPLATE = "https://bedrock-mantle.{region}.api.aws/v1/messages" |
There was a problem hiding this comment.
MANTLE_ENDPOINT_TEMPLATE is defined identically in both chat/mantle/transformation.py (line 24) and messages/mantle_transformation.py (line 23). If the mantle endpoint URL changes, both files must be updated in sync. Consider extracting it to common_utils.py or a shared mantle_utils.py and importing it in both places.
# common_utils.py (or a new mantle_utils.py)
MANTLE_ENDPOINT_TEMPLATE = "https://bedrock-mantle.{region}.api.aws/v1/messages"| ) | ||
| except Exception: | ||
| pass # response parsing may fail on mock; we only care about the outgoing call |
There was a problem hiding this comment.
Broad exception swallow can hide response-parsing regressions
All three tests swallow every exception from litellm.completion() with except Exception: pass, and then make assertions solely about the outgoing HTTP call. If the mantle config's response-parsing breaks (e.g., the parent AmazonAnthropicClaudeConfig unwraps a Bedrock-Invoke-style envelope that the raw Anthropic response doesn't have), the exception would be silently discarded and the test would still green. Consider either:
- Asserting the return value of
litellm.completion()is a validModelResponse, or - Narrowing the
exceptto known mock-induced errors and re-raising anything unexpected.
| """ | ||
| Check if the model is an explicit mantle route (bedrock-mantle endpoint). | ||
| """ | ||
| return "mantle/" in model |
There was a problem hiding this comment.
Substring match instead of prefix check for mantle route
_explicit_mantle_route uses "mantle/" in model, consistent with other _explicit_*_route helpers, but this matches anywhere in the string. A hypothetical model name such as "us.dismantled/foo" would incorrectly be treated as a mantle route. Using model.startswith("mantle/") (or checking the segment after the provider prefix) would be more precise.
|
Refiled as #26196 targeting main instead of litellm_internal_staging. |
Relevant issues
Adds support for the new AWS Bedrock
bedrock-mantleendpoint, which serves Claude Mythos Preview (anthropic.claude-mythos-preview) using the Anthropic Messages API format.Changes
Usage:
The
bedrock-mantleendpoint differs from standard Bedrock in two ways:https://bedrock-mantle.{region}.api.aws/v1/messagesmodelgoes in the request body rather than the URLRoute pattern:
bedrock/mantle/<model-id>— consistent with existing explicit routes (bedrock/converse/...,bedrock/agentcore/...).Auth: AWS SigV4 with service=
bedrock, same as other Bedrock models.Files:
model_prices_and_context_window.json— addsanthropic.claude-mythos-preview(1M context, 128K output, supports reasoning + vision; pricing TBD)litellm/llms/bedrock/common_utils.py— adds"mantle"route,_explicit_mantle_route()helper, dispatch inget_bedrock_chat_config()andget_bedrock_provider_config_for_messages_api()litellm/llms/bedrock/chat/mantle/transformation.py—AmazonMantleConfigfor/chat/completionslitellm/llms/bedrock/messages/mantle_transformation.py—AmazonMantleMessagesConfigfor/messages(inheritsAmazonAnthropicClaudeMessagesConfig)litellm/__init__.py+litellm/_lazy_imports_registry.py— registrationQA results (fake mantle endpoint)
Intercepted outgoing HTTP calls to verify full request/response pipeline for both endpoints.
/chat/completionsRequest:
Response (OpenAI format):
{ "id": "chatcmpl-...", "object": "chat.completion", "model": "anthropic.claude-mythos-preview", "choices": [{ "finish_reason": "stop", "index": 0, "message": { "role": "assistant", "content": "Hello! I am Claude Mythos Preview running via bedrock-mantle." } }], "usage": {"prompt_tokens": 12, "completion_tokens": 15, "total_tokens": 27} }/messagesRequest:
Response (Anthropic format):
{ "id": "msg_fake456", "type": "message", "role": "assistant", "model": "anthropic.claude-mythos-preview", "content": [{"type": "text", "text": "Hello! I am Claude Mythos Preview running via bedrock-mantle."}], "stop_reason": "end_turn", "usage": {"input_tokens": 12, "output_tokens": 15, "total_tokens": 27} }Test results (12/12 passed):
Pre-Submission checklist
tests/test_litellm/(unit) andtests/llm_translation/(e2e with mocked HTTP)make test-unitpasses for new testsType
CI