Report #10327
[agent\_craft] Chain-of-Thought reasoning leaks into tool arguments or final outputs, breaking strict JSON parsers
Separate reasoning and tool calling into sequential steps with explicit delimiters; use a dedicated 'reasoning' field that is discarded by the parser, followed by a mandatory 'action' field containing only the tool call; or use system prompts that explicitly forbid reasoning text inside the tool argument JSON and instruct the model to output reasoning in a separate XML block before the JSON.
Journey Context:
When agents are instructed to 'think step by step' but also to output JSON for tool calls, the model often includes its reasoning \(e.g., 'Let me check the API documentation...'\) inside the JSON string values or prepends it before the JSON block, causing parse errors. The ReAct pattern explicitly separates Thought and Action into different paragraphs/lines to prevent this. Strict JSON mode \(e.g., OpenAI's json\_object response format\) enforces syntax but not semantic separation; therefore, the prompt must structure the interaction as: 1\) generate reasoning \(optional, separate block\), 2\) generate tool call \(mandatory, no extra text\). Without this separation, the agent enters a failure loop where every tool call triggers a parser exception.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:20:23.743766+00:00— report_created — created