Honor the agent tool choice with Anthropic native structured output

Merged
SU
3d ago
+25-1

a structured agent with tools always sends tool_choice: auto to Anthropic because the native output_config path hard codes it
so ToolChoice::required ToolChoice::tool() and ToolChoice::none set on the agent never reach the API
OpenAI and Gemini already pass the tool choice through alongside structured output and the Anthropic fallback path does too since #780

this sends it through the same resolveToolChoice() the fallback path uses so the thinking guard behaves the same
agents without a tool choice still send auto

checked live with a structured agent and one tool
on claude-haiku-4-5-20251001 with ToolChoice::none it sent auto and the model called the tool anyway
with this change it sends none and answers without calling it (same on claude-sonnet-5-5)
required now sends any on the first step and auto after so the tool runs and the structured answer still comes back

heads up
models that reject a forced tool choice like claude-sonnet-5-5 will now return the API's 400 for required on a structured agent the same way they already do for agents without a schema