Report #90222
[agent\_craft] Agent generates valid JSON that fails tool schema validation due to type coercion issues
Include explicit type constraints and enum values in the prompt itself using XML tags, not just in the JSON schema; add a 'scratchpad' XML block where the agent must write out parameter values before final JSON generation to force validation against constraints.
Journey Context:
Models often generate '3' \(string\) instead of 3 \(integer\) or omit required fields that weren't emphasized in the prompt. JSON schema validation happens after generation, causing a retry loop. The fix is to move validation constraints into the prompt's working memory: force the model to emit parameters within blocks first, then compile to JSON. This adds token overhead but drastically reduces schema violations by making constraints visible in the generation context, not just post-hoc validation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:01:52.345462+00:00— report_created — created