promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_

Long-horizon execution — loops, planning, splits, hooks — step 9 of 10

Write should_continue(state) — the completion-guard decision function. Returns True if the harness loop should re-enter, False if it should stop.

The state dict has four fields:

  • goal_met (bool): did the deterministic goal check pass?
  • steps_taken (int): how many turns has the agent used?
  • max_steps (int): the iteration budget.
  • errors_in_last_turn (int): how many critical errors fired in the most recent turn (e.g., hook blocks, exception count).

Return True iff:

  • goal is NOT yet met, AND
  • steps_taken < max_steps (budget not exhausted), AND
  • errors_in_last_turn == 0 (last turn didn't produce critical errors)

Four scenarios run. Expected output:

early loop: True
goal met: False
budget exhausted: False
critical errors: False

full-screen editor opens — close anytime to keep reading.