Validate your agent's JSON output before acting on it
=========================================================
const { validate } = require("./validate-output");
const result = validate(modelRawText, { action: "string", amount: "number" });
if (!result.ok) { /* handle result.error -- ask again, log, or fall back */ }

Catches: malformed JSON, missing fields, wrong field types. See demo.js for all 4 real cases.
