Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

* `ChatBedrock()`'s default model (previously `"us.anthropic.claude-sonnet-4-6"`) is now `"us.anthropic.claude-sonnet-5"`, which mantle's `api="messages"` endpoint actually serves. Separately, the cross-region inference prefix (e.g. `"us."`) is now stripped from the model id sent in requests to `api="messages"` and `api="responses"`, since mantle rejects it even though Converse requires it. Previously, a mantle-only model with a cross-region prefix (e.g. `model="us.openai.gpt-5.4"`) would 404. (#411)
* `.to_solver()` no longer corrupts the system prompt or the prior turns it reads out of Inspect AI's message state. The system prompt was being set to the `repr()` of the `ChatMessageSystem` object rather than its text, and message content arriving in Inspect AI's `str` form (rather than as a list of `Content`) was iterated one character at a time. (#407)
* `ChatGoogle()` no longer raises `ValueError: Unknown content type: ContentThinking` on the second and later turns when `reasoning` is enabled; thinking content is now replayed to the model as thought parts, and the `thought_signature` on thought parts is preserved (previously only tool-call parts kept it). (#403)
* `ChatOllama()` now distinguishes a remote endpoint it can't reach from a genuinely missing local install, and validates a supplied `model` against `/api/tags` at construction time instead of only when `model` is omitted. (#393)
Expand Down
25 changes: 21 additions & 4 deletions chatlas/_provider_bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

BedrockAPI = Literal["converse", "messages", "responses"]

DEFAULT_MODEL = "us.anthropic.claude-sonnet-4-6"
DEFAULT_MODEL = "us.anthropic.claude-sonnet-5"

MANTLE_HOST = "https://bedrock-mantle.{region}.api.aws"

Expand Down Expand Up @@ -98,7 +98,7 @@ def ChatBedrock(
A system prompt to set the behavior of the assistant.
model
The model to use for the chat. Defaults to
`"us.anthropic.claude-sonnet-4-6"`.
`"us.anthropic.claude-sonnet-5"`.
api
Which Bedrock API to use. The default, `None`, picks the API from
`model`.
Expand Down Expand Up @@ -183,7 +183,9 @@ def ChatBedrock(
)
return Chat(
provider=BedrockResponsesProvider(
model=model,
# Converse needs the cross-region inference prefix, but mantle
# rejects it on the model id in the request.
model=bedrock_strip_region_prefix(model),
aws_profile=aws_profile,
aws_region=region,
base_url=base_url,
Expand Down Expand Up @@ -215,7 +217,9 @@ def ChatBedrock(

return Chat(
provider=BedrockMessagesProvider(
model=model,
# Converse needs the cross-region inference prefix, but mantle
# rejects it on the model id in the request.
model=bedrock_strip_region_prefix(model),
aws_profile=aws_profile,
aws_region=region,
base_url=base_url,
Expand Down Expand Up @@ -457,6 +461,19 @@ def bedrock_api_for_model(model: Optional[str]) -> BedrockAPI:
return MODEL_APIS.get(CROSS_REGION_PREFIX.sub("", model), "converse")


def bedrock_strip_region_prefix(model: str) -> str:
"""
Strip a cross-region inference prefix (e.g. `"us."`) from `model`.

Converse needs the prefix on the model id it's sent, since that's how it
picks the inference profile. Mantle's Anthropic and OpenAI-compatible
endpoints have no such concept and 404 if the prefix is included, so it
must be stripped from the model id used in requests to `"messages"` and
`"responses"`.
"""
return CROSS_REGION_PREFIX.sub("", model)


def aws_endpoint_url(var: str, default: str) -> str:
"""An AWS service endpoint override env var, or `default` when unset."""
url = os.environ.get(var, "")
Expand Down
Loading