AI Agents That Write Their Own Tools: How LLMs Leveled Up Game Completion Efficiency

    This article reviews a fully automated game benchmark in which two generations of LLM-driven agents played the same turn-based RPG under identical emulator conditions, save state, and prompt constraints. The newer generation collected all 16 badges using roughly half the tokens and turns of the previous generation, which stalled at 4. The analysis breaks down the underlying capabilities the test exposed: externalized memory for long-horizon tasks, self-authored tooling to bypass input throttling, multimodal cross-validation when structured state is incomplete, and multi-stage resource strategies for unfavorable matchups. It closes with a reusable engineering checklist covering memory externalization, tool self-registration, layered constraint enforcement, multi-source arbitration, budget governance, and reproducibility. Readers will find practical guidance on agent architecture, sandbox protocol design, and evaluation focus for autonomous agents.

    1. Experiment Background: A Same-Environment, Cross-Generation Comparison

    An industry research foundation ran a fully automated game matchup, pitting two generations of large language model (LLM) agents against each other in an identical simulator environment, with the same save point and the same prompt constraints. Each agent had to complete a classic turn-based role-playing game independently. The only variable was the model generation.

    The results were stark. The previous-generation agent had collected only 4 gym badges when its test budget ran out. The new-generation agent collected all 16 badges, defeated the Elite Four and the Champion, and then took on a hidden post-game boss, all while consuming roughly half the tokens and turns. According to the officially disclosed figures, the newer generation progressed at least twice as fast overall; once “turns per badge” is factored in, the relative efficiency gap widens to several times over.

    The value of this kind of experiment is not “who plays games better.” It compresses several foundational agent capabilities into a quantifiable, reproducible sandbox: long-horizon planning, state tracking, tool building, and failure recovery. Each is unpacked below.

    2. Removing the Training Wheels: Making Agents Work Like Researchers

    To keep the comparison fair, the organizers deliberately removed common assistive mechanisms: no task list, no map navigation hints, and no guidance on where to go next. The prompt did not ask the agent to “finish as fast as possible” either. Instead, it required a scientific approach: treat every judgment about game mechanics as a hypothesis to be verified, and do not assume prior knowledge holds.

    The setup also opened up an unstructured notepad capability, letting the agent freely record hypotheses, design controlled experiments, and track progress. This may look simple, but it externalizes working memory. The biggest failure mode in long tasks is losing critical information to context compression, and a repeatedly readable and writable external note is effectively a layer of persistent state for the agent.

    The engineering takeaway is direct: if your agent has to span multiple turns and stages, give it a writable external memory store first, rather than endlessly extending the context window.

    3. Self-Written Drivers: Treating Environment Constraints as Engineering Problems

    For stability reasons (to avoid simulator desynchronization), the test environment banned mixed key input: an agent could not trigger multiple keys simultaneously or consecutively within a single interaction. For the previous-generation model, this was nearly a hard wall. Giving a Pokémon a nickname requires character-by-character input, and single-key mode is extremely inefficient, so a large share of the budget went to mechanical operations.

    The new-generation agent’s handling is worth recording. Instead of repeatedly tweaking the same failing code, it reassessed the environment’s capability boundaries and found that the “custom tool” path was not subject to the mixed-input restriction. It then wrote its own tool to batch input sequences, packing long key sequences locally and executing them together. In effect, it wrote itself a driver layer that bypassed the throttling at the interaction layer.

    Two conclusions follow. The first is behavioral: when facing failure, determine whether the method is wrong or the channel is restricted, because the response strategies are completely different. The second is about design: every sandbox has capability boundaries and implementation seams. If your evaluation goal is to measure an agent’s engineering creativity, you do not need to weld every seam shut; if your goal is to measure stability, you must enforce atomicity and rate checks at the protocol layer rather than relying on prompt constraints.

    Illustrative constraint-validation logic:

    1. def validate(action, last_ts):
    2. # Atomicity: only one semantic action allowed per interaction
    3. if action.kind == "key_combo" and not action.atomic:
    4. return Reject("combined_input_not_allowed")
    5. # Rate: limit interactions per unit time to prevent local batching bypass
    6. if now() - last_ts < MIN_INTERVAL:
    7. return Reject("rate_limited")
    8. return Accept()

    4. Multimodal Input: Reading the State That Isn’t in Memory

    The eighth gym is an ice-type puzzle level: you have to push boulders down from the upper floor to pave a path across lava ground. The agent got stuck in a loop because the memory values it relied on had no field for “boulder has dropped,” and a leftover decoy boulder on the second floor deepened the misjudgment: numerically the puzzle looked unchanged, but visually it had already changed.

    The new-generation agent ultimately used visual input to confirm the state, cross-checking “screen evidence” against “numerical evidence” to break out of the loop. This exposes a common problem: structured state (memory, variables, database fields) is only a projection of the environment’s ground truth, and any quantity that isn’t modeled becomes a blind spot in the agent’s cognition.

    The practical recommendation is to explicitly separate two kinds of observations in your agent architecture: readable and writable structured state, and read-only raw observations (screenshots, logs, audio). When the two conflict, use the raw observation as the arbiter, and record the conflict itself as a hypothesis to be tracked.

    5. Long-Horizon Battles: Writing Resource Management as an Executable Strategy

    The final battle pitted the agent against a hidden boss with a level advantage. The new-generation agent designed a multi-stage attrition plan: use continuous recovery to offset the opponent’s output, use stat reduction to lower the opponent’s threat, and combine consumables with a revival mechanism to form a loop. This dragged an almost unwinnable quick match into a seven-hour grind and eventually secured the win.

    The general form of this strategy is “if you can’t win, aim not to lose; if you can’t lose, wait for the opponent to change.” When the expected payoff of a single engagement is negative, change the objective function from “win this turn” to “maximize sustainable turns,” and continuously collect the opponent’s behavioral distribution during that time. The lesson for engineering systems is that when capacity or permissions are clearly mismatched, the right move is often to design retry budgets, backoff curves, and fallback paths, rather than increasing the intensity of a single request.

    6. A Reusable Implementation Checklist

    • Externalize memory: provide a readable and writable note or a state file in object storage for long tasks, reducing information loss from context compression.
    • Build tools yourself: allow the agent to register custom tools inside a controlled sandbox, and pair it with a logging service that records every tool call for traceability.
    • Layer constraints: separate “prompt-layer suggestions” from “protocol-layer enforcement”; critical invariants must be validated at the protocol layer.
    • Arbitrate across sources: when structured state conflicts with raw observations, defer to the raw observation and trigger a hypothesis review.
    • Govern budgets: set token and turn caps for each stage, with monitoring and alerts, to avoid a single long tail dragging down overall cost.
    • Ensure reproducibility: fix random seeds, containerize the environment, and retain full interaction traces so conclusions are auditable.

    7. Conclusion

    What this matchup really demonstrates is a shift in the center of gravity of agent capability: from “producing the correct answer” to “reshaping the environment to obtain the answer.” When a model can write its own tools, keep its own books, and design its own controlled experiments, the focus of evaluation should also move from outcome scores to process quality: whether constraints were broken reasonably, whether hypotheses were revised in time, and whether failures were attributed effectively. For developers, this is both a capability dividend and a starting point for a governance checklist.