Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,9 @@ def _supports_tool_search_on_bedrock(self, model: str) -> bool:
"""
Check if the model supports tool search on Bedrock.

On Amazon Bedrock, server-side tool search is supported on Claude Opus 4.5
and Claude Sonnet 4.5 with the tool-search-tool-2025-10-19 beta header.
On Amazon Bedrock, server-side tool search is supported on Claude
Opus 4.5/4.6/4.7, Sonnet 4.5/4.6, and Haiku 4.5 with the
tool-search-tool-2025-10-19 beta header.

Ref: https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool

Expand Down Expand Up @@ -407,10 +408,17 @@ def _supports_tool_search_on_bedrock(self, model: str) -> bool:
"sonnet_4.6",
"sonnet-4-6",
"sonnet_4_6",
# NOTE: Opus 4.7 on Bedrock does not support server-side tool search
# as of launch (2026-04-16). Bedrock rejects the tool type with:
# "tool type 'tool_search_tool_..._20251119' is not supported for this model".
# Re-add the opus-4.7 patterns here once AWS announces support.
# Opus 4.7 (unsupported at its 2026-04-16 launch; verified live
# 2026-08-11 that Bedrock now accepts the beta on it)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
"opus-4.7",
"opus_4.7",
"opus-4-7",
"opus_4_7",
# Haiku 4.5
"haiku-4.5",
"haiku_4.5",
"haiku-4-5",
"haiku_4_5",
]

return any(pattern in model_lower for pattern in supported_patterns)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
Expand All @@ -426,11 +434,10 @@ def _get_tool_search_beta_header_for_bedrock(
"""
Adjust tool search beta header for Bedrock.

Bedrock requires a different beta header for tool search on Opus 4 models
when tool search is used without programmatic tool calling or input examples.

Note: On Amazon Bedrock, server-side tool search is only supported on Claude Opus 4
with the `tool-search-tool-2025-10-19` beta header.
Bedrock requires a different beta header for tool search than the
Anthropic API when tool search is used without programmatic tool
calling or input examples: `tool-search-tool-2025-10-19`, and only on
the models listed in `_supports_tool_search_on_bedrock`.

Ref: https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool

Expand Down
4 changes: 0 additions & 4 deletions tests/e2e/claude_code/tool_search/test_bedrock_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@
]


@pytest.mark.skip(
reason="product bug LIT-4522: Bedrock Invoke /v1/messages does not normalize "
"tool_search_tool_regex_20251119; re-enable when messages path matches chat path"
)
@pytest.mark.covers("llm.messages.bedrock_invoke.tool_search.nonstream.works")
def test_tool_search_bedrock_invoke(compat_result):
"""Probe `/v1/messages` with a `tool_search_tool_regex_20251119`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,55 @@ def test_filter_and_transform_beta_headers_passes_context_management_for_bedrock
assert out_converse == []


@pytest.mark.parametrize(
"model",
[
"us.anthropic.claude-haiku-4-5-20251001-v1:0",
"us.anthropic.claude-sonnet-4-5-20250929-v1:0",
"us.anthropic.claude-opus-4-7",
],
)
def test_bedrock_messages_tool_search_adds_beta_header(local_beta_headers_config, model):
"""
LIT-4522: Bedrock InvokeModel only admits ``tool_search_tool_*`` tool types
when the request body carries the ``tool-search-tool-2025-10-19`` beta;
without it Bedrock 400s with "Input tag 'tool_search_tool_regex_20251119'
... does not match any of the expected tags". The allowlist in
``_supports_tool_search_on_bedrock`` previously omitted Haiku 4.5 and
Opus 4.7, so the beta was silently dropped for those models and every
tool-search request failed. Verified live 2026-08-11: Bedrock returns 200
with ``server_tool_use`` for all three models once the beta is sent.
"""
from litellm.types.router import GenericLiteLLMParams

cfg = AmazonAnthropicClaudeMessagesConfig()
messages = [{"role": "user", "content": [{"type": "text", "text": "Hi"}]}]
optional_params = {
"max_tokens": 64,
"tools": [
{"type": "tool_search_tool_regex_20251119", "name": "tool_search_tool_regex"},
{
"name": "add_numbers",
"description": "Add two integers",
"input_schema": {
"type": "object",
"properties": {"a": {"type": "integer"}, "b": {"type": "integer"}},
"required": ["a", "b"],
},
},
],
}

result = cfg.transform_anthropic_messages_request(
model=model,
messages=messages,
anthropic_messages_optional_request_params=optional_params,
litellm_params=GenericLiteLLMParams(),
headers={},
)

assert "tool-search-tool-2025-10-19" in (result.get("anthropic_beta") or [])


def test_bedrock_messages_thinking_shape_follows_exact_bedrock_entry_flag(
local_model_cost_map, monkeypatch
Expand Down
Loading