The Deck · Beontheloop · Beontheloop<br>From Inference Loops<br>to Long-Running Agents<br>Fundamentals, Workflow, and What Actually Fits<br>← tap to go back<br>tap for next →
A note before we startThese aren’t all my own ideas. This is an aggregate of the best thinking in this space — the engineers I learn from — folded together with my own experiments on what actually works and what doesn’t.
“text in”→LLM→“text out”<br>An LLM is a function. Text in, text out. Stateless. No memory between calls.
An agent is a while-true loop<br>that appends to an array.<br>agent.py<br># What an agent actually is<br>while True:<br>user_input = get_input()<br>response = llm.complete(user_input)<br>if response.wants_tool:<br>result = execute_tool(response.tool_call)<br>response = llm.complete(result)<br>print(response)<br>Agent · ↻ while trueuser input→LLM↑↓<br>tool
→output
References<br>Mihai Eric · The Emperor Has No Clothes: Claude Code in 200 Lines<br>Geoffrey Huntley · fundamental skills and knowledge you must have in 2026 for SWE
And that array<br>is the context window.<br>◆Every API call sends the entire array.<br>◆Each turn appends.<br>◆The model is stateless.
CONTEXT WINDOW · 200K · not to scalesystem prompt6.3k<br>tool definitions9.5k<br>CLAUDE.md2.5k<br>user message0.4k<br>assistant1.2k<br>tool result3.1k<br>unused context
The loop, in action.<br>agent.py<br># this iteration takes the tool branchwhile True: user_input = get_input() response = llm.complete(user_input) if response.wants_tool: result = execute_tool(response.tool_call) response = llm.complete(result) print(response)<br>Agent · log// agent ready · waiting for input
→user_input received“find all TODO comments in src/”
→LLM responds: wants_tool=truetool_call: bash(“grep -rn TODO src/”)
→executing tool · bash3 matches in auth.ts, api.ts, db.ts
→LLM responds with answer“Found 3 TODOs across the codebase”
→print(response) · loop iterates ↻
Context window · 200Ksystem prompt6.3k<br>tool definitions9.5k<br>CLAUDE.md2.5k<br>skills0.9k<br>user0.3k
assistant · tool_call0.5k
tool_result0.6k
assistant0.4k
~179k remaining · empty
The agent harness wraps the loop.<br>Everything that isn’t the LLM — what tools exist, what context loads, when to stop.
Agent harness · Claude CodeAgent · ↻ while trueuser input→LLM↑↓<br>tool
→output
system prompt<br>context mgmt<br>skills & tools<br>MCPs<br>sub-agents<br>plan mode<br>session persistence<br>permissions & hooks
the whole stackLoop.Array.Harness.<br>An agent is a while-true loop appending to an array. The harness controls what’s in it.
If the context window is just an array,<br>what goes in the array is everything.
The instruction ceiling is real.<br>Frontier thinking models reliably follow ~150–200 instructions. Beyond that, even rules at the top get ignored.<br>smaller models · exponential decay•frontier thinking · linear decay
Reference<br>Dex Horthy · humanlayer.dev · arxiv:2507.11538
Smart zone, dumb zone.<br>The window isn’t uniform. The first ~40%is where the model thinks clearly. Past that, attention frays — tool choice gets sloppy, instructions get dropped, the goal drifts.<br>“The more context you use, the worse results you’ll get.”<br>Dex Horthy / humanlayer.dev · Geoffrey Huntley
Context window · 200Ksmart zonedumb zone<br>system prompt6.3k<br>tool definitions9.5k<br>CLAUDE.md2.5k<br>skills0.9k<br>~180k remaining · fresh session
Reference<br>Dex Horthy · escaping the Dumb Zone (#262)
The allocation problem.<br>Static fills eat your usable space before the conversation starts.<br>Static fills → smart zone shrinks.before the conversation even starts.
Context window · 200Ksmart zonedumb zone<br>system prompt6.3k<br>tool definitions9.5k<br>CLAUDE.md2.5k<br>skills0.9k<br>~180k remaining · ~60k smart available
The context rot problem.<br>Nothing fails. Every call succeeds. It just fills up.<br>Same window, same model → it rots.no errors. just volume.
Context window · 200Ksmart zonedumb zone<br>system prompt6.3k<br>tool definitions9.5k<br>CLAUDE.md2.5k<br>skills0.9k<br>user · “implement feature X”0.3k<br>assistant · read files0.5k<br>tool_result · 4 files0.6k<br>~178k remaining · smart zone
Good context stays in the smart zone.<br>Fresh session per task start clean, don't reuse a tired window<br>Only what this task needs drop the MCPs and notes that aren't useful here<br>Offload to disk save big stuff as files, keep short summaries in the window<br>Send sub-agents for side quests let them explore, return one paragraph<br>Leave room below the line finalizing work (tests, commits, lint) still has space<br>Split big work across sessions when it won't fit one window, plan it, write the spec to disk, let multiple agents pick it up
Context window · 200Ksmart zonedumb zone<br>system prompt · lean1.2k<br>tool definitions · 4 tools2k<br>spec.md · one task3k<br>skills0.9k<br>user · one clear goal0.3k<br>assistant · tool_call0.5k<br>tool_result1.5k<br>assistant · tool_call0.5k<br>tool_result2k<br>assistant · “done”0.4k<br>~188k remaining · all above the line
Every session starts from zero. Context doesn’t engineer itself.<br>Allocation, rot, compaction, recovery. Someone has to handle them.
Your harness wraps theirs.<br>Anthropic ships the agent harness. You ship the layer...