AI agents, the useful 20%

For someone who already knows agent theory, and now has to build, run and trust the LLM kind. Everything else is deliberately left out.
PrimerSoftwareSeptember 20, 2026
The one confusion. The model is not the agent. The model is one stateless function call: text in, text out, with the option to ask for a tool. The agent is the loop around it — the code that decides what goes into that call, what happens to what comes back, whether to go again, and when to stop and fetch a human. Everything that looks like memory, autonomy or initiative lives in that loop, not in the model. When an agent misbehaves, the loop is almost always the thing to fix.

What is different from the agents you know

Classic agent theory still holds; the parts just sit in different places. Each row is the same idea, relocated.

Classic agentWhere it lives in an LLM agent
AutonomyA permission setting in your harness, not a property of the thing. You choose per tool: read freely, write only after approval.
Persistence / stateNowhere by default. The model forgets everything between calls. State is a file or a database your loop re-reads and re-injects each turn.
Goal / intentionA sentence in the prompt. No goal stack, no BDI machinery — only what you re-state every turn, so a long run drifts unless you restate it.
PerceptionWhatever text you paste in, plus tool results. It sees nothing you did not hand it, and it cannot tell fresh data from stale.
LearningNot in the loop. Weights are fixed at run time. "Learning" means you wrote something down and put it back in the context next time.
CoordinationNo protocol, no shared blackboard, no negotiation. One agent calls another the way a function calls a function, and gets text back.
Reactive vs deliberativeBoth come from the same model. The difference is only whether your loop lets it plan before acting.

The parts

Model
The one call that turns context into either an answer or a request to use a tool. Swappable. Pick it per task, not per system.
Context
Everything the model sees this turn: instructions, the task, prior results, tool output. Your real product. Assembled fresh every call.
Tools
Functions it may ask for by name, with typed arguments. The model never runs anything; your code does, then hands back the result as text.
Loop
Call, read the answer, run the tool, put the result back, call again — until done, stuck, or over a limit. Limits are not optional.
Memory
Two kinds, both yours: what you carry in-context this run, and what you write to disk between runs. Retrieval is just a tool that finds text.
Gates
Where a human must say yes, and where the loop must refuse itself: spend caps, tries, allowed tools, "never without approval" actions.
Trace
A record of every call, tool use and result, replayable later. The only way to debug something non-deterministic. OpenTelemetry spans are the norm.
Evaluation
A fixed set of tasks with known-good outcomes, re-run after every change. Judging the final answer alone hides a wrong path that got lucky.

The shapes worth knowing

Ordered by cost and risk. Go down the list only when the one above genuinely fails; most jobs people call "agentic" are the first two.

ShapeWhat it isReach for it when
WorkflowFixed steps you wrote, model calls inside them. No decisions about control flow.You already know the steps. Cheapest, most reliable, most of what ships.
Tool loop (ReAct)Think, call a tool, look at the result, repeat. The model chooses the next move.The path depends on what it finds. The default "agent".
Plan then executeWrite the whole plan first, then run the steps, replanning only on failure.Long jobs where wandering is expensive. Gives you a plan to approve.
ReflectionA second pass critiques the first against stated criteria, then it revises once.Quality matters more than latency. Cap it at one or two rounds; more drifts.
RouterA cheap call picks the specialist, model or tool, then hands off.Mixed traffic with clearly different kinds of work.
Orchestrator + subagentsA parent splits the work, children run with their own context, parent merges.Independent pieces, or you need isolation. See the last two sections.
Human in the loopThe agent proposes; a person confirms before anything lands.Anything that writes, spends, sends or publishes. This is Command's shape.

The everyday loop

Pick one unit of work. Assemble its context from scratch — instructions, the task, the few things it needs. Call the model; if it asks for a tool, run the tool and put the result back. Stop on an answer, a question, or a limit, then write the result somewhere durable and let a human look. Repeat with the next unit. That is the whole craft: the interesting engineering is in what you put in the context and where you stop, not in the model call.

Safe to try

These cannot damage anything, and they are how you build confidence before letting an agent near real work.

node _agents/runner.js --dry        # lists what it would pick up, changes nothing
model: mock                         # a fake provider that answers from memory, no network, no key
--max 3                             # at most three steps a tick, so a bad run stays small
sh _agents/run-tests.sh             # 62 checks on a throwaway board and fake APIs

The general versions: a dry run that prints the plan, a mock model, a hard cap on steps and spend, and read-only tools. If a framework makes any of those four hard, that is a reason to distrust the framework.

Practice, start to finish

  1. Write the task as one step with a clear finish line, and say which model. You should be able to state, in one sentence, what "done" looks like.
  2. Run it against the mock provider. The step moves to "for review" with a fake answer — proving the plumbing, not the intelligence.
  3. Switch to a real model, one step only. Now you get a real answer, plus tokens, cost and elapsed time recorded on the step.
  4. Read the answer and the trace, not just the answer. Right answer by a wrong route means the next, slightly different task will fail.
  5. Send it back with a reason instead of fixing it yourself. The reason and the previous attempt go into the next context — that is the feedback loop.
  6. Only now let it run unattended, with the caps on. Cost per run and steps per tick should be numbers you know before you sleep.

When it goes wrong

SymptomWhat it really isWay out
It loops foreverNo stop condition it can reach; each turn re-reads its own last turnCap steps and tries. Make "I am stuck" a legal, rewarded answer.
Good at first, vague laterContext rot: distraction — it starts copying the shape of its own earlier turns instead of thinkingShorter runs. Summarise and restart rather than appending forever.
Repeats a wrong factContext poisoning: one hallucination entered the context and is now cited as evidence at every stepNever let the model's own output back in as fact. Restart the context; do not patch it.
Confidently off-targetContext confusion: too much irrelevant material in the windowPut in less. Relevance beats volume; a bigger window does not fix it.
Tool call fails or mis-firesThe most common production failure, usually bad arguments or a changed interfaceHand the error text back as a normal result and let it try once. Validate arguments before executing.
Right answer, wrong workIt used last year's file, or guessedJudge the trace, not the output. This is what evaluation is for.
It obeys a web pagePrompt injection — text it fetched contained instructions, and it followed themTreat every tool result as data, never as instruction. Keep dangerous tools behind approval, so an injection has nothing to grab.
Bill is a surpriseFan-out: retries, reflection and subagents multiplyRecord cost per run from day one. Cap per task, not per month.

Leave this alone: an agent with unattended write access to the only copy of something. Not because it is malicious, but because it is confident and quick. Any write it makes must be either reversible, backed up before the fact, or gated behind a human yes.

Why the way out works. Almost every fix above is the same fix: make the unit of work smaller, and make the loop stop sooner. Small units mean a bad run wastes one step instead of an afternoon, a retry is cheap, a review is quick, and the trace is short enough that you can actually read it.

Where it runs: the sandbox

Gates decide what an agent may ask for. A sandbox decides what it can reach even if nothing stops it — the difference between a rule and a wall. Instructions are advice to a model that can be talked out of them; a wall is not. Four dials, from loosest to tightest:

DialWhat you setWhat it stops
FilesystemOne working directory it can read and write; everything else invisible or read-onlyThe confident rm in the wrong folder; reading credentials it was never meant to see
NetworkDeny by default, allow named hostsData walking out, and a poisoned page calling home
CredentialsThe child process gets a bare environment: no keys, no tokens, scoped to one jobA leaked key in an error message or an echoed request
MachineA container or VM with a snapshot, thrown away after the runEverything else, and it makes "undo" a single command

The practical rule: the blast radius should be obvious before the run, not discovered after it. Unattended work belongs one level tighter than attended work, because nobody is watching the moment it goes wrong. Note the cost too — a real sandbox adds startup time, and cutting the network breaks the tools that need it, so most setups end up with a narrow allowlist rather than a wall.

Agents spawning agents

A subagent is not a new kind of thing. It is the same loop, started by another loop, with its own fresh context and its own tools. The parent sends a task; the child runs blind to everything it was not told; only the child's final answer comes back, as text, into the parent's context.

Why it helps

What it costs

Utility agents: the other reason to have two

Not every second agent is a worker splitting a task. A utility agent runs beside the task agent and does one job on its behalf. The clearest current example is a proactive memory agent: instead of the worker deciding when to search its own notes, a separate agent watches the run and pushes the fact forward when it becomes relevant. Reported gain on Terminal-Bench 2.0 with Sonnet 4.5: 37.6% to 45.9%, with no retraining — a pattern change, not a model change. The same shape fits a critic, a budget watcher, or a safety check. What makes it work is that the second agent has a different job and a different context, so it notices what the first one is too deep in to see.

Rules that keep it sane

RuleWhy
Depth two, hardParent and children. Grandchildren make cost and blame untraceable. Children may not spawn.
Written contract per childOne objective, the inputs, the shape of the answer, the tools allowed. If you cannot write it, do not delegate it.
Pass the budget downEvery child gets a share of steps, tokens and time. Unbudgeted children are how a run costs 50×.
Children return data, not ordersThe parent treats a child's answer as a claim to weigh, exactly like a tool result. Otherwise one poisoned child steers the whole run.
Parent owns every side effectChildren read, think and report. Writes, sends and spends happen once, at the top, where the human gate is.
Make them independentIf child B needs child A's output, they are not parallel — that is a workflow, and a plain sequence is cheaper and clearer.

When it is not worth it: a task under a few steps, anything sequential, or anything where merging costs more thought than doing it yourself. The honest default is one agent, small steps, until you can point at the specific window or wall-clock problem a fan-out solves.

The atom

The unit of agent work is one step: one objective, one context, one result. Not a conversation, not a session, not a project. Everything good about an agent system comes from getting that unit small and well-shaped, because the unit is what you retry, parallelise, review, price and blame.

PropertyMeaningWhat it buys
BoundedOne finish line, plus caps on steps, tokens and timeA bad run is cheap. You can say no to it early.
Self-containedIts context is assembled from durable state, not from whatever happened to be in the windowIt runs the same tomorrow, on another machine, after a crash.
Re-runnableRunning it twice is harmless, or is explicitly gated so it cannot beRetry becomes a non-event instead of a risk.
ObservableIt produces a result you can read and a trace you can replayYou can judge the work, not just the wording.
GatedIts side effects are reversible or need a yesAutonomy becomes a dial you turn per step, not a leap of faith.

Compose atoms; do not grow them. A big job is a list of small steps with a review between, not one long-running agent with a big goal — the long run is where drift, cost and unreviewable output all come from. This is also the honest answer to "how autonomous should it be": as autonomous as one atom, then a human or a parent decides again.

Where this lands in Command

ConceptIn Command
The atomA checklist step on a card — one objective, its own instructions, its own result
Permissionactor (human, agent or both) and approved, decided before anything runs
Budget and retriesagent_tries, three then it waits for you; steps per tick; a timeout per call
Result and traceresult, plus agent_run with model, provider, tokens, cost and elapsed time
The human gateEvery finished step lands in "for review". Send back with a reason, and the reason becomes the next context
The door to real agentsThe command driver: any program that takes a step as JSON and returns an answer — LangGraph, an Agent SDK script, a shell script

Words you will see

Harness / scaffold
The code around the model: loop, tools, limits, gates. The part you actually write.
Tool calling
The model returns a structured request to run a named function. Your code runs it and returns the result.
MCP
Model Context Protocol: a standard plug so any tool server works with any agent, instead of one adapter per pair.
Context engineering
Deciding what goes in the window each turn. Has quietly replaced "prompt engineering" as the job.
Context rot
Quality falling as the window fills, in every model regardless of size. Poisoning, distraction, confusion.
Trace / span
The recorded tree of calls and tool uses for one run. Replayable. The agent equivalent of a stack trace.
Eval
A fixed task set with known outcomes, run after every change. Without it you are tuning by vibe.
Guardrail
A check outside the model that can block an action. Instructions are advice; guardrails are enforcement.
Prompt injection
Instructions hidden in content the agent reads. The top LLM security risk, and worse in agents because they can act.
Handoff
Passing a task to another agent with its own instructions and tools. A subagent that replaces you rather than reporting back.

The landscape, in one line each

LangGraph — your agent as a graph of steps with explicit state; good when you want the control flow visible and resumable. Claude Agent SDK — the loop, tools and permissions already built, close to how Claude Code itself works. OpenAI Agents SDK — the production replacement for the archived Swarm; handoffs and guardrails as first-class parts. Microsoft Agent Framework — Semantic Kernel and AutoGen merged into one runtime. Memory layers (Mem0, Letta, Zep) — storage for what should survive between runs. Anthropic's own guidance, and the honest consensus: use the simplest composable pattern that works, and add a framework only when you can name what it saves you.

Deliberately not here

Fine-tuning and RL for agents — you will not train a model before you have traces worth training on. Vector-database choice, chunking and retrieval tuning — that is its own primer, and most agents need less retrieval than people assume. Framework APIs — they change faster than this page. Multi-agent negotiation, auctions and emergence — the classic literature you already know, which LLM agents do not currently implement. Benchmarks and leaderboards — they measure what is easy to measure; your own eval set on your own work is worth more than all of them.

AI agents · primer, four pages · September 20, 2026 · Written for Rich Price, with examples from Command 1.5's runner.