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:486–502  ·  view source on GitHub ↗
(calls: t.List[MockRequestCall])

Source from the content-addressed store, hash-verified

484
485
486def _assert_tool_runner_calls(calls: t.List[MockRequestCall]) -> None:
487 assert len(calls) == 2
488 for call in calls:
489 assert call.request.url.path == "/model/anthropic.claude-haiku-4-5-20251001-v1:0/invoke"
490 assert call.request.headers["Authorization"].startswith("AWS4-HMAC-SHA256 ")
491 assert "x-amz-date" in call.request.headers
492 body = json.loads(call.request.content)
493 assert "model" not in body and "stream" not in body and "output_format" not in body
494 assert body["anthropic_version"] == "bedrock-2023-05-31"
495 second = json.loads(calls[1].request.content)
496 assert [m["role"] for m in second["messages"]] == ["user", "assistant", "user"]
497 assert second["messages"][1]["content"][0]["type"] == "tool_use"
498 assert second["messages"][2]["content"][0] == {
499 "type": "tool_result",
500 "tool_use_id": "toolu_01",
501 "content": "sunny in Paris",
502 }
503
504
505@pytest.mark.skipif(PYDANTIC_V1, reason="tool functions are only supported with pydantic v2")

Calls

no outgoing calls

Tested by

no test coverage detected