Goal setting & monitoring: track progress to a target
Give the agent an explicit target plus a way to measure progress, so loops terminate on done, stuck, or off-track instead of wandering until they run out of tokens.
What it is
An agent without a finish line keeps going. Goal setting & monitoring fixes that by pairing a clear target with a way to check progress against it on every loop.
- The goal: a concrete, checkable definition of done — not "help the user" but "all tests pass and the diff is under 50 lines."
- The monitor: a check that runs each iteration and answers one question — are we closer, stuck, or done?
The monitor is what turns an open-ended loop into something that actually stops.
When to use it
Reach for this whenever an agent runs in a loop and decides for itself when to quit.
- Multi-step tasks with a measurable end state — "green build," "form submitted," "report covers all five sections."
- Long-running or autonomous runs where nobody is watching each step.
- Anything that pairs with reflection or planning — the goal is what reflection grades against.
- It overlaps with evals: the same success criteria can score a run live and offline.
Skip it for single-shot calls with no loop — there's no progress to track, so the monitor is dead weight.
How it works
Encode the goal as something a check can evaluate, then run that check every turn.
- Define success criteria the agent can read — e.g.
tests_passing == true and lint_errors == 0. - After each step, run the monitor and compute progress against the criteria.
- Branch on the result — done ends the run, progressing continues, stuck or off-track triggers a retry, replan, or escalation.
- Track a
no_progress_count; if the metric hasn't moved in N turns, stop calling it progress and break the loop.
The key move — the goal lives in data the agent inspects, not just in a prompt it might drift away from.
Watch out for
- No stuck-detection. A done-check alone isn't enough. Without a no-progress counter, a failing agent loops until it burns the budget — see cost control.
- Vague goals. "Make it better" can't be measured, so the monitor can't fire. If you can't write the check, the goal isn't defined yet.
- Gaming the metric. The agent optimizes exactly what you measure — a goal of "tests pass" invites deleting the tests. Pair criteria with guardrails.
- Monitor drift. A check that's cheaper than the real goal (token count instead of quality) quietly steers the agent off-target.
Related patterns
Planning: make a plan before acting
Make the agent write an explicit, ordered plan before it acts, execute the steps, and replan when reality breaks the plan.
Prioritization: decide what to do next
When an agent faces a pile of possible actions, score and order them by urgency, value, dependencies, and cost instead of just grabbing whatever came in first.
Observability: log selection vs logic
You can't fix what you can't see. Log every tool-call block, separate selection failures from logic failures, and keep structured per-run logs.