Part 8 of 13 · 1 min read
How to build it so it holds up
- Define a strict schema for every tool, and reject rather than coerce (no
"50"to 50, no bool as int, no NaN or infinity, no unknown keys). - Use full-match patterns with ASCII-only classes (beware of
$matching before a trailing newline and Unicode digits). - Add semantic checks against current state: ownership, totals, existence, cumulative limits.
- Authorise separately (module 2): validation does not decide who may do what.
- Guard outputs for secrets and external links, and render untrusted output without images or auto-loading links.
- Fail closed for security decisions; alert on guard errors.
- Prefer structural controls (allowlisted egress, typed tool results) over text matching.
- Re-ask or repair carefully: limit retries, and never let the model's repair text bypass the validator (it must pass again).
- Test guards with evasions, not only the attacks they were written for, and keep them in the CI gate (Level 9 module 7).
- Log guard decisions with the trace (Level 9 module 8).