Agentic Pattern Libraryby Vikas Goyal
← All patterns
37

Metacognitive Monitor

Also known as: surprise detector, agent watchdog, run-time monitor

A lightweight watcher spots surprises and switches the agent into System 2 mode.

TrackAgentic systems FamilyFast & slow Maturity Horizon ChangesVerification
01

Problem

An agent running in fast mode doesn’t notice when things stop making sense. Tool results contradict each other, the same step repeats, or the plan quietly stops fitting the facts, and the agent keeps going with confidence. By the time the final output is checked, the run has wasted time or taken wrong actions.

  • Most runs are routine and need no deep thinking.
  • Trouble shows up mid-run, in signals a final check sees too late.
  • The agent is a poor judge of its own confusion.
  • A watcher that interrupts too often slows everything down.
02

Solution

Run a separate, cheap monitor alongside the agent that reads its trace after every step. The monitor looks for specific surprise signals: a tool result that contradicts an earlier one, a repeated action, an unexpected error, output that breaks a known rule, or progress stalling against the plan. When a signal fires, the monitor pauses the fast loop and hands the current state to System 2 to diagnose it, replan or escalate to a human. The monitor itself uses rules and a small model, never the expensive one.

03

Diagram

Task Fast agent loopSystem 1 · steps Trace Result Monitorrules + small model System 2diagnose · replan · escalate each step no surprises reads signal pause new plan · resume

The monitor watches the trace, not the final answer. It catches trouble mid-run and is cheap enough to run on every step.

04

When to use

Use it when

  • Long-running or multi-step agents where mid-run errors compound
  • Agents that take real actions in other systems
  • You can name concrete warning signs from past failures
  • Fast mode is right most of the time but fails in recognizable ways

Avoid it when

  • Short, single-call tasks; check the output instead
  • You can't define surprise signals, so the monitor just guesses
  • Every step already runs on a reasoning model
05

Trade-offs

Latency Cheap per-step check; slow path only on alerts
Cost Rules and a small model; System 2 on demand
Complexity Trace access, signals and pause/resume
Reliability Catches problems while they can still be fixed

Gains

  • Problems caught mid-run instead of after the damage
  • Reasoning effort spent exactly where the run got confusing
  • Alert logs give a catalog of real failure modes

Costs

  • Signals need tuning; too sensitive and the agent stalls
  • Pause/resume needs a clean way to hand over state
  • Novel failures that match no signal still slip through
06

Worked example

Scenario
An IT operations agent fixes a failing nightly data sync by running checks and restarting services.
  1. Agent (fast)Step 1 checks the sync job and finds it failed with a timeout. Step 2 restarts the connector service.
  2. MonitorStep 3 checks the job again and gets the same timeout. Signal: repeated_failure_after_fix. The run pauses.
  3. System 2Reads the trace and log tail, and notices the source database password expired 2 days ago. The timeouts were auth retries. It replans: stop restarting and open a credentials ticket.
  4. AgentOpens the ticket with the evidence attached and notifies the on-call engineer.
  5. Monitor logWithout the monitor, the fast loop would have restarted the service until it hit its step cap of 8. The alert added about 25 seconds and avoided 5 useless restarts.
07

Failure modes

FailureSymptomMitigation
Alert fatigueMonitor fires on normal variation; runs crawlTune thresholds on recorded runs; track false-alarm rate
Blind to new failuresA new kind of problem matches no signalReview failed runs monthly and add signals from them
Messy handoverSystem 2 misreads the situation from a partial traceHand over a structured state summary plus the raw trace
Monitor shares the agent's blind spotUses the same model and misses the same contradictionsBase core signals on rules and data, not model judgment