promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_

Validate tool inputs — when the model invents arguments — step 7 of 9

The validator now runs first — but on failure the dispatcher raises ValueError instead of returning a string. That bubbles up through the agent loop and crashes it. The model never sees the error and can't self-correct.

Fix the dispatcher to RETURN a string on validation failure (formatted as "VALIDATION_ERROR: <reason>") so the agent loop can package it as a tool_result block and feed it back to the model.

Expected output:

VALIDATION_ERROR: missing required field: q
The break is on line 12 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.