Mental loop & dry run
Two simulation patterns that work together: Mental Loop simulates actions internally before execution, choosing the safest option. Dry Run adds formal safety checks and approval gates, essentially "preview mode" before any irreversible action.
Mental loop + dry run pipeline
Any time the agent is about to take an irreversible action: deleting data, sending emails, making financial transactions. The dry run simulates the outcome and gets approval before executing, preventing costly mistakes.
# Mental Loop (Pattern 39)
class MentalLoopAgent:
def simulate_and_choose(self, situation, goal):
actions = self.propose_actions(situation, goal)
results = []
for action in actions:
sim = self.simulator.simulate_action(action)
results.append(sim)
best = self._choose_best_action(results)
return self._execute_action(best.action)
# Dry Run (Pattern 43)
class DryRunHarness:
def process_action(self, action):
# Safety check first
safety = self.safety_checker.check_safety(action)
if not safety["is_safe"]:
return {"status": "rejected", "reason": safety}
# Simulate
dry_run = self.simulator.simulate_action(action)
# Review
review = self.reviewer.review_dry_run(dry_run)
if review["decision"] == "APPROVED":
return self._execute_action(action)
return {"status": "rejected", "review": review}Mental simulation with risk scoring, plus dry run safety validation.
Dry run pattern
Quiz: Quiz
Loading practice…
Flashcards: Flashcards
Loading practice…
Mental Loop and Dry Run give agents a "think before you act" capability, essential for any system that takes real-world actions. Next, we will look at how to orchestrate multiple agents using Meta-controller routing and Ensemble aggregation.