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

Function _run_sync_tool_use

tests/lib/tools/test_runners.py:1023–1042  ·  view source on GitHub ↗

Drive a tool runner over ``messages`` and collect the tool_result messages it generated.

(
    client: Anthropic,
    *,
    tools: List[Any],
    messages: List[BetaMessageParam],
)

Source from the content-addressed store, hash-verified

1021
1022
1023def _run_sync_tool_use(
1024 client: Anthropic,
1025 *,
1026 tools: List[Any],
1027 messages: List[BetaMessageParam],
1028) -> List[BetaMessageParam]:
1029 """Drive a tool runner over ``messages`` and collect the tool_result
1030 messages it generated."""
1031 runner = client.beta.messages.tool_runner(
1032 max_tokens=1024,
1033 model="claude-haiku-4-5",
1034 tools=tools,
1035 messages=messages,
1036 )
1037 responses: List[BetaMessageParam] = []
1038 for _ in runner:
1039 response = runner.generate_tool_call_response()
1040 if response is not None:
1041 responses.append(response)
1042 return responses
1043
1044
1045@pytest.mark.skipif(PYDANTIC_V1, reason="tool runner not supported with pydantic v1")

Calls 2

tool_runnerMethod · 0.45

Tested by

no test coverage detected