Agent Prompting: Stop Conditions Matter More Than Steps

My agent ran all night. When I woke up, it was still searching. It had made 200 API calls.

This wasn’t a bug. I forgot to write stop conditions.

The biggest difference between prompting an agent and prompting GPT isn’t tool calls. It’s stop conditions. GPT gives you one output and stops. Agents keep running. If you don’t tell them when to stop, they’ll run forever—until your API quota runs out or you manually kill the process.

A Real Failure Case

Task: Find 3 data points supporting “AI is transforming education.”

My prompt (first attempt):

Objective: Find 3 verifiable data points supporting the claim that AI is transforming education.

Requirements:

  • Each data point must have a clear source
  • Data must be from 2023 or later
  • Data points should have logical connections

Result: The agent searched 50 times, found 20 data points, and kept searching because it thought “I can find better ones.”

The problem: I defined success criteria (3 data points) but not stop conditions (stop immediately after finding 3).

Three Types of Stop Conditions

Type 1: Task Completion (Success Stop)

Definition: Stop immediately when the goal is met. Don’t keep optimizing.

Before (no stop condition):

Objective: Find 3 data points.

After (with stop condition):

Objective: Find 3 data points.

Stop condition: Once you find 3 data points that meet the criteria, stop searching immediately. Do not continue looking for “better” data.

Keywords: “stop immediately” “do not continue”

Type 2: Sufficient Evidence (Evidence Stop)

Definition: Stop when you have enough evidence to support a conclusion. Don’t chase perfection.

Before (no stop condition):

Objective: Analyze the feasibility of this proposal.

After (with stop condition):

Objective: Analyze the feasibility of this proposal.

Stop condition: Stop when you have enough evidence to determine “feasible” or “not feasible.” You don’t need to exhaust every possibility.

Keywords: “enough evidence” “don’t need to exhaust”

Type 3: Error Handling (Error Stop)

Definition: Stop when you encounter unsolvable problems. Report current progress.

Before (no stop condition):

Objective: Find a solution to this problem.

After (with stop condition):

Objective: Find a solution to this problem.

Stop conditions:

  • If you try 5 times without finding a viable solution, stop and report current progress
  • If you encounter inaccessible resources, skip them and continue
  • If the problem appears unsolvable, stop immediately and explain why

Keywords: “stop after N attempts” “stop when unsolvable”

Before/After Comparisons

Case 1: Data Search Task

Before (goal only, no stop conditions):

Objective: Find 3 research data points supporting “remote work increases productivity.”

Requirements:

  • Data from authoritative sources
  • Published after 2022

The problem: The agent will keep searching, trying to find “the most authoritative” data.

After (clear stop conditions):

Objective: Find 3 research data points supporting “remote work increases productivity.”

Success criteria:

  • Data from authoritative sources (academic journals, major consulting firms, government reports)
  • Published after 2022

Stop conditions:

  • Stop immediately after finding 3 data points that meet the criteria
  • If you search 10 times without finding 3, report what you’ve found and explain why
  • If you find contradicting evidence (remote work decreases productivity), note it as well

Improvement: Clear definition of when to stop (after finding 3), when to give up (after 10 searches), and how to handle unexpected situations (contradicting evidence).

Case 2: Code Review Task

Before (goal only, no stop conditions):

Objective: Review this code and find all potential issues.

The problem: “All potential issues” is infinite. The agent will keep searching.

After (clear stop conditions):

Objective: Review this code and find critical issues.

Priority levels:

  • P0: Security vulnerabilities, data leak risks
  • P1: Performance bottlenecks, logic errors
  • P2: Code style, readability issues

Stop conditions:

  • Stop after finding all P0 and P1 issues
  • Only report obvious P2 issues; don’t dig deep
  • If the code exceeds 1000 lines, review only the core logic

Improvement: Used priority levels instead of “all,” with clear review depth limits.

Case 3: Solution Comparison Task

Before (goal only, no stop conditions):

Objective: Compare three cloud providers (AWS, Azure, GCP) and make a recommendation.

The problem: Comparison dimensions are infinite. The agent will keep comparing.

After (clear stop conditions):

Objective: Compare three cloud providers (AWS, Azure, GCP) and make a recommendation.

Comparison dimensions:

  • Pricing (required)
  • Performance (required)
  • Ease of use (required)
  • Ecosystem (optional)

Stop conditions:

  • After completing the three required dimensions, make a recommendation
  • If data is incomplete for any dimension, note it and continue
  • Don’t dig into optional dimensions unless the first three can’t drive a decision

Improvement: Distinguished between required and optional dimensions to prevent infinite scope expansion.

Stop Conditions for Five Common Scenarios

Scenario 1: Search Tasks

Stop conditions:

  • Stop immediately after finding N results
  • If you search M times without finding N results, report current progress
  • Skip paywalled or inaccessible resources

Scenario 2: Analysis Tasks

Stop conditions:

  • Stop when you have enough evidence to support a conclusion
  • Don’t chase 100% certainty; 80% confidence is sufficient
  • If data contradicts itself, report the contradiction and stop

Scenario 3: Generation Tasks

Stop conditions:

  • Stop after generating one version that meets the criteria
  • Don’t generate multiple versions for me to choose from
  • If the first attempt doesn’t meet the criteria, retry at most 2 times

Scenario 4: Debugging Tasks

Stop conditions:

  • Stop after finding the root cause; don’t keep searching for other possible causes
  • If you try 5 methods without solving it, report current progress
  • If the problem is beyond your capabilities, say so immediately

Scenario 5: Optimization Tasks

Stop conditions:

  • Stop after reaching the target performance (e.g., response time < 100ms)
  • Don’t chase extreme optimization; good enough is good enough
  • If optimization introduces new problems, roll back and report

Self-Check Checklist

After writing your agent prompt, ask yourself:

  • Did I define “when to stop”?
  • Did I define “what to do after failure”?
  • Did I distinguish between “required” and “optional”?
  • Are my stop conditions verifiable? (Not “when it’s good enough,” but “after finding 3”)
  • Did I account for edge cases? (Inaccessible resources, contradicting data, beyond capabilities)

If any answer is “no,” your agent might run wild.

Stop conditions aren’t optional. They’re the core of agent prompts. An agent without stop conditions is like a car without brakes—you never know where it’ll end up.

Stay updated with our latest AI insights

Follow FuturePicker on Google
Scroll to Top