How a 9B Small Model Can Drive a Self-Evolving Agent Framework
This article breaks down a self-evolving agent framework in which a 9B-class small model handles high-frequency decisions while most of the compute budget goes to code execution and validation. It explains the three-layer architecture (state, decision, execution), how a shared search state turns experiments into a searchable archive where failures are first-class records, two complementary policy-learning mechanisms based on KL-UCB and policy memory, a research workflow with Proposer and Worker roles for structural changes, and a WorkSpace for reusing validated assets. It also covers practical implementation points and common pitfalls such as budget constraints, layered validation, and memory staleness.
1. The Starting Problem: Why “Being Able to Write Code” Is Not “Being Able to Evolve”
In scenarios where agents take on automated coding and experimentation tasks, a long-standing contradiction remains: a model can generate runnable code but struggles to decide what to change next. Most solutions frame the loop as “generate, run, score, regenerate,” which is essentially random-restart local search. It lacks structured memory of history and lacks an explicit decision about whether to explore or exploit. As a result, the experiment budget is consumed by repeated failures, and the returns curve flattens quickly.
Another counterintuitive point concerns compute allocation. The industry commonly assumes that stronger is always better, so the most expensive model is placed in the decision seat. But in tasks like continual evolution, the decision action itself is a high-frequency, short-context, highly patterned call; what really consumes compute is code execution and validation. Handing decisions to a small model on the order of 9B parameters and leaving the budget for execution and evaluation often yields a higher return per unit of cost. This is the core idea behind a small-model-driven continual evolution framework.
2. Framework Overview: A Three-Layer Structure
The framework can be abstracted into three layers:
- State layer: maintains a shared search state that serves as the single source of truth for the whole system;
- Decision layer: a small model acts as the decision maker, using the state to choose which version to keep optimizing and which route to take;
- Execution layer: contains a regular patching channel and a structural-modification channel, responsible for turning decisions into verifiable code changes.
The three layers are decoupled through “write to state” and “read from state,” so any layer can be replaced independently and scaled horizontally.
3. Shared Search State: Turning Experiments into a Searchable Archive
The shared search state is not a log but a continuously updated experiment archive. It typically contains at least five kinds of information:
- Code version snapshots and their metadata (corresponding task, generation time, source strategy);
- Evolution relationships between versions, forming a directed lineage graph that can answer “which version and which change produced this version”;
- The result of each experiment, including whether validation passed, which stage the failure occurred in, and resource consumption;
- Unexplored directions, i.e., the frontier set;
- Remaining experiment budget, which participates in decisions as a global constraint.
The key design here is that “failure is a first-class citizen.” Failure records must carry a structured cause (compilation error, failing test, unmet performance target, timeout); otherwise the decision maker cannot distinguish “the idea was wrong” from “the implementation was wrong.” The lineage structure gives the system the ability to backtrack: when an entire branch does not work out, it can fall back to the branch point and take another path instead of starting from scratch.
From an engineering standpoint, this state needs concurrency safety and persistence: when multiple workers run in parallel, use version numbers or optimistic locking to avoid write conflicts, and periodically persist to durable storage such as object storage, with logging and monitoring/alerting services to observe experiment throughput and failure rates.
4. Decision Mechanism: Two Complementary Policy-Learning Paths
The decision layer must answer two questions: which historical version to continue from, and which action to take. The framework offers two complementary mechanisms.
4.1 Confidence-Bound-Based Policy Learning
This uses a KL-UCB-style method that treats each candidate direction as an arm and ranks them by “observed average return plus an uncertainty upper bound.” Compared with naive UCB, the KL form makes looser assumptions about the return distribution and gives a tighter bound under bounded rewards, making it suitable for experimental settings with highly dispersed results. It naturally achieves the exploration-exploitation tradeoff: directions with good long-term performance are prioritized, while directions sampled fewer times still keep a chance of being tried.
Illustrative logic:
def select_arm(stats, total, c=1.0):# stats[arm] = (success, trials)best, best_score = None, -1.0for arm, (s, n) in stats.items():if n == 0:return arm # unexplored directions get one chance firstp = s / nbonus = upper_bound(p, n, total, c) # KL upper boundif p + bonus > best_score:best, best_score = arm, p + bonusreturn best
4.2 Memory-Based Policy Learning
The second path distills effective experience into a policy memory. It records not just “success/failure” but structured entries in the form of triples: applicable conditions, specific guidance, and historical effect statistics. As new experiments accumulate, entries are reinforced (weight increases when successfully reused), revised (conditions narrowed or guidance refined), or retired (no longer applicable over the long term).
The relationship between the two mechanisms is this: the confidence bound decides “what to try in the short term,” while policy memory decides “how to act in the long term.” The former is stateless and fast; the latter is stateful, explainable, and transferable across tasks.
5. When Patching Fails: A Research Workflow and Role Division
If the system itself has a capability gap, changing code only within the existing framework brings marginal returns. This calls for a structural-modification channel, i.e., a research workflow, that replaces monolithic decision making with role division:
- Proposer: analyzes the task definition, the existing execution framework, and historical experiment results, locates capability gaps, and proposes new mechanistic solutions (for example, adding new validation methods, adjusting how context is organized, or introducing new candidate generation strategies);
- Worker: turns the solution into code, completes implementation, debugging, and testing, and writes the execution result back to the state along with failure details.
The value of role separation lies in context isolation: the Proposer focuses on “what to do” and the Worker focuses on “how to make it run,” avoiding attention dilution caused by doing both divergent thinking and detail-level debugging in the same context. Multiple Proposers can produce candidates in parallel, which the decision layer ranks with the same UCB logic before dispatching.
6. WorkSpace: Making Successful Experience Reusable
Accumulating experience requires an independent workspace that does three things: stores validated code snippets and utility functions; maintains policy memory entries; and provides a retrieval interface so that a new task first checks “is there already a reusable asset” at the start. Retrieval usually combines task-description vector similarity with structured tag filtering: narrow the scope by tags first, then rank by similarity. To avoid experience pollution, content entering the workspace must pass a validation gate and come with a description of its source and applicable boundaries.
7. Implementation Points and Common Pitfalls
- The budget is a hard constraint: write the remaining budget explicitly into the state so the decision layer can automatically switch between “digging deeper into one branch” and “casting a wide net”;
- Validation should be layered: static checks, unit tests, and end-to-end validation filter progressively, with cheaper checks run earlier;
- A small model needs strong constraints: replace long-chain free-form reasoning with clear state summaries, strict output formats, and tool-calling interfaces;
- Prevent memory ossification: give policy entries a validity period and invalidation conditions, and recheck them periodically with new data;
- Prioritize observability: experiment throughput, the distribution of failure causes, and the exploration ratio should all be measured, with monitoring, alerting, and logging services used to locate the cause of stagnation.
8. Conclusion
The takeaway of this framework is not that “a small model is always stronger,” but that in continual evolution tasks, the ceiling is determined by the quality of state representation, the decision mechanism, and experience accumulation, rather than the model size of a single call. Only by leaving expensive compute for execution and validation, handing high-frequency decisions to a constrained small model, and using structured memory to turn the success or failure of each experiment into a reusable asset can a truly sustainable improvement loop be formed.
