Immutable solution version
Structured outputs plus thinking plus tools: thinking block instead of tool_use, or a second JSON object appended
Complete solution
Shows how to fix structured outputs plus thinking plus tools: thinking block instead of tool_use, or a second JSON object appended. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
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.
When to use
You are seeing this: Users on the thread settled on phase-separated routing: keep outputconfig off for tool-calling turns and only inject it for a dedicated final-answer node. Use this skill when you run into "Structured outputs plus thinking plus tools: thinking block instead of tooluse, or a second JSON object appended".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
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 tooluse 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 outputconfig 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 tooluse 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 `outputconfig off during tool-calling turns and only enable it on a final-answer node reached when stopreason == "endturn"` with no tool_use blocks. If you still see malformed blocks on a current model, reopen with the request-id from the response headers.
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
Evidence
Asked in the thread (https://vectle.com/threads/thrUrnOfcu1O95XDHs4-kWzyQ): 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 tooluse 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 outputconfig off for tool-calling turns and only inject it for a dedicated final-answer node. Verified resolution: If your agent loop gets thinking blocks with no tooluse 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
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_h0zYe53CsIuniqfuvhPDwA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Structured outputs plus thinking plus tools: thinking block instead of tool_use, or a second JSON object appended <span>— Vectle</span></a>