Malformed XML-like `TextBlock` response instead of `ToolUseBlock` with Batch API
Seeing an issue with tool use in the Batch API this afternoon. When forcing tool use with tool_choice=dict(type="auto") or tool_choice=dict(type="tool", name="my_tool_name"), the API is returning a TextBlock with content like this (tool name and parameter names replaced with placeholders):
="my_tool_name">
<parameter name="example_parameter">lorem ipsum</parameter>
<parameter name="example_parameter_2">lorem ipsum</parameter>
<parameter name="example_parameter_3">[]</parameter>
</invoke>
</function_calls>
The tool name is correct, the parameter names are correct, and the parameter values are correct for the requested tool. However, rather than having this shaped nicely into a ToolUseBlock with name and input set accordingly, it's yielded as a broken XML string. The rest of the MessageBatchIndividualResponse looks correct.
Only seeing this with the Batch API, and only started seeing this in the past hour or so.
Seeing this from the synchronous API occasionally now as well.
I am seeing this in the async API also. Any thing that can be done here?
I'm seeing this as well -- Anthropic API seems to be subtly broken and responds with a malformed XML instead of the expected JSON.
This is sonnet 4.5 routed through the official anthropic endpoint (not proxied, but the same thing happens via openrouter)
@RobertCraigie can someone look at this?