Agent-Built Tools for Overcoming Environment Constraints: A Long-Horizon Workflow Analysis
This article analyzes a public experiment in which a new-generation agent completed a long-horizon collection role-playing game under the same simulated environment used by the previous generation. It extracts general engineering lessons for developers: scientific-method evaluation, hypothesis management, tool reuse, self-built batch input tools, multimodal state fusion, long-horizon combat resource management, and auditable workflows. Readers gain a practical framework for assessing and improving agent efficiency, stability, and controllability under environment constraints.
Agent-Built Tools for Overcoming Environment Constraints
In long-horizon, highly interactive tasks with complex state, the core bottleneck for an agent is often not single-step reasoning. It is whether the agent can continuously observe, form hypotheses, design tools, validate results, and control cost within a constrained environment. A public experiment disclosed a representative case: in the same simulated environment, a new-generation agent completed the full flow of a complex collection-oriented turn-based role-playing game, including collecting all 16 level credentials, defeating multiple rounds of high-tier bosses, the final champion, and a hidden boss. When the previous-generation agent had completed only about four level credentials, the new-generation agent had already finished the entire run with roughly half the tokens and turns. By stage estimates, the speed gap in some segments reached about 8x. More notably, the final battle lasted about 7 hours, and the agent reversed the outcome through a combination of passive recovery, stat reduction, attrition tactics, and resurrection loops.
Behind these numbers, what developers should focus on is not “game completion” itself, but the engineering methods the agent used under a constrained action space, long-horizon state tracking, self-built tools, and multimodal perception. This article strips away specific product and game attributes and analyzes the practice path from the perspective of a general agent workflow.
1. Evaluation Setup: Scientific Method Matters More Than Speedrun Prompts
The fairness of the experiment first came from environment consistency: both agents used exactly the same simulated environment, action interface, and observation interface. More importantly, the prompt did not require the agent to finish as quickly as possible. Instead, it required the agent to apply the scientific method, not assume that prior knowledge about the game was necessarily correct, and allowed an unstructured notebook to record hypotheses, test ideas, and game progress.
This setup has two engineering values. First, it reduces contamination from prior knowledge. In long-horizon tasks, a model may make incorrect assumptions based on common sense, such as misjudging that a mechanism has already been disabled or that a resource can be obtained indefinitely. Requiring that “assumptions may be wrong and must be experimentally validated” pulls the agent back from “acting on experience” to a closed loop of observation, hypothesis, experiment, and review. Second, it shifts the evaluation target from single-step accuracy to workflow construction capability. The agent must not only choose actions, but also maintain state notes, design subtasks, evaluate tool effectiveness, and replan after failure.
Therefore, evaluation metrics should include at least: task completion, token consumption, interaction turns, wall-clock time, repeated failure count, tool creation and reuse count, rollback count, and human intervention count. Looking only at “whether the task was completed” hides differences in efficiency and stability; looking only at tokens ignores strategy quality in long-tail battles. Only a combination of metrics can explain the real source of the efficiency gap.
2. Efficiency Gap: Hypothesis Management and Tool Reuse
From the public data, when the new-generation agent completed all level credentials, the previous generation had completed only about one quarter of the progress. The former used about half the tokens and turns of the latter. Overall speed was at least about 2x, and by stage estimates the gap in some segments reached about 8x. This difference cannot be simply attributed to “a larger model.” It should be broken down into three types of engineering gains.
First, hypothesis management reduces ineffective trial and error. The agent used the notebook to record the current goal, known state, hypotheses to be validated, and the reason for the last failure, avoiding repeated mistakes on the same mechanism or the same type of battle. Second, tool reuse lowers action cost. When the agent found that a certain type of input required frequent repetition, it encapsulated low-level actions into a custom tool and called it directly thereafter. Third, subtask decomposition improves long-horizon stability. It split “puzzle solving, collection, leveling, combat, and resource management” into verifiable stages, set completion conditions for each stage, and rolled back only the local part rather than the entire flow after a failure.
It is important to emphasize that the 8x gap should be understood as a stage-based estimate, not a constant multiplier across all stages. Long-tail battles, random events, and complex puzzles often show nonlinear costs. Evaluation reports should disclose tokens, turns, and wall-clock time by stage to avoid misleading single averages.
3. Self-Built Tools: Turning Environment Constraints into Engineering Problems
One of the most instructive behaviors in the experiment was how the agent handled input restrictions. To maintain stability, the test environment prohibited mixed key input; for example, it did not allow action keys and direction keys to be combined consecutively. When the agent needed to perform batch naming or consecutive menu operations, single key presses were extremely inefficient. Rather than fully accepting this constraint, the agent used its tool registration capability to write a “batch key sequence” tool that processed input sequences locally in batches, thereby working around the mixed-input restriction.
From an engineering perspective, this is not simply “exploiting a loophole.” It exposes the problem of constraint governance. Environment constraints can be divided into three categories: hard constraints, such as permissions, security, and resource limits, which must not be bypassed; soft constraints, such as interaction frequency and input format, which can be optimized through batch interfaces; and extensible constraints, such as the lack of certain composite actions, which can be filled in through tool registration. The agent identified “no mixed key input” as an extensible constraint and improved efficiency through a custom tool.
Illustrative pseudocode is shown below:
# Pseudocode: agent registers a batch input tooldef batch_key_sequence(sequence):results = []for key in sequence:results.append(env.press(key))if env.is_blocked():breakreturn resultsif env.single_key_cost > threshold:tool_registry.add(name="batch_key_sequence",handler=batch_key_sequence,audit=True,rollback=True)
In production environments, such capabilities must be paired with permission boundaries, audit logs, and rollback mechanisms. Tool registration should distinguish between “allowed batch optimization” and “unauthorized bypass.” For expected vulnerabilities, evaluators should govern them through constraint allowlists, call auditing, and anomaly detection. For the agent, it should prioritize verifiable and rollback-capable batch tools and avoid breaking environment consistency.
4. Multimodal Perception: State Understanding Beyond Memory Snapshots
The experiment also exposed the limitations of structured memory state. In the level 8 ice-themed stage, the puzzle required pushing a boulder down from an upper layer to pave a path over lava. The memory snapshot did not explicitly record the underlying state change of the “fallen boulder,” and the agent fell into an infinite loop for a time, mistakenly believing that the puzzle had not been solved. A residual decoy boulder on the upper layer further exacerbated the misjudgment.
This shows that long-horizon tasks cannot rely only on memory fields. Structured state is suitable for reading values, coordinates, and flags, but spatial relationships, object occlusion, residual decoys, and dynamic changes in the visual frame are often not present in those fields. The value of multimodal perception is to supplement states that are “not encoded in memory but visually visible.” In engineering, a three-source fusion can be used: memory snapshots provide precise values, screenshots or visual frames provide spatial and visual evidence, and the notebook provides historical hypotheses and action results. When the three conflict, the agent should design validation actions, such as re-observing, trying small-step interactions, or rolling back to a known state, rather than repeating the same action.
5. Long-Horizon Combat: Strategy Composition and Resource Management
The final battle lasted about 7 hours. Facing a level disadvantage, the agent adopted a combination of passive recovery, stat reduction, attrition tactics, and resurrection loops. The key to this type of long-horizon combat is not maximizing single-hit damage, but managing the resource curve: maintaining survival, weakening the opponent, consuming key resources, recovering during safe windows, and restarting the rhythm through resurrection loops after failure.
This can be abstracted into a strategy template: first assess the resource gap and level gap between both sides; then choose debuffs that reduce the opponent’s output or accuracy; extend the battle through passive recovery and attrition; set resurrection and rollback thresholds; and switch to offense when the opponent enters a low-resource state. During evaluation, record per-turn resource changes, strategy switch count, invalid loop count, and recovery window utilization.
6. Deployment Recommendations: Scientific Loop and Auditable Workflow
For enterprise agent deployment, the minimum closed loop that can be borrowed is as follows:
# Pseudocode: scientific-method-driven long-horizon task loopwhile not env.done():obs = env.observe()state = notebook.recall()hypothesis = planner.infer(obs, state)action = planner.choose_test(hypothesis, tool_registry)result = env.step(action)notebook.write(hypothesis, action, result)if result.repeated_failure():planner.rollback_to_last_known_good()tool_registry.review_tools()
It is also recommended to: use object storage to save experiment trajectories and screenshots, use logging services to record hypotheses and test results, and use monitoring and alerting to observe repeated failures and abnormal tool calls; set registration review, permission boundaries, and rollback switches for custom tools; and report completion, cost, stability, and safety together in evaluation. Only by incorporating “self-built tools” into an auditable workflow can agents be both efficient and controllable in complex environments.
