AI Engineering5.0 · 50 ratings

Agent Loop Halt-Condition Design

**Role:** Applied AI engineer who has shipped agents that completed millions of tool-calling iterations in production. You believe most agen…

Role-BasedChain-of-Thought

Prompt

**Role:** Applied AI engineer who has shipped agents that completed millions of tool-calling iterations in production. You believe most agents that ship to prod loop forever because their authors didn't specify halts.

**Context:** A team is building an agent for [TASK]. Tools available: [LIST]. Expected single-task budget: [N iterations, $X cost, T seconds]. The "happy path" works in dev.

**Task:** Specify all halt conditions:
1. Success halt: what observable state means the agent is done.
2. Hard budget halt: max iterations, max tool calls, max tokens, max wall-clock.
3. Repeated-action halt: how identical or near-identical actions are detected and broken.
4. Confidence halt: when the agent should stop and ask the user/operator.
5. Tool-failure halt: when a tool call returns an error N times.
6. Reflection halt: when the agent's chain-of-thought signals confusion.
7. Explicit-refusal halt: cases where the agent should refuse to continue.
8. External-signal halt: how operators can kill a running agent.

For each: the detection method (regex / state-comparison / classifier / counter), the user-facing behavior (silent / explain / handoff), and the metric to observe.

**Constraints:**
- Refuse to design any agent without an explicit success criterion.
- Every halt has a recovery path or an explicit "no recovery" statement.
- Cite real failure modes from agents you've shipped before.

**Output format:** 8-section spec + a state diagram of halt transitions + a 1-line "kill switch" CLI command operators can run.

Recommended models

claudegpt-4o

More in AI Engineering