DEV Community

Patrick
Patrick

Posted on

The Pre-Execution Check: The One Habit That Makes AI Agents Safe to Run Unsupervised

Most people trust their AI agents by default. That's backwards.

The agents I trust most aren't the ones with the smartest models — they're the ones with pre-execution checks baked into their config.

What's a Pre-Execution Check?

It's a gate your agent runs before taking any significant action. A quick self-audit:

  • Is this task within my defined scope?
  • Do I have the information I need to do this correctly?
  • Could this action cause harm that can't be undone?
  • Is there anything in outbox.json I should know about first?

If any answer is uncertain, the agent stops and escalates instead of guessing.

Why This Matters

Without a pre-execution check, agents make decisions at the edge of their competence — and they don't know that's what they're doing.

The model doesn't flag "I'm not sure about this." It just does its best. And its best, in an edge case, might be confidently wrong.

The Pattern

Add this to your SOUL.md:

Before executing any task that modifies external state or sends communications:
1. Confirm task is within defined scope
2. Confirm required context is loaded and current
3. Check outbox.json for pending escalations
4. If any check fails: write reasoning to outbox.json and stop
Enter fullscreen mode Exit fullscreen mode

It adds ~2 seconds per major action. It prevents compounding failures.

Real-World Example

One of our agents sends a weekly newsletter. Without the check, it once sent a draft with a placeholder still in it — because the task was "send newsletter" and it had a file that looked like a newsletter.

With the pre-execution check, it would have caught that the file contained [INSERT_STAT_HERE] and escalated before sending.

One check. One habit. Prevents the category of failure that's hardest to recover from.

The Safety Stack

Pre-execution checks work best as part of a reliability stack:

  1. Pre-execution check — before acting
  2. Escalation rule — when uncertain, write to outbox.json
  3. Circuit breaker — after N failures, stop and surface
  4. Dead letter queue — log what failed and why

Each layer catches what the previous one misses.

The full patterns — including templates for each — are in the Ask Patrick Library: askpatrick.co


Ask Patrick publishes battle-tested AI agent configs and patterns updated nightly. The Library is the shortcut to building agents you can actually trust.

Top comments (0)