PromptABCD
FeaturesLearnHow it worksUse casesFAQGuideBlogContext Blocks
Sign inGet started free
Sign inSign up
PromptABCD

A calm home for your best AI prompts. Save them once, find them in seconds, reuse them forever.

Product

  • Features
  • Chrome Extension
  • Free Courses
  • How it works
  • Use cases
  • Blog
  • Context Blocks
  • Export Anywhere
  • FAQ

Resources

  • User guide
  • Learn prompting
  • Sign in
  • Get started free

© 2026 PromptABCD. All rights reserved.

Privacy PolicyTerms and Conditions
Home/Blog/Agent Loop Engineering/The Prompts That Drive Each Loop Step
Agent Loop Engineering

The Prompts That Drive Each Loop Step

One vague system prompt was making an agent loop badly — wrong tools, no stopping, no progress. Great agent loop prompts drive each step deliberately. Here's the teardown and the fix.

August 23, 2026·8 min read
ShareShare
⚡Featured Prompt— copy and use right now
You are a helpful assistant with access to tools. Use them to help
the user with their request. Be thorough and accurate.

An agent I was asked to fix looped badly in every way at once: it picked the wrong tools, never knew when to stop, repeated itself, and drifted off the goal. The team assumed the model was the problem and wanted to upgrade it. But the model was fine. The agent loop prompts were doing almost none of the work a loop needs its prompts to do — one vague paragraph was being asked to drive tool choice, stopping, and progress all at once, and it drove none of them well. This is the teardown of that prompt and the specific prompts that fixed each step.

A loop doesn't run on one prompt. Different moments in the loop need different guidance: how to choose a tool, how to read an observation, when to stop, how to know it's making progress. Cram all of that into a single fuzzy system prompt and each function gets a fraction of the attention it needs. Great agent loop prompts are deliberate about each step.

Before: The Weak Prompt

Here's the original, near enough to reproduce every failure:

You are a helpful assistant with access to tools. Use them to help
the user with their request. Be thorough and accurate.

What this does: gives the model a vague identity and a vague goal with no guidance on tool selection, stopping, or progress — so every loop-specific decision is left to the model's default instincts, which vary wildly.

Run a loop on this and watch it flail: it picks tools by vibe, has no notion of when the task is complete, and re-does work because nothing tells it to track progress. The prompt isn't wrong, exactly — it's just empty of everything a loop actually needs.

Why It Fails

The prompt addresses the task but ignores the loop. "Be thorough and accurate" is fine advice for a single answer, but it says nothing about the decisions a loop makes dozens of times: which tool, based on what; whether this observation means keep going or stop; whether the agent is advancing or spinning. Those are loop concerns, and the prompt is silent on all of them.

So the model falls back on defaults, and defaults are inconsistent. Sometimes it stops appropriately; sometimes it loops. Sometimes it picks the right tool; sometimes it guesses. The agent's behavior looks random because the prompt left every loop-level decision unspecified, and the model is filling those gaps differently each time. A loop needs its prompts to make the repeated decisions explicit.

This is the core insight people miss about agent loop prompts: a system prompt for a one-shot answer and a system prompt for a loop are different artifacts with different jobs. The one-shot prompt shapes a single response, so task framing is most of what it needs. The loop prompt shapes a decision the model will make dozens of times under shifting context — so it has to encode the policy for those decisions, not just the goal. Reusing a one-shot-style prompt for a loop is why so many capable models produce erratic agents: the prompt was written for the wrong kind of job.

⚡ Pro tip: Audit your system prompt by asking whether it mentions the four loop decisions at all — tool choice, reading observations, stopping, progress. If it only describes the task, it's a one-shot prompt doing a loop's job, and the loop's behavior is running on the model's defaults. Naming the four decisions is the fastest upgrade most agents can get.

⚠️ Common mistake: Writing a system prompt that describes the task but not the loop behavior. A prompt that says what the agent is for but nothing about how to choose tools, when to stop, or how to track progress leaves the loop's core decisions to chance. The task framing is necessary but nowhere near sufficient — the loop-driving instructions are what make behavior consistent.

After: The Improved Prompt

The fix is to give each loop function explicit guidance, in one structured prompt with distinct sections.

ROLE: You are a research agent that answers questions using tools.

TOOL SELECTION: Before each call, state which tool and why in one line.
Choose search for facts, calculate for math, finish when done.

OBSERVATIONS: After each tool result, note what it tells you and what
gap remains. Answer only from observations, never from assumption.

STOPPING: Call finish(answer) as soon as you can fully answer. Do not
keep searching once you have enough — over-searching is a failure.

PROGRESS: Track what you've learned in a running list. Before each
action, confirm it addresses a remaining gap. If it doesn't, finish.

What this does: splits the system prompt into explicit sections for the four loop decisions — tool selection, reading observations, stopping, and tracking progress — so each repeated decision gets clear, specific guidance instead of being left to the model's defaults.

Breaking Down Each Element

Four sections, each driving a different loop step.

Tool selection guidance makes the model narrate its choice, which sharply improves tool accuracy — reasoning before acting, baked into the prompt. Observation guidance forces the model to read tool results and ground its answers in them, preventing the ignore-the-result failure. Stopping guidance gives an explicit completion signal and — critically — frames over-searching as failure, which stops the never-ending loop. And progress guidance makes the model check each action against a remaining gap, catching the spin before it starts.

Each section addresses a specific failure the vague prompt allowed. Together they turn inconsistent, default-driven behavior into deliberate, repeatable behavior — not because the model changed, but because the prompt finally told it how to run the loop.

That phrase — the prompt told it how to run the loop — is worth taking literally. A loop prompt isn't describing a personality or a goal; it's specifying a control policy the model executes many times over. Read the improved prompt back and you'll notice it reads almost like a procedure: at this point do this, use this signal to decide that, treat this condition as failure. The vague original read like a mission statement. The gap between a mission statement and a procedure is exactly the gap between an agent that flails and one that runs.

⚡ Pro tip: Frame stopping as a failure to avoid, not just a condition to meet. "Over-searching is a failure" changes behavior far more than "stop when done," because it gives the model a reason to stop rather than a vague permission. Models respond to clear failure framing more reliably than to soft guidance.

Variations for Different Contexts

The four loop functions stay constant; their content shifts by agent.

A coding agent's tool-selection section names when to read a file versus run tests versus edit; its stopping section says finish when tests pass, not when the code merely looks right. A customer-support agent's observation section emphasizes grounding answers in retrieved account data; its progress section tracks which parts of the customer's question remain unanswered. A data-analysis agent's stopping section defines "done" as every sub-question answered with a cited number, preventing both under- and over-analysis.

Same four-section structure, different specifics — each tuned to what tool choice, stopping, and progress mean for that agent's work.

⚡ Pro tip: Keep the four sections as separate, labeled blocks rather than blending them into flowing prose. A model follows an explicit "STOPPING:" section far more reliably than the same instruction buried in a paragraph — the label acts as a signpost the model can find and honor. Structure in the prompt becomes structure in the behavior.

⚡ Pro tip: Write the stopping section last and hardest. Stopping is the loop decision models get wrong most often — both stopping too early and never stopping — so it deserves the most specific, most concrete language in the whole prompt. A precise stopping section fixes more bad-loop behavior than any other change.

Save and Reuse This

The four-section structure — tool selection, observations, stopping, progress — is a template for any loop-driving prompt. Swap the specifics for your agent, keep the structure, and every loop function gets deliberate guidance instead of being left to default. That's the difference between an agent that behaves consistently and one that behaves like the weather.

There's a reason this template is worth keeping rather than rewriting each time: the four decisions are universal to loops, so the structure transfers even when every specific word changes. Any loop-driven agent chooses tools, reads observations, decides when to stop, and tracks progress — that's just what a loop does. So a prompt organized around those four decisions is the right shape for the next agent and the one after it, with only the content swapped. Rebuilding that structure from scratch on every project is redoing solved work.

I keep the four-section agent loop prompts template saved and versioned in PromptABCD, so every new agent's system prompt drives each loop step on purpose from the first run — instead of one vague paragraph that describes the task and leaves the actual loop to chance, then gets blamed on the model when it flails.

promptsagent loopprompt engineeringsystem promptai agentstool use

Continue Reading

Cost per Loop Iteration: Budgeting Token Spend
Agent Loop Engineering

Cost per Loop Iteration: Budgeting Token Spend

Most teams budget agent loop token cost by the total and miss where it actually goes. Here's a case where the real cost hid in re-sent context, and the fix that cut spend 60%.

August 23, 2026·8 min read
How to Handle Partial Failures Inside the Loop
Agent Loop Engineering

How to Handle Partial Failures Inside the Loop

What happens when one tool call in a batch fails but the rest succeed? Handling agent loop partial failure well is the difference between a resilient agent and one that dies on a hiccup.

August 23, 2026·8 min read
Checkpointing Agent State Between Iterations
Agent Loop Engineering

Checkpointing Agent State Between Iterations

Agent loop checkpointing saves the agent's state each iteration so a crash costs one step, not the whole run. Here's how to checkpoint what matters, cheaply, without slowing the loop.

August 23, 2026·8 min read

Save the prompts from this post

PromptABCD is a free prompt manager. Paste, organize, and reuse your best AI prompts — no more hunting through chat history.

Start free →
← PreviousCost per Loop Iteration: Budgeting Token Spend
Share this post:
ShareShare