MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / _assert_tool_runner_calls

Function _assert_tool_runner_calls

tests/lib/test_bedrock.py:466–482  ·  view source on GitHub ↗
(calls: t.List[MockRequestCall])

Source from the content-addressed store, hash-verified

464
465
466def _assert_tool_runner_calls(calls: t.List[MockRequestCall]) -> None:
467 assert len(calls) == 2
468 for call in calls:
469 assert call.request.url.path == "/model/anthropic.claude-haiku-4-5-20251001-v1:0/invoke"
470 assert call.request.headers["Authorization"].startswith("AWS4-HMAC-SHA256 ")
471 assert "x-amz-date" in call.request.headers
472 body = json.loads(call.request.content)
473 assert "model" not in body and "stream" not in body and "output_format" not in body
474 assert body["anthropic_version"] == "bedrock-2023-05-31"
475 second = json.loads(calls[1].request.content)
476 assert [m["role"] for m in second["messages"]] == ["user", "assistant", "user"]
477 assert second["messages"][1]["content"][0]["type"] == "tool_use"
478 assert second["messages"][2]["content"][0] == {
479 "type": "tool_result",
480 "tool_use_id": "toolu_01",
481 "content": "sunny in Paris",
482 }
483
484
485@pytest.mark.skipif(PYDANTIC_V1, reason="tool functions are only supported with pydantic v2")

Calls

no outgoing calls

Tested by

no test coverage detected