AI Agents Writing Their Own Tools to Jailbreak Games: A Step Change in LLM Efficiency

    This article examines a fully automated game benchmark in which two adjacent generations of LLM agents competed in the same emulator environment under identical save states and prompt constraints. The newer model cleared all 16 badges, defeated the Elite Four and Champion, and beat a hidden boss using roughly half the tokens and turns of its predecessor, at about one-eighth the wall-clock time. The analysis focuses on three capabilities behind the gap: hierarchical failure attribution across perception, rules, and execution; treating constraints as engineering problems through custom, observable tools; and multimodal state fusion to observe information absent from memory. It closes with a reusable engineering checklist covering methodology-first prompting, externalized memory, tool governance, fixed attribution order, budget and termination conditions, and post-run consolidation. The intended audience is developers building reproducible agent evaluation systems.

    1. Experiment Background: Treating “Playing a Game” as an Agent Capability Benchmark

    A recent fully automated game match hosted by a nonprofit foundation drew attention: two LLM agents from adjacent generations competed to clear a classic turn-based role-playing game in exactly the same emulator environment, with the same initial save and the same prompt constraints. The result was not close. The newer model collected all 16 badges, defeated the Elite Four and the Champion, and additionally beat a hidden opponent that normally requires an extremely high level, using only about half the token consumption and half the number of turns of the previous generation. Converted to time, the previous generation took roughly eight times as long.

    The value of this evaluation is not “who played better.” It is that the setup forms a near-ideal agent stress test:

    • The state space is huge with severe long-range dependencies, so short-term memory cannot cover global progress.
    • Feedback is sparse; many mistakes only surface dozens of steps later.
    • Environment rules are opaque, and prior knowledge may be wrong.
    • The agent is allowed to write its own code, build its own tools, and spawn subtasks.

    The prompt deliberately did not ask the agent to “finish as fast as possible.” Instead, it required the agent to work like a scientist: do not assume prior knowledge about the game is correct, and use an unstructured notepad to record hypotheses, design verification, and track progress. This is critical, because it extends the evaluation target from “task success rate” to “methodology capability,” meaning the closed-loop quality of hypothesis management, experiment design, and conclusion revision.

    2. Capability One: Hierarchical Selection in Tool Trust and Failure Attribution

    One stable behavioral difference in the test: when facing a failure, the newer agent first judged “did I misunderstand the environment, or did I write the code wrong,” rather than repeatedly tweaking the same script. The previous generation was more prone to getting stuck in local struggles with the codebase, showing small-step patching on the same logic and repeatedly triggering the same error.

    From an engineering perspective, this is a question of attribution level. A robust agent should maintain at least three layers of hypotheses:

    1. Perception layer: is the state I read complete, and is there temporal lag;
    2. Model layer: does my understanding of the rules hold;
    3. Execution layer: are my tools and scripts correct.

    When a failure occurs, the correct order is to investigate from the outside in: first falsify perception and rule hypotheses, then touch the execution code. Doing it the other way around raises cost exponentially, because every tweak at the execution layer costs a full round of environment interaction. The following pseudocode fixes this strategy:

    1. def on_failure(ctx, err):
    2. # Outside-in: suspect perception and rules first, then code
    3. if not ctx.sensor_consistent():
    4. ctx.recalibrate_sensors(); return
    5. if ctx.rule_hypothesis_untested():
    6. ctx.design_minimal_experiment(); return
    7. ctx.patch_tool(err); ctx.retry_with_budget()

    Combined with the principle of a “minimal falsifiable experiment” — change only one variable at a time and reproduce via the shortest path — this can significantly reduce wasted turns. The notepad serves as externalized memory here: writing hypotheses, evidence, and conclusions into searchable entries avoids repeatedly overturning oneself during long tasks.

    3. Capability Two: Custom Tools and “Constraints as an Engineering Problem”

    To keep the emulator synchronized and stable, the test environment imposed strict input limits: no mixed key presses, meaning it was not allowed to submit multiple keys simultaneously or consecutively in one interaction. This is a reasonable engineering tradeoff for stability, but it is extremely inefficient for tasks requiring large amounts of repeated interaction (for example, batch confirmation or batch naming).

    The newer agent’s handling was instructive: it did not accept the constraint wholesale. It first verified the boundary of the constraint and found that the custom tool path was not subject to it, so it wrote a batch input sequence tool that packed and executed long sequences locally. Described neutrally, its structure was:

    1. @define_tool
    2. def press_sequence(keys: list[str], interval_ms: int = 30):
    3. """Expand a key sequence locally and emit keys at a fixed interval"""
    4. for k in keys:
    5. emit(k); sleep(interval_ms)
    6. return {"sent": len(keys)}

    The real technical point here is not “bypassing,” but three insights:

    • The applicable scope of a constraint must be confirmed empirically, not inferred from the wording of documentation;
    • When high-frequency repeated operations become the bottleneck, the “interaction protocol” should be abstracted into a reusable tool, rather than repeatedly reminding the model in the prompt to operate carefully;
    • The tool itself must be observable: return the number of deliveries and the failure position, making upper-layer attribution easier.

    A reminder is warranted: in engineering, this kind of practice should be confined to “improving automation efficiency while preserving environment consistency.” In production systems, any “efficiency optimization” that bypasses rate limits or breaks state consistency turns into data pollution and non-reproducible failures. A more robust way to land this is to provide an official batch interface for automated interaction, set idempotency keys and rate quotas, and bring all custom tools into a unified registration, audit, and rollback mechanism.

    4. Capability Three: Multimodal Compensation for Information Absent from Memory

    The eighth gym’s puzzle required pushing a boulder down from upstairs and paving a path on the ground. Relying on memory values alone made it nearly impossible to judge progress, because the fallen boulders were not reflected in readable memory fields; residual decoy boulders on the second floor further aggravated misjudgment, trapping the agent in a “puzzle unsolved” loop.

    The newer model’s advantage was introducing a visual channel: treating the screen as a first-class state source and cross-checking it against memory readings. When the two sources conflicted, it deferred to the side that was “repeatably observable and could explain the difference,” and recorded the conflict itself as a hypothesis to be verified. In engineering terms, this abstracts to dual-channel state fusion:

    1. state = {
    2. "mem": read_memory(), # structured, precise, limited coverage
    3. "vision": detect_objects(), # unstructured, broad coverage, noisy
    4. }
    5. if conflict(state):
    6. log_hypothesis("channel conflict", evidence=state)
    7. state = run_disambiguation_probe(state) # design a minimal experiment to decide

    From this we can extract a general principle: an agent’s state observability determines its ceiling. Any state change that does not exist in memory or logs but truly happens in the physical world must have a corresponding perception channel; otherwise, even the strongest reasoning is only doing work on incomplete information. Multimodality, logs, metrics, and distributed tracing are isomorphic in value on this point.

    5. A Reusable Engineering Practice Checklist

    • Write “methodology” rather than “steps” at the prompt layer: require explicit hypotheses and falsifiable conclusions, and forbid treating priors as facts.
    • Externalize memory: a structured notepad or knowledge entries recording hypothesis-evidence-conclusion triples, supporting retrieval and rollback.
    • Tool registration and governance: custom tools must be registered, rate-limited, idempotent, and auditable, with clear applicable boundaries.
    • Fix the failure attribution order as perception → rules → execution, and use minimal falsifiable experiments to control trial-and-error cost.
    • Multi-channel state fusion: structured readings and unstructured perception validate each other, with conflicts explicitly recorded.
    • Budget and termination conditions: set caps on tokens, turns, and wall-clock time to avoid idle looping in long tasks.
    • Productize retrospectives: consolidate successful strategies into a reusable skill library for direct invocation in later tasks.

    6. Conclusion

    What this match truly reveals is a shift in the dimension of agent competition: from “smarter single-step reasoning” to “whether the agent can autonomously build workflows, manage uncertainty, and expand the boundary of its own capabilities.” Tool trust and failure attribution determine trial-and-error cost; custom tools determine the ceiling of automation; multimodal perception determines state completeness. Only when the three stack together does an order-of-magnitude efficiency gap appear. For developers, rather than chasing a single model’s leaderboard score, it is better to build a solid foundation in evaluation environments, tool governance, and observability. On platforms such as Baidu AI Cloud, using a container platform to host the runtime, object storage to save notepads and trajectories, and log services with monitoring and alerting to achieve full-link observability is a general path for building this kind of reproducible agent evaluation system.