Loop Engineering: how AI agents have evolved
A four-stage analysis of AI agent evolution: from system prompts that grew to 25,000 tokens, to autonomous loops that self-prompt and cycle until the goal is met.
Giacomo Mirandola — Product & Frontend Engineer ·
TL;DR — In just a few years we moved from writing longer and longer prompts to designing loops that self-execute. Here are the four stages that explain how language models became true autonomous agents — and why at BlueSky we use all of them to build agents that actually work.
1. Prompt Engineering: the basics
What it is. The initial method to steer AI models: write a system prompt with clear instructions and a role (“you are a lawyer”, “you are a front-end developer”).
Prompt evolution. To make the model follow instructions precisely, prompts grew huge — up to 25,000 tokens to include correct-answer examples, constraints and strict guidelines.
2. Context Engineering: the era of tools and memory
Agents are born. LLMs become real agents, able to interact autonomously with local files, the web and external apps via protocols like MCP.
The Context Rot problem. Each tool call (a web search, a CRM read) fills the model's context window. Past 200,000 tokens, performance degrades drastically.
An imperfect fix. Context Engineering handles this by shortening responses and compacting information via summaries to free up space — at the cost of progressive performance loss.
3. Harness Engineering: external scaffolding and the file system
The new paradigm. Instead of endlessly summarizing memory, Harness Engineering introduces an external scaffold that breaks complex tasks into sub-tasks.
Extended memory. To avoid saturating the context window, the agent writes its own history and decisions to local files (typically Markdown, like memory.md).
Smart flushing. Once a sub-task is done, short-term memory is cleared. In the next step, the agent uses semantic search to re-read from local files only what it needs — picking up exactly where it left off.
4. Loop Engineering: continuous automation
What it is. The latest evolution: take the whole Harness Engineering structure and wrap it in automation loops — a “loop on top of loops”.
Self-prompting agents. The user no longer needs to correct or push the agent step by step. The agent self-prompts and keeps looping through its tools until the problem is solved or the goal is met.
Triggers and Goals. Loops start from triggers (a new GitHub issue, an email, a notification) or preset commands (like /goal) with a set number of retries and termination conditions.
Verification levels. To know when to stop, the loop uses different conditions:
- Deterministic — code produces no errors.
- Hard rules — execution must take under 100 ms.
- Delayed truths — wait for a social post to reach 300 likes.
- LLM as a judge — another model evaluates output quality.
- Human in the loop — final check stays with the user.
Why this matters for your business
The future of AI isn't in writing single commands: it's in designing cyclical systems capable of self-improvement. That's the leap that turns a chatbot into an operational agent — able to fix bugs, optimize processes or update content autonomously, with human oversight only where it truly matters.
At BlueSky we build our agents applying all four stages: careful prompting, context engineering for memory, harnesses to orchestrate complex tasks, and verification loops to guarantee measurable results. Tell us about your case and let's figure out which level fits your business.