Imagine you’re trying to fix a complex machine. You could tweak the instruction manual (the prompt), or you could replace a single gear (a tool wrapper). But what if the problem is that the sensor at the front of the machine needs to tell the motor at the back to slow down? Fixing that requires changing both parts simultaneously so they can talk to each other.
This is the core insight behind HookEvo. While most research focuses on optimizing either the "brain" (the LLM) or the "manual" (the prompt), HookEvo focuses on evolving the harness—the code-based nervous system that connects the AI to its tools and environment.
TL;DR
HookEvo is a framework that allows AI agents to "self-evolve" by rewriting the code that manages their own execution lifecycle. By allowing an improver model to make coordinated changes across different stages of a task—like teaching an agent to record a fact from a tool and use it later to gate a specific action—it achieves state-of-the-art performance even with relatively small models.
What Problem Does This Paper Address?
Tool-using agents don't live in a vacuum; they operate within a "harness" that interprets tool results, assembles the model's context, and checks actions before they are executed.
The authors argue that current optimization methods are too narrow. They usually focus on one piece at a time: just the prompt, or just a single tool's code. However, many agent failures are "interdependent." For example, an agent might fail a shopping task because it forgot to select an option before checking out. Fixing this requires a two-part change:
- A "post-tool" handler to record which options were selected.
- A "pre-tool" check to block the checkout action if that record is empty.
If you try to evolve these separately, the first change doesn't improve the score (so it's discarded), and the second change fails because the data it needs doesn't exist yet. HookEvo solves this "chicken-and-egg" problem by allowing coordinated edits.
Methods
HookEvo uses an evolutionary loop to refine agent harnesses. It’s built on the DeepSeek Harness (DSH), which provides "hooks" into the agent's lifecycle (like Post-tool, Context, and Pre-tool).
The process works in rounds:
- Observe: The system runs the current agent on a batch of tasks and collects execution traces.
- Diagnose: A high-capability "improver" model (like GPT-4o) analyzes the traces of failed tasks to figure out what went wrong.
- Propose: The improver suggests a "scoped patch." This isn't just a prompt change; it can be a Joint Composition (Scope C) that includes new executable code and shared state logic.
- Evaluate & Retain: The new candidate is tested against the old version. If it performs better and actually changes the agent's behavior, it becomes the new "parent" for the next round.
Datasets
The authors evaluated HookEvo across four diverse benchmarks:
- ALFWorld: Household tasks (e.g., "put a clean sponge in the cabinet").
- DBBench: Database and SQL manipulation tasks.
- WebShop: Navigating an e-commerce site to find and buy specific items.
- OSBench: Using a shell to perform filesystem operations.
Key Insights and Ideas
- Coordination is the Secret Sauce: The jump from "Scope A" (just editing the prompt) to "Scope C" (coordinated code edits) was massive. For their best improver, "Sol," the success rate soared by nearly 26 percentage points when it was allowed to make these joint changes.
- Shared State Matters: By giving different hooks access to a shared "episode state," the agent gains a form of short-term memory that is more reliable than just stuffing everything into a long prompt.
- The "Improver Gap": Not all models are good at being "engineers." While the strongest model (Sol) thrived with the complex "Scope C" edits, weaker models actually performed worse when given too much freedom, suggesting that harness evolution requires high-level reasoning.
Key Results
Using a frozen Qwen3-4B (a relatively small model) as the "executor," HookEvo produced harnesses that outperformed much larger models and previous state-of-the-art methods:
- ALFWorld: 95.41% success rate.
- DBBench: 70.56% success rate.
- WebShop: 48.17% success rate.
- OSBench: 41.67% success rate.
In many cases, these results beat the performance of models like GPT-4 or much larger Qwen variants that were using standard, non-evolved harnesses.
Limitations and Future Work
- Search Budget: Evolution is computationally expensive. Each round requires running dozens of tasks to evaluate a single candidate.
- Data Sensitivity: The authors noted that how training data is allocated (fixed pools vs. rotating batches) affects the results, but they haven't fully mapped out the optimal strategy yet.
- Future Directions: The team wants to explore letting the improver model choose its own edit scope for each proposal and investigate more deeply how the interaction between different handlers (reading vs. writing state) specifically drives success.
Summary updated