🔥 Machines That Talk · Day 13

The Agent Token Furnace

An "AI agent" (like a coding assistant) doesn't answer once — it loops: think, use a tool, read the result, think again. Every loop re-sends everything so far plus the tool output. That's a furnace that quietly eats tokens. Let's watch one run.

↓ light the furnace
🔥 Lab · The Agent Loop

Task: "Fix the bug in my code"

Press Next step to run the agent one loop at a time. Each step it thinks, calls a tool, and reads the result — and re-sends the whole growing history to the model. Watch the cost per step climb.

🔥

tokens burned so far

Context this step: 0 tokens
Total burned: 0 tokens

💸 Running cost:

$0.00
🐞 Break-It Challenge

The log that poisons the whole run

Real agents paste tool output (terminal logs, file contents) back into the context. Tap to make one tool dump a giant 4,000-token error log — then keep stepping and watch every later step carry that weight.

Ouch. That log doesn't cost you once — it's re-sent on every following step. This is exactly how an agent that "just kept trying" can quietly run up a huge bill. Pros trim tool output before it re-enters the context.
🏷️ The pro wordAn agent runs a tool loop: the model plans, calls a tool (function), reads the result, and loops again — a pattern often called ReAct (reason + act). Because each step re-sends the history plus tool outputs, an agentic run can cost many times a single answer. Even before a tool runs, its description (the tool schema) is sent every step, and the model's tool-call is billed as output. Agents can also fan out — "read 5 files, summarize each, then combine" is 6+ model calls, not one. That's why agents have a max steps and budget cap.
🎯 Boss Build · Run a Lean Agent

Get the job done under budget

Same "fix the bug" task, $0.05 budget. Pick your settings and run the agent — keep it lean enough to finish under budget. Trimming tool output and capping steps are your friends!

budget: $0.05
🚀 Beyond the Basics

How the pros really do it

Agent frameworks (like the coding assistants you may use) all fight the furnace:

✂️

Trim tool output (what you did)

Summarize logs/files before re-adding them. ✅ Stops the furnace roaring. ⚠️ Might drop a needed detail.

🛑

Caps & budgets (the safety net)

Max steps + a dollar limit that halts the loop. ✅ No runaway bills. ⚠️ May stop before finishing.

🧭

Sub-agents & routing (the pro move)

Small models for simple steps, big ones only when needed. ✅ Cheaper & faster. ⚠️ More complex to build.

🏷️ Pro names to look upReAct, function calling, max iterations / step cap, token budgets, and context compaction for tool output. Tools like LangChain and coding agents (Claude Code, Cursor) build all this in.

🎉 Day 13 Complete!

You saw the agent furnace: every loop re-sends the history plus tool outputs, so an agent can cost many times a single answer — and one giant log poisons the whole run. Now you know the fixes: trim tool output, cap the steps, and route to cheaper models.

Day 14: The Speed-Limit Gates →
Tomorrow: even if you can afford it, the AI won't always let you spend — meet the rate limits that gate every API. 🚧
AI Adventure · Machines That Talk · Day 13 — made for young inventors 🚀