Skip to content
All apps

Agent loop

About this app

An LLM agent is a loop: the model writes tool calls as text, a program executes them and every observation grows into the context — with and without tools compared, including a tool failure and a prompt injection.

An agent is a loop

A language model only predicts the next token. A program around it turns it into an agent. The model reads the entire context and sometimes writes a tool call, ordinary text in a format such as JSON. The agent program detects the call, runs the tool, for example a calculator, search, code execution or a clock, and appends the result to the context as an observation. The model then reads everything again and continues writing until it produces an answer. So the model never calculates or searches itself, and the context grows with every step.

What the app shows

Tool stations sit on the left, the growing context stack in the middle and the model on the right. Step by step the system prompt, question, thoughts, tool calls, observations and answer appear, each labelled with its origin. Counters show loops, tool calls and tokens in the context. Six scenarios are available: calculation, current knowledge, multi-step plan, tool error, prompt injection and step budget. All runs are pre-recorded examples, and the companies and products in them are fictional. The 4,096-token context limit is for illustration.

Things to try

Play a scenario step by step, then switch off the tools: the same question is answered from memory, fluent and confident in tone but wrong, outdated or invented. Notice in the context that tool outputs take up most of the tokens. In the tool error scenario the model reads an error message and tries again. In prompt injection a hidden instruction sits inside a document. In the step budget scenario the program stops after three calls, and the honest answer is “not found”.

Frequently asked questions

What is an AI agent?
An AI agent is a language model that works in a loop with tools. The model decides which tool to call, a program executes the call and returns the result. This repeats until the model gives an answer or a limit is reached.
How does a language model call tools?
The model writes the call as text in an agreed format, often JSON with the tool name and arguments. The surrounding program recognises this text, runs the tool and adds the result to the context. The model itself executes nothing; it only produces text.
What is prompt injection in AI agents?
In a prompt injection, instructions are hidden in data that an agent reads, such as a web page or a document. The model might wrongly follow them as if they came from the user. Because models can be fooled, the agent program must also limit what tools are allowed to do without confirmation.
What can I try in this app?
You pick one of six scenarios, play it step by step and watch the context grow. The tools switch lets you compare the same question with and without tools.

Subject: Neural networks

More from Neural networks

A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps