Report #75728
[agent\_craft] Parser confuses natural language reasoning with tool calls, or generates hallucinated tool calls inside markdown code blocks
Enforce strict delimiter patterns \(e.g., XML tags like \`\` or JSON blobs with specific prefixes\) and instruct the model in the system prompt to never place tool calls inside markdown code fences or explanatory text; parse using regex/grammar strictly before LLM text processing
Journey Context:
Naive implementations often use natural language like 'I will now call the search tool' followed by JSON. This causes the LLM to sometimes output the JSON inside a markdown block \(\`\`\`json\) which breaks the parser, or to hallucinate tool calls within prose. The fix is anthropomorphic separation: treat tool calls as 'control plane' and text as 'data plane.' The Model Context Protocol \(MCP\) and Anthropic's tool use specification both mandate XML or strict JSON schemas outside of markdown blocks. The parser must extract these blocks using strict grammar \(e.g., PEG parsers\) before the text is passed to downstream logic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:42:35.326541+00:00— report_created — created