Lessons for building agents
What this testbed has taught about building AI agents that work on their own: the tools they call, what they are told, the state they share, the loop that runs them, how they are measured, and how the system around them gets better. Each lesson is written for any agent, in a codebase, a ticket queue or a business tool. The evidence under each comes from a logged run here, in one line, with a link to the write-up that has the numbers.
The environment is Minecraft because agents in it can be watched and runs can be repeated. It is the evidence, not the subject. The models were never trained here: they came knowing the game, which is among the best-documented anywhere, so these runs test the structure around a model that already knows its world (see Evaluation).
The short version. When an agent fails, look first at what its tools did and what it was told, then at its judgement. Most early failures here were ours: tools that misled it, information it couldn't see, and actions it had no tool for. Fixing those moved the agents further than any prompt change would have, and left their own behaviour visible to study.
Tools
A tool is the only way an agent touches the world, and the only account it gets of what happened. The agent plans on that account. If it is wrong, every decision after it is wrong too, however good the model.
- A tool's description carries the cautions; measure before trimming it. Long descriptions cost tokens, but the sentences beyond "what it does" are where the risks and limits are. Evidence: 50 logged decisions replayed with every description cut to its first sentence (the prompt 60% shorter) changed the choice beyond the model's own noise (29 of 50 the same, against 36 of 50 between two full runs), and the changes leaned from safety to the goal: picking up an item beside monsters, mining at 5 health. (ideas)
- Report what happened, not what was expected. A result that says "delivered" because delivery
was attempted sends the next decision the wrong way.
Evidence: a hand-over said two pickaxes lay "beside" a teammate who had walked off; the teammate
searched for them five times. A
takefrom a chest reported items picked up off the floor on the way as "taken from the chest". (06) A hunt begun inside a closed home never got out of it and ran its clock down in place, then said "the sheep got away": 208 of 223 such hunts in two nights, while the agents planned around animals that were never the problem. Fixed, the team's success rate went from 2 in 6 to 7 and 8 in 10. (07) - A refusal must be true. "Not possible" or "not found", when the action was possible, makes the agent plan around a problem that isn't there, and it rarely tries again. Evidence: mining refused reachable ore as "out of reach" 44 times in one team run, and in 34 of 53 earlier runs that mined; it starved the part of the goal that needed iron. (06) A refusal must also fit the situation it is given in, and the best one is no refusal: "descend closer first" for ore far below was said 144 times in 13 reps until the tool dug toward the ore itself, and "walk outside first" was said to an agent already outside, on its home's roof. (07)
- Do exactly what was asked, no more. A bulk side effect is invisible to the agent until the
damage shows.
Evidence: asked for 1 item from the team's store,
taketook all 10 and emptied it. (06) - End an action when what it acted for is gone. A long-running action that loses its subject
should stop and say so, not carry on and report on whatever it finds.
Evidence:
fleeran on after the agent died and reported success: 39 of 86 deaths in one run came during a flee that then said it had worked. (06) - Tell interrupted, impossible and temporary apart. Each calls for a different next step. Evidence: an interrupted dig was reported as "a block I cannot clear"; a craft cut short by an interrupt blamed the server; a teammate who had left was reported as one who "doesn't exist". (02, 05, 06)
- Write errors the agent can act on, and name the tool that fixes them. A raw error from deep in a library is noise; one that names the next step gets followed. Evidence: "is smelted from raw_iron, not crafted" was followed by mining more ore. "Need 3 more cobblestone", which names no tool, was followed by the same failing craft 4–16 times. "Destination full" from the smelting library failed 42 times in one run. (03, 06)
- Give a read-only way to look. Without one, an agent learns the state of something by changing
it.
Evidence: an agent took food out of the shared store to see what was in it; after
look_in_chestwas added, agents looked 11 times and took nothing. (06) - Cover every step a plan will need, or say which you don't. An agent will plan a step it has no tool for, and nothing tells it the step silently failed. Evidence: asked to "place the beds" for the team, an agent could only place a bed by sleeping in it; the spare stayed in its pack while a teammate had none. (06)
- Check what an action leaves behind, not just the action. Each step can be valid on its own and still break something everyone relies on, such as a way out. Evidence: three beds, each put down in free space, walled off the back of a shared home, and an agent was shut in for the rest of the run. Now a bed goes only where the room can still be walked through from its door. (06)
- Fixing tools moves results more than changing models. Evidence: the same small model went from 3 of 9 runs to 8 of 9 on fixes to tool code alone (01); four paid models went from 4 of 12 to 12 of 12 (04).
Observations and context
What the agent is told about its situation each time it decides. It has to be small, because every word is paid for on every call, and true, because the agent believes it.
- Agents trust the summary over the evidence. A computed status ("safe", "done", "0") beats the raw signal beside it, even when the two contradict each other in the same observation. Check every status you compute against the signals it summarises. Evidence: an agent waited beside a zombie because its home was reported "closed"; another reasoned for 26 decisions from a health of 0 that was really 0.4; agents believed a team progress list over their own last action. (06)
- Never round away the edge case. Formatting that is fine for most values hides the one that matters. Evidence: health under half a point showed as 0 (above).
- A fixed cap drops what matters. Truncating a list to N items cuts off whichever item came N+1st, which may be the important one. Give the important kinds their own place. Evidence: a cap on nearby blocks hid the team's chest from an agent standing beside it; beds weren't listed at all. (06)
- What's out of range is invisible. An agent decides as if nothing exists beyond what it is shown. Evidence: agents went home to a doorway crowded with monsters because hostiles were listed only within 24 blocks of the agent and the home's line said nothing of them; of 38 entries where an agent was hit, 7 got in. Now the home's line names the mobs at its doorway, and the tool for going in stops short of them and says why. (limitations; not yet seen in a team run)
- A true, neutral fact can still pull agents off the goal. What an agent is shown, it acts on: a fact about a side issue becomes a side quest. When you add one, measure how behaviour changes (trips, deaths, time), not only the success rate. Evidence: a standing line telling agents where they and their teammates had dropped things on dying, true and worded as plain fact, sent them back for those things about ten times as often at night (1.3 to 15 trips a run); about 9 in 10 of those trips failed, deaths rose from 2.7 to 5–9 a run, and the team's success fell from 21 of 30 to 4 of 12. It came out. (08)
- Tell the agent who it is. Without its own name, an agent addresses itself. Evidence: agents tried to hand things to themselves and ask themselves questions until the prompt named them. (next steps, team run trio3)
- Carrying the agent's own plan forward can hurt. A small model trusted its stale plan over what the world reported, and looped. Evidence: with a written plan carried between decisions, a 4B model met its goal in 13 of 24 runs; with no memory, 12 of 12. One asked for "one more log" 134 times while told it held 12. (01)
- More context is slower and can wear an agent down. Resending the whole conversation filled a small model's window and quadrupled its decision time. Evidence: about 21 seconds a decision against 4–5; five of six such runs gave up early, citing their own failures. (02)
- Telling an agent what is still open helps it close what it can act on. It doesn't help with what it can't. Evidence: with the goal's open parts listed each step, a team kept its food store full in 3 reps of 3 (1 of 3 without), refilling it unasked when a teammate ate from it; iron and beds didn't move. One model tried the step it had been skipping in 6 runs of 9, against 3. (06, 02)
- State goals as outcomes. What the task requires can reach the agent through tool descriptions and failure messages, the way it reaches a person, rather than through steps in the goal. Evidence: spelling out the steps made no difference for a small model with no memory (6 of 6 either way). (01)
Shared state between agents
When several agents work toward one goal, what they believe about each other is state, and it has the same problems as state in any distributed system.
- One rule for shared derived state. If each agent computes "the" shared thing for itself, they will disagree exactly when it matters. Evidence: with two bases built, each agent's progress list named the one it knew of first; two teammates were told to sleep in different homes for 118 decisions. Fixed by one rule for everyone. (06)
- Publish shared state on a clock, not when each member finishes its work. Otherwise the view lags by a whole task, and the next action is taken twice. Evidence: 16 seconds after a teammate received a pickaxe, the list still said it had none, and it was given a second, the last one. (06)
- Agents answer requests, not needs. They are generous when asked and almost never act on a need they can see. Design for it: turn needs into explicit requests, as tickets do for people. Evidence: 31 of 35 hand-overs between teammates followed a request; a spare bed stayed in one agent's pack while it was told, night after night, which teammate had none. (06)
- A request works only if it maps onto something the asked agent can do. Evidence: "bring the beds and place them" failed where "give me a bed" would have worked. (06)
- Messages are interrupts, and they cost. Each message cuts into the receiver's work. Status chatter drowns out the requests that matter, and orders from a peer with no authority are treated as suggestions. Evidence: teammates' messages broke off work 87 times against 100 for threats; questions were answered three times in four, instructions followed at once 1 time in 27; the same words repeated now interrupt only once. (06)
- Agents organise themselves, then the plan freezes. They split the work unprompted in their first few decisions, and nobody revisits the split when an owner stalls. Evidence: every team divided the goal over chat within two or three decisions; when the agent that owned a part stalled, no one took it over. (06) It holds even when a tool says the owner is gone: after the agent holding all the team's pickaxes left the game, a teammate sent it 62 requests, each refused with "no other agent ... is in the world right now", before mining for its own on day 2. (06)
- State held in one place is lost with it. What lives only in one agent goes when that agent fails. Evidence: twice an agent made every pickaxe the team needed, carried them all, and died with them; things stored in the shared chest were the only things that survived deaths. (05, 06) It happened again with the tool describing the chest as safe: an agent drowned carrying the team's three iron pickaxes (06).
- Share what each agent observes, not only what it holds. A finding that stays in one agent's context is rediscovered, or never found, by the rest. Evidence: with sightings of animals forgotten as soon as they left an agent's view, sheep were in view in 6-7% of observations and three beds were never made; shared for ten minutes, an agent walked to the sheep a teammate had seen, and everyone slept in the home. (06)
- Share what changed, not only what was seen. An agent acts on its last belief until something tells it otherwise, and it rarely re-checks what it believes is done. Evidence: one agent emptied the team's food chest to eat; the other two, whose last look was older, spent most of a day sure the food was stored, and the run missed its goal by 3 seconds. With each agent shown the chest as last seen by anyone, and told when a teammate found it changed, agents cooked and stored on the news ("need 10 cooked meat in chest"). (06, tbase6)
The control loop
The world moves on while the model thinks. The loop that runs the agent decides how often it is asked, what can interrupt it and what happens without it.
- Keep the model out of the fast loop. The model chooses a goal; deterministic code carries it out, retries, gives up and reports back. One rule holds the design together: the model decides, the code does. Evidence: paid models finished a one-day goal in 20–33 decisions (04); a team got through three in-game days on 95–188 decisions per agent (06).
- Replan on events, not on a timer, and filter the events. An interrupt that doesn't change the right next step only costs a decision. Evidence: a monster outside a closed shelter interrupted an agent, which went out to it; once that stopped interrupting, no agent left its shelter at night. (04)
- Put what can't wait in code, as a reflex. Some things happen faster than a model answers. A reflex keeps the agent alive until the model has chosen, then says what it did; it doesn't choose for it. Evidence: an agent was killed during its 2.3-second decision to run; agents under water now swim out before the model is asked anything (02). In one team run, 9 of 17 deaths came while the model was still deciding, most with a monster already beside the agent; stepping back while it decides kept health at 20 where standing still lost 15 (06). A reflex has to cover the whole gap: swimming out before and after each decision missed the drowning that came during one (06).
- A reflex can do quiet harm; count how often it fires against what it guards. Code that acts without the model acts without its judgement, and its mistakes show up only as an odd line in the log. Evidence: a reflex meant to dig falling sand off an agent's head also dug out the home's door whenever an agent stood in the doorway, about 4,500 events over two weeks, against 56 for every other block put together; it left an agent locked out at dusk and killed with the team's iron pickaxe (07).
- An escape needs a destination. "Away from danger" can lead somewhere worse; "toward safety" is the goal. Evidence: agents fled straight away from monsters, away from their home and into a lake, and 7 of 17 deaths came during a flee (06).
- A failure that keeps coming back is a chain of gaps, closed one run at a time. The agent's choice can be right throughout while the structure behind it fails it in a new way each run. Evidence: agents answered monsters by running in every run of the team goal. Deaths came, in turn, from a home reported safe with a zombie inside, the body standing still while the model decided, running away from home, a tool running on after the death, arrows, drowning, digging under gravel, and a home besieged at night; each was answered in the tools and the next showed itself (06).
- Give the agent honest ways out. A way to say "done" that is checked, and a way to give up with a reason, both counted. Evidence: a premature "done" is refused once and told what is missing; a false claim of success is recorded as data. (04)
- A notice is not a circuit-breaker. Telling an agent it is looping doesn't stop it. Here that is measured, not fixed; in production you would need a hard stop. Evidence: a small model chose the same decision again after 290 of 293 notes that it was repeating itself. (02)
- Rate-limit side channels. A burst of failures can turn into a burst of messages. Evidence: ten chat lines in a second got an agent kicked from the server. (02)
Evaluation
What an agent did is only worth knowing if it can be repeated and trusted.
- Keep a baseline with no model in it. It tells you whether a failure is the harness or the model. Evidence: a scripted agent met a goal 5 of 6 times that a small model met 1 of 18: the tools could do it, so the open question was the model. (02)
- Seed, reset and bound by task time, not steps. Runs end when the goal is met, the model stops, or the environment's own time or a dollar cap runs out. Tokens and wall-clock are recorded, never limits: tokenizers differ, and wall-clock measures the hardware. (experiments)
- Log every decision with its exact prompt and answer. It makes replay, costing and re-asking free. Evidence: a stuck moment was replayed to the model 6–8 times with old and new prompts to rule them out as the cause of a loop. (02)
- Read the logs before believing a result, including your own checker's. Evidence: one success was false, from a bug in the goal check; a report counted a teammate saying "I respawned" as a death; 45 of 49 "under water" alarms came from a library reading other creatures' air as the agent's. (02, 05)
- Test changes in the real environment, not only against fakes. Fakes can't model physics, timing or the other side. Evidence: a hand-over that passed every unit test overshot its receiver in four of five live tries.
- Small samples are hints. With three runs, 3 of 3 is consistent with a true rate as low as 44%. Report the interval. (01)
- When a test stops separating, make it harder. Evidence: after the fixes, every model met the one-agent goal 12 of 12; it then measured only cost, so the next test was a team goal. (04)
- Be careful crediting judgement. A fix can remove the trigger for what looked like bad judgement. Evidence: agents stopped leaving their shelters at night once nothing false alarmed them; whether their judgement changed can't be told. (04)
- Know what the model brings before crediting the structure. A model that knows the domain from its training needs only outcomes and tools; one that doesn't needs that knowledge carried in. Evidence: nothing here was trained, and agents used game facts no prompt gave them ("zombies just outside will burn in sunlight shortly", 9 times; "Endermen leave you alone unless you look at them"). Goals that state only the outcome work partly because of that. In a private domain, the tool descriptions and observations have to carry what the model can't already know.
- A cheaper model's ceiling rises with the harness, up to a point; compare prices after fixing the tools. Evidence: teams of three GPT-6 Luna agents never met the whole shared-home goal in any earlier run while our tools were failing them; after those fixes one of three reps met it all for US$0.15, against US$1.36-1.43 for the mixed team's wins. One win in three is a hint, not a rate. (06) Later fixes took the same team to about half, and no further (below).
- When fixes stop moving the rate, test the model. Once the tools are true, what is left of a team's failures is its own judgement, which the harness should report, not coach. A short trial of a stronger model on the same harness then says more than another round of fixes. Evidence: six fixes in a day, each checked against the old code in the real game and each removing a real failure, left three of the cheapest model at 15 of 30 (sets of 7, 4 and 4); 25 of its 27 losses since the last good set ended short of iron pickaxes it had made and then lost in deaths or passed around. Three of a stronger model on the same harness met the goal 20 of 20, at about $1 a success against 28¢. It died as often; it got the team's pickaxes back after a death (11 of 15 times, against 6 of 27), sized its iron to the team, and never haggled. (08)
- Then test taking guidance away. What a weaker model needs, a stronger one may not: each piece of help is a condition to test, not a default to keep. Evidence: with the list of what the goal still lacked switched off, the stronger team still met it 10 of 10, as fast as with it (median 30 minutes of game time against 33). (08)
- Measure cost per outcome, not per call. The same one-day task cost about 1 cent a run on one model and 13–22 cents on others; prompt caching cut 81–86% of input on the models that support it, and one model's prompt was below its caching minimum and never cached. (04, 05)
The improvement loop
How the structure around the agents gets better, run after run.
- Run the agents on a goal, with nothing in their prompt about how to reach it.
- Read where they got stuck, with three things side by side: what the agent was told, what it reasoned, and what really happened.
- Sort each stuck point: a tool failed or misled it; it lacked information a person in its place would have; or it was its own judgement.
- Change only the first two, and check the fix in the real environment. Judgement is left alone and reported: coach it away in the prompt and you measure the coaching.
- Run again, and see whether the agents get further.
Evidence: the same mixed team went from one or two parts of a four-part goal to three, and its failed decisions fell from about 93 a rep to 52–58, on fixes to tools and information alone (06). Every fix so far, beside the same problem in real systems that use agents, is in 06's table.
One run finds the next failure, not the rate. With a fix after each run, almost every run turned up a different failure, and the goal stayed out of reach while they were being found. Evidence: nine overnight reps of three Lunas, each on the fixes from the one before: a new failure in almost every rep, about half of them in our code; the whole goal was met only in the last, which says the fixes allow a win, not how often (06). The rate came from freezing the code: five reps of three Lunas on one unchanged commit met the whole goal in 4 of 5, where reps with fixes between them had won 4 of 14 on the same world (07). Two sets of ten on one later commit met it in 7 and 8: a single set of five, or even ten, is a wide estimate, and a run of five wins in a row came inside the set that scored 7 (07).
Then pool the failures across runs, and sort each by what could still have been done. One run's failure tells a story; the same kind of failure gathered from every run tells which story is common. Put every instance side by side with what the agent knew, what state it was in and what the tool did, then ask of each: was it already lost when the agent decided, did our tool decide it, or was it the agent's own choice? Only the middle group is a fix for the harness; the first is about acting sooner, and the last is behaviour to report. Hunches about the runs get the same test before anything is built on them. Evidence: across 25 reps, 48 of 60 deaths came while the agent was running away, which read as one problem. Sorted, 26 of those agents were near death before the escape began (13 died while the model was still choosing it); 17 had most of their health and were killed by how the escape tool behaved underground, where it died in 10% of uses against 4.5% in the open, because a helper could not find a floor under a low ceiling and sent them straight away at any height, into rock and down caves. The tool was changed; the late decisions were left alone. The same pooling showed the agents never once stored their most valuable material where a death could not take it (0 of 850 decisions considered it): their own choice, reported, not coached. And a hunch that early runs in a series won more (3 of 7 against 1 of 8) turned out to be about a one-in-four chance, with every world checked as reset the same (06).
What is left alone. Answering requests but not needs, one agent carrying everything, status chatter: these are the agents' own behaviour. In organisations they are handled by how work is routed (tickets, a shared view of what's open), and here they can be tested as separate conditions, not made defaults.
Further
- Limitations: what the agents can't do, and what the numbers can't show.
- Skills: the tool set, with how each tool fails.
- How agents communicate: messages, requests and questions between agents.
- Running experiments: batches, conditions and fair comparisons.