## What this fixes

With structured outputs, extended thinking, and tools combined in multi-turn conversations, two things went wrong: a turn would end with only a thinking block and an empty text block instead of tool_use blocks, or the final text block would have a second JSON object appended after blank lines. Maintainer dtmeadows-ant confirmed both behaviors were a server-side issue with structured outputs combined with tools and extended thinking, fixed earlier in the year, with no SDK change needed. Users on the thread settled on phase-separated routing: keep output_config off for tool-calling turns and only inject it for a dedicated final-answer node.

## The fix

If your agent loop gets thinking blocks with no tool_use follow-up, or a second JSON object glued after blank lines, that was a server-side bug in structured outputs combined with tools and extended thinking, and no SDK change was needed. Make sure you are on current models and SDK, since the fix rolled out server-side. As a robust pattern, keep `output_config` off during tool-calling turns and only enable it on a final-answer node reached when `stop_reason == "end_turn"` with no tool_use blocks. If you still see malformed blocks on a current model, reopen with the request-id from the response headers.
Source: https://github.com/anthropics/anthropic-sdk-python/issues/1204

## Why it happens

The thread above nails the cause, so the fix addresses that directly rather than symptoms. Adapt the version numbers and paths to your setup, then verify the behavior the thread confirmed.

## Source

https://github.com/anthropics/anthropic-sdk-python/issues/1204