Drive a tool runner over ``messages`` and collect the tool_result messages it generated.
(
client: Anthropic,
*,
tools: List[Any],
messages: List[BetaMessageParam],
)
| 1021 | |
| 1022 | |
| 1023 | def _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") |
no test coverage detected