Giving Loops Memory
For loops that run over many steps (research agents, multi-turn assistants), summarize prior steps into a short running memory instead of replaying the full history every time — this keeps context small and cheap..
The prompt
Here is a running summary of research so far: [summary]. Here is the newest finding: [new info]. Update the summary to under 150 words, keeping only what's still relevant to answering: [original question].
What to replace
Swap these placeholders for your own details before running the prompt:
[summary]your own value[new info]your own value[original question]your own value
Pro tip: Re-summarize memory every 3-5 steps in long-running agents to avoid context bloat and drifting off-task.
How to use this prompt
- Copy the prompt using the button above.
- Replace [summary], [new info], [original question] with your own details — the more specific you are, the better the output.
- Paste it into Claude and run it.
- If the answer feels generic, add constraints: audience, length, tone, and what to avoid. That single change fixes most weak output.
Learn the technique
Giving Loops Memory
Module 2 — Building Agent Loops · Loop & Agentic Engineering
Related prompts
Critique-and-Revise Loops — ChatGPT
A loop is simply feeding a model's own output back to it (or to a second prompt) for review and improvement, repeated until a quality bar is met.
ClaudeCritique-and-Revise Loops — Claude
A loop is simply feeding a model's own output back to it (or to a second prompt) for review and improvement, repeated until a quality bar is met.
ChatGPT / Agent toolsThe ReAct Pattern (Reason + Act)
ReAct loops interleave reasoning ("what should I do next?") with actions (calling a tool, searching, running code), then feed the result back in before reasoning again.
Any modelPlanner–Worker–Reviewer Teams
The most robust agent architecture is also the simplest: a Planner decomposes the goal into tasks, Workers execute one task each with narrow context, and a Reviewer checks results against acceptance criteria before anything ships.
Any modelLoop Budgets and Failure Handling
Production loops need budgets (max iterations, max cost, max time) and explicit failure paths: what happens when the Reviewer fails a result three times? Options: escalate to a human, fall back to a simpler method, or return a partial result flagged as unverified.
Any modelProject: Draft–Critique–Revise Content Machine
Deliverable: a working 3-role loop (writer, critic, editor) that produces a publishable piece of content on any topic you give it. Steps: 1.
Topics
Related across the site
n8n and AI: Build Your First Real Automation
A practical walkthrough of wiring an AI model into an n8n workflow — the node structure, the prompt that makes it reliable, and three automations worth building first.
AI agent
An AI agent is a system where a model plans and takes actions through tools in a loop, rather than producing a single response. It decides what to do next, does it, observes the result, and continues until the goal is met.
AI Automation with n8n
Connect AI models to real workflows using n8n — the open-source automation tool. Learn the HTTP Request and AI Agent nodes, and build automations that run on a schedule or trigger.
AI Marketing
Use AI for market research, copywriting frameworks, and audience segmentation — with prompts that produce genuinely usable marketing assets, not generic filler.
AI SEO & Search Visibility
Use AI to do keyword research, optimize content for search, and get your brand cited by AI answer engines like ChatGPT, Perplexity, and Google AI Overviews.
Build a Personal Study Assistant
Turn a stack of lecture notes into a study partner that quizzes you, explains what you got wrong, and tracks which topics you keep failing. You will finish with a reusable system prompt you can point at any subject.