An AI agent is a while loop that lets the model pick the next function call.

Below is a real one, running against the Gemini API. It works for a small homewares shop and has eight tools — look up an order, read a policy, check stock, issue a refund, and so on. Give it a customer's message and watch it decide what to do, one turn at a time. Everything it does changes the shop's data further down the page, so you can check its work rather than take its word.

Register to try the lab

Everything below is real — it's just switched off until you register, so you can see exactly what you'd be trying first. It only takes an email and a name.

Register

max 12 turns each

What it's doing

0 turns 0 tokens

Each turn is one call to Gemini. Arrows going out are tool calls the model asked for; arrows coming back are what your C# handed it.

Pick a message above and press Run.

The shop — this is real data the tools read and write. Check its claims against it.

The model is stateless. It remembers nothing between calls, so the whole conversation — your message, its tool calls, and every result — gets re-sent from scratch on every turn. That is what you're watching grow here, and it's why turn six costs several times what turn one did.

turn — — messages — tokens
Run the agent and the conversation appears here, turn by turn.

This is the only description of your app the model ever gets. Nobody hand-writes it — it's generated at runtime by reflecting over the [AgentTool] methods in AgentTools.cs, because the C# signature already says which parameters exist and which are required.

Run the agent to see the schemas it was given.

The real files, embedded at build time — what you read here is what is running. There are only four, and AgentLoop.cs is the one that matters.

Loading…

The system instruction, verbatim. Notice how much of the agent's "behaviour" is just English written by a developer — this text is as much a part of the program as any method here.

You are a customer service agent for a small online homewares shop. You resolve customer problems end to end using the tools you have been given.

How to work:
- Read the customer's message carefully. It may contain MORE THAN ONE problem. Handle every one.
- If you do not have an order number, look the customer up by name or email.
- ALWAYS read the relevant policy with get_policy before deciding what to do. The rules stack.
- Check stock before promising a replacement.
- If a tool fails, read the error and try a different approach. Do not give up on the first failure.
- Finish by emailing the customer a plain-language summary of everything you did.
- When everything is done, reply with a one-paragraph summary for the human operator. Do not   call any more tools once you are finished.

Today's date is 2026-08-23.