Skip to content
AINE · The Agentic Loop

The agentic loop, playable.

An agent is an LLM with tools, context, and a loop — and the loop is the part everyone hand-waves. So here it is, running a real task: play it, pause it, hover anything to see what is actually happening, and at 3 points it will stop and ask what you would do before it shows you what the agent did.

  • 6 turns of the loop
  • 27 steps
  • 3 decisions are yours
  • Hover anything

The task

The session below runs against a Node.js service with an API layer, an auth service, and a test suite. The goal handed to the agent is one sentence: Replace the deprecated getUserById with fetchUser everywhere. Keep the tests green. Everything else — which files to touch, what breaks, how to know it worked — the agent has to discover through the loop.

Step 0/27 · Turn 0/6
Toolbox

The loopwaiting

ReasonActObserveAdjustgoal

The tracewhat the agent says and does

Nothing yet. The session starts the moment you press play — and the first four entries happen before the model generates a single token.

Context windowwhat the model sees

Empty. Everything the model will ever know about this task has to land in here first.

0 / 8,000 tokens| = attention thins

The agentic loop, playable

Press play, or step through it.

One real task, exactly as an agent runs it: the runtime assembles the context, then the loop takes over — reason, act, observe, adjust — until the tests are green. Hover anything, at any point, to see what is actually happening.

Watch the right-hand column

The animation’s real story is the context window. Before the model generates a single token, the runtime has already stacked the system prompt, the tool schemas and the project rules into it — the static foundation, identical on every call. Your message lands on top of that pile, not at the start of an empty one.

From there, every pass through the loop adds and never removes. A thought is a few dozen tokens; one file read is more than every thought in the session combined; a write carries the whole new file in its arguments. By the final reply this small session has spent 5,640 of its 8,000-token window — and a real session is this, repeated for hours. The red tick on the meter marks the uncomfortable truth from the research: well before a window is technically full, attention over its middle has already thinned. Managing that growth — what lands in the window, when, and what never should — is context engineering.

The 6 things worth remembering

  • 01

    The model is stateless. The loop is not.

    Every call starts from a blank model and replays the whole transcript. What feels like memory is the history you watched accumulate — which is why continuity belongs in files, not in the conversation.

  • 02

    Tool results fill the window, not thoughts.

    One file read cost more than every thought in the session combined. The context meter is a budget, and tool output is what spends it — so what a tool returns is a design decision, not a detail.

  • 03

    The model declares; the harness executes.

    Nothing the model outputs runs by itself. It emits a tool call, and your side of the loop decides whether to carry it out. Every permission prompt you have ever clicked lives in that gap.

  • 04

    Tests are observations, not a final exam.

    The red test did not end the session — it steered it. Failure output goes back into the window and becomes the next thought's raw material, which is why failure messages with detail in them make agents converge faster.

  • 05

    Descriptions are the real API.

    The agent picked every tool by reading its description, the same way it will pick yours. A vague description produces wrong calls and wasted turns; a precise one is invisible, which is what good infrastructure looks like.

  • 06

    Stopping is a design decision.

    The loop ended because the model replied without a tool call — and production agents back that up with iteration caps, token budgets and ask-the-human tools. An agent without exit conditions is a while loop with your API key.

Where this comes from

This page animates the mental model from AI-Native Software Engineering: what makes an agent an agent, and how context is assembled and spent while it works. For the seven-day version with practice exercises, take the roadmap; to make your own repo a place this loop works well, follow the baby steps.