ContextEvolve: Multi-Agent Context Compression for Systems Code Optimization

TL;DR

ContextEvolve uses three agents to compress optimization context, improving ADRS performance by up to 33.3% while cutting tokens by 29.0%.

cs.LG 🔴 Advanced 2026-02-02 33 views
Hongyuan Su Yu Zheng Yong Li
large language models systems code optimization multi-agent systems context compression reinforcement learning

Key Findings

Methodology

ContextEvolve decomposes parameter-blind code evolution into three orthogonal dimensions. The Summarizer Agent converts parent summaries and offspring code into compact semantic state; the Navigator Agent analyzes metric-weighted trajectories and produces textual optimization directions; and the Sampler Agent retrieves relevant, diverse, high-performing exemplars. A Generator combines these artifacts, an evaluator assigns fitness, and the resulting code, score, and summary enter the Evolve Buffer. The design is functionally aligned with state representation, policy-gradient guidance, and prioritized experience replay.

Key Results

  • Across ADRS tasks—Transaction Scheduling, SQL Optimization, Load Balancing, Sparse Attention Kernel, and Model Placement—ContextEvolve exceeds the strongest baseline by an average 6.5%; the abstract reports up to 33.3% improvement. On Load Balancing, Balance rises from 0.25 to 0.34, Speed from 0.45 to 0.65, and the combined score from OpenEvolve’s 0.15 to 0.20.
  • Its combined scores are 36.10, 0.79, 0.20, 0.586, and 24.02 for TS, SQL, LB, SAK, and MP. Against OpenEvolve’s 33.56, 0.72, 0.15, 0.591, and 22.67, it wins four of five tasks, with only a slight SAK deficit. Token use falls 17.3% on average and nearly 30% on complex LB.
  • Removing the Summarizer, Sampler, or Navigator reduces average performance by 9.3%, 6.0%, and 2.9%, respectively. Best-so-far updates occur 83.3% more frequently than for baselines; while baselines stagnate after roughly 60 iterations, ContextEvolve reports a 22.4% breakthrough.

Significance

The work addresses a central bottleneck in LLM-based systems research: plausible code is easy to generate, but reliable, faster code requires long, expensive feedback loops. It shows that API-only access need not imply unguided mutation. By separating memory into semantic state, search direction, and demonstrations, the framework reuses feedback without weight updates. Academically, it offers a useful bridge between evolutionary LLM search and reinforcement learning. Industrially, it promises lower context cost for database, scheduling, kernel, and distributed-systems optimization, provided that executable evaluators and correctness tests are available.

Technical Contribution

The principal contribution is a structured context-compression operator Φ rather than naive history truncation. Candidates follow ct∼Mθ(·|Φ(Ht),D), with the objective of maximizing the best score over T iterations. The Summarizer preserves functional invariants and design changes; the Navigator uses Δs and improvement, fluctuation, and decline trajectories to produce textual gradients; the Sampler conditionally retrieves informative exemplars. The paper formalizes functional correspondences to Encoder, ∇θEτ[J(τ)], and prioritized sampling PS(Br), creating an RL-like, off-policy search process while keeping θ frozen.

Novelty

The novelty is not simply using multiple agents or evolutionary code search. It is the explicit orthogonalization of optimization context into semantic state, direction, and experience distribution, with one agent responsible for each. Unlike OpenEvolve’s raw-code concentration and GEPA’s reflective mutation with Pareto selection, ContextEvolve separates what must be remembered, where search should move, and which examples should guide generation. Its RL analogy is functional rather than a claim of true parameter learning.

Limitations

  • The evaluation covers only five ADRS scenarios and uses Qwen3 for all LLM components. Generalization to other models, providers, programming languages, hardware platforms, and larger repositories remains unverified.
  • The RL correspondence does not involve actual parameter gradients, policy updates, or convergence guarantees. The paper also does not fully quantify latency, dollar cost, or the effect of more than three times as many API calls.
  • Navigator and Sampler depend on LLM judgments about causal code changes and noisy metrics. Incorrect summaries, unstable evaluators, or non-stationary objectives could reinforce misleading directions or local optima.

Future Work

Future studies should test cross-model and cross-language transfer, calibrate trajectory weights, measure summary faithfulness, and optimize exemplar diversity automatically. Integrating static analysis, compiler feedback, hardware counters, and formal regression tests could improve safety. The community should also compare parallel scheduling, caching, and agent-call budgets in real dollar costs, and develop theory connecting textual-gradient quality, context budget, and expected search improvement.

AI Executive Summary

Systems code optimization rarely ends with a plausible first draft. A candidate must remain correct while improving latency, throughput, balance, memory use, or deployment success across repeated tests. LLMs can propose code, but raw evolutionary histories quickly overwhelm a finite context window. Test-time reinforcement learning is attractive yet requires parameter updates unavailable through most APIs; AlphaEvolve/OpenEvolve and related training-free methods avoid that barrier but often repeat mutations or waste tokens.

ContextEvolve reorganizes the search memory rather than the model weights. Its Summarizer Agent turns parent–offspring code differences into compact semantic state. Its Navigator Agent studies successful, fluctuating, and declining trajectories to produce textual optimization guidance. Its Sampler Agent selects relevant, diverse, high-value exemplars. A Generator then combines the parent, guidance, and exemplars, while an evaluator scores the offspring and returns it to the Evolve Buffer. The authors interpret this as a textual counterpart of state representation, policy-gradient direction, and prioritized experience replay.

On five ADRS scenarios—Transaction Scheduling, SQL Optimization, Load Balancing, Sparse Attention Kernel, and Model Placement—the method achieves combined scores of 36.10, 0.79, 0.20, 0.586, and 24.02. It improves over the strongest baseline by an average 6.5%, with the abstract reporting up to 33.3% improvement and 29.0% lower token consumption. In Load Balancing, the score rises from OpenEvolve’s 0.15 to 0.20; removing the summarizer, sampler, or navigator reduces performance by 9.3%, 6.0%, or 2.9%. The framework is promising, but its RL analogy is functional rather than a true gradient method, and broader models, tasks, costs, and reliability tests remain necessary.

Deep Analysis

Background

AI-Driven Research for Systems (ADRS) applies LLMs to databases, networking, distributed systems, and kernels. Because one-shot code is often incorrect or slow, modern systems use evaluator-driven iterative search. AlphaEvolve/OpenEvolve and GEPA improve candidates through feedback, but raw-history prompting wastes context and reflective mutation does not explicitly separate semantic memory, directional evidence, and exemplar distribution. ContextEvolve targets this missing structure.

Core Problem

Given task D, frozen model Mθ, evaluator E, and history Ht={(ci,si)}, the goal is to maximize the best E(ci) within T iterations. The challenge is not merely generation: code is high-dimensional and redundant; multi-metric changes are noisy; recent examples may omit valuable older discoveries; and every mutation must preserve correctness. Finite context therefore creates a search-efficiency bottleneck.

Innovation

  • ��Orthogonal decomposition: semantic state, optimization direction, and experience distribution. •Specialized agents: Summarizer preserves code meaning, Navigator extracts trajectory-level guidance, and Sampler retrieves useful demonstrations. •RL functional alignment: the three roles correspond to encoding, policy-gradient estimation, and prioritized replay without changing weights. •Token utility: compact abstracts and curated exemplars replace indiscriminate raw-code concatenation.

Methodology

  • ��Initialization: the Evolve Buffer stores (c,s,z), code, score, and semantic summary. •Parent selection: choose cp and zp from the buffer. •Direction extraction: Navigator analyzes trajectories weighted by Δs=sparent−schild and categorizes improvement, fluctuation, and decline. •Experience retrieval: Sampler conditions on zp and gt to produce relevant, diverse Ectx. •Generation: Generator samples ct∼Mθ(·|Φt). •Evaluation and update: E returns sc; Summarizer compares parent and child to produce zc; the tuple is added for future selection and analysis.

Experiments

The benchmark contains five ADRS scenarios: Transaction Scheduling, SQL Optimization, Load Balancing, Sparse Attention Kernel, and Model Placement. TS, SQL, SAK, and MP run for 100 iterations; LB runs for 300. Baselines are Heuristics, Human-SOTA, LLM One-shot, GEPA, and OpenEvolve, an open-source AlphaEvolve implementation. Qwen3 serves all LLM components. Evaluation reports domain-specific metric pairs, weighted combined scores, best-so-far trajectories, cumulative tokens, and ablations removing each context agent.

Results

ContextEvolve obtains 36.10, 0.79, 0.20, 0.586, and 24.02 on TS, SQL, LB, SAK, and MP. OpenEvolve obtains 33.56, 0.72, 0.15, 0.591, and 22.67, so ContextEvolve wins four tasks but is slightly lower on SAK. LB Balance improves by 36%, best-so-far updates are 83.3% more frequent, and complex LB consumes nearly 30% fewer tokens. Ablations identify the Summarizer as most important, followed by Sampler and Navigator.

Applications

The framework can search database queries, transaction schedulers, load-balancing policies, sparse-attention GPU kernels, and model-placement configurations. It requires an executable evaluator, reliable correctness tests, measurable objectives, a sandbox, and LLM API access. In industry, it is best positioned as an offline candidate generator whose outputs pass regression tests, safety checks, and expert review before deployment.

Limitations & Outlook

Performance depends on evaluator quality, summary faithfulness, and the model’s ability to infer causal relationships from noisy metric changes. Multi-agent orchestration uses more than three times as many API calls, although it lowers total tokens; latency and monetary cost are underreported. Five benchmark scenarios and one foundation model do not establish universality. The RL analogy supplies conceptual structure, not actual gradients, convergence, or optimality guarantees.

Plain Language Accessible to non-experts

Imagine a restaurant trying to improve one recipe over hundreds of tastings. The ordinary approach keeps every old recipe, comment, and failed experiment on the table. Soon the table is crowded, the chef forgets what matters, and the same bad idea returns.

ContextEvolve hires three assistants. The first reads the new recipe and writes a short memory: what must stay, what changed, and what the dish is trying to achieve. The second compares many tastings and says which kinds of changes usually improved the score, which produced mixed results, and which repeatedly failed. The third searches the archive for a few relevant and successful recipes, rather than dumping the whole archive in front of the chef.

The chef combines these three kinds of advice, cooks a new version, and sends it to a strict tasting panel. Only the measured result and a new concise memory go back into the archive. In the paper, the recipes are systems programs and the tasting panel is an automated benchmark. The approach usually finds better versions with fewer written instructions, but it can still be misled by bad judging, incomplete memories, or unusual dishes.

ELI14 Explained like you're 14

Imagine upgrading a game character. Your AI teammate can rewrite the character’s equipment code, but every upgrade must survive a training arena. After many rounds, the backpack fills with old builds, failed attempts, and repeated advice. The AI starts missing the useful clues—annoying, right?

ContextEvolve adds three teammates. The first is the “highlight editor”: it turns a huge build into a short note about what changed and what must not break. The second is the “map reader”: it studies which upgrades raised or lowered the score and points toward promising moves. The third is the “loot curator”: it picks a few useful, different, high-scoring builds as examples. The main AI then creates the next build and tests it.

In five ADRS challenges, including scheduling, SQL, load balancing, attention kernels, and model placement, the method generally beats other automatic search systems. In Load Balancing, its combined score is 0.20 versus OpenEvolve’s 0.15. The paper reports up to 33.3% better performance and 29.0% lower token use. Remove the highlight editor and average performance drops 9.3%—so remembering the right things matters!

But it is not magic. The AI is organizing instructions, not secretly changing its brain. It also needs many API calls and trustworthy tests. If the judge gives bad scores, the system may confidently chase the wrong upgrade. More models, games—well, real systems—and stronger safety checks are still needed!

Glossary

ContextEvolve

A training-free, multi-agent framework for iterative systems-code optimization. It compresses search context instead of updating the language model’s weights.

The paper’s proposed method.

Summarizer Agent

An agent that converts parent summaries and offspring code into a compact semantic description. It functions like a state encoder in the paper’s RL analogy.

Maintains semantic state and removes redundancy.

Navigator Agent

An agent that examines trajectories and score changes to generate textual improvement directions. Its output is analogous to a policy-gradient signal, not a numerical parameter gradient.

Maintains optimization direction.

Sampler Agent

An agent that selects relevant, diverse, high-value historical exemplars. It is the semantic analogue of prioritized experience replay.

Builds few-shot context for generation.

ADRS

AI-Driven Research for Systems, a benchmark spanning several systems-code optimization problems. The paper evaluates TS, SQL, LB, SAK, and MP scenarios.

Primary experimental benchmark.

Evolve Buffer

A repository of candidate code, fitness scores, and semantic summaries. It supports parent selection, trajectory analysis, and exemplar retrieval across iterations.

Core memory structure in Algorithm 1.

Open Questions Unanswered questions from this research

  • 1 It remains unknown whether summaries stay faithful across models, programming languages, code scales, and hardware. Future work needs cross-model tests, automatic fact checks, and explicit summary-error measurements.
  • 2 The paper lacks convergence guarantees and a full accounting of API latency and dollar cost. A useful next step is a theory and benchmark relating textual-guidance quality, context budget, calls, and search gains.

Applications

Immediate Applications

Offline database and scheduler tuning

Engineering teams can expose SQL plans, transaction schedulers, and automated benchmarks to ContextEvolve. Candidate implementations should run in a sandbox and pass correctness regression tests before expert review and deployment.

GPU-kernel and placement search

For sparse-attention kernels or model placement, the system can propose code or configurations using latency, density, error, and success metrics. Compilation, hardware counters, timeouts, and rollback protection are essential prerequisites.

Long-term Vision

Autonomous systems-research assistant

A mature version could connect problem formulation, code generation, benchmarking, verification, and technical reporting into one research loop. Major obstacles are invariant checking, cross-hardware transfer, API economics, and reliable causal interpretation of performance data.

Abstract

Large language models are transforming systems research by automating the discovery of performance-critical algorithms for computer systems. Despite plausible codes generated by LLMs, producing solutions that meet the stringent correctness and performance requirements of systems demands iterative optimization. Test-time reinforcement learning offers high search efficiency but requires parameter updates infeasible under API-only access, while existing training-free evolutionary methods suffer from inefficient context utilization and undirected search. We introduce ContextEvolve, a multi-agent framework that achieves RL-level search efficiency under strict parameter-blind constraints by decomposing optimization context into three orthogonal dimensions: a Summarizer Agent condenses semantic state via code-to-language abstraction, a Navigator Agent distills optimization direction from trajectory analysis, and a Sampler Agent curates experience distribution through prioritized exemplar retrieval. This orchestration forms a functional isomorphism with RL-mapping to state representation, policy gradient, and experience replay-enabling principled optimization in a textual latent space. On the ADRS benchmark, ContextEvolve outperforms state-of-the-art baselines by 33.3% while reducing token consumption by 29.0%. Codes for our work are released at https://anonymous.4open.science/r/ContextEvolve-ACC

cs.LG cs.AI