Meta Context Engineering via Agentic Skill Evolution — part 2/4

Cleaned-text code points [15999, 31847). Bibliography omitted here; source.md includes it.

MCE decouples what to learn (the context function c s c_{s} ) from how to represent and learn it (the skill s s ). This decoupling is analogous to separating learned parameters from model architecture and training algorithms in machine learning (ML), except that MCE operates at a higher level of abstraction, where the ML models (LLMs) are already well-trained and frozen. Such decoupling has given rise to fields such as meta-learning, AutoML, neural architecture search, hyperparameter optimization, and meta-black-box optimization. By elevating this decoupling to CE, MCE opens a new design space for optimizing agentic AI.

### 3.2 Meta-Level: Agentic Skill Evolution

The meta-level agent maintains its skill database ℋ k − 1 = { ( s i , c i , J i train , J i val ) } i = 1 k − 1 \mathcal{H}_{k-1}=\{(s_{i},c_{i},J_{i}^{\text{train}},J_{i}^{\text{val}})\}_{i=1}^{k-1} , a folder that summarizes the history of skills, their resulting context functions, and evaluation metrics from all previous iterations. At iteration k k , the meta-agent generates a new skill by performing agentic crossover : s k = Crossover ​ ( τ , ℋ k − 1 ) , s_{k}=\textsc{Crossover}(\tau,\mathcal{H}_{k-1}), (4) where τ \tau denotes the task specification (e.g., task description, data format, evaluation criteria). Agentic crossover is an LLM agent-driven operator that synthesizes a new skill by selectively combining and refining elements from previous skills. Unlike prior LLM-driven evolutionary operators that apply fixed recombination rules (e.g., merging two programs into a better one), it is a flexible and deliberative process: the agent reasons over the task specification, arbitrarily inspects workspace folders, identifies successful and failure patterns, and composes an improved skill.

A skill s ∈ 𝒮 s\in\mathcal{S} is represented as a folder in the base-agent workspace. In practice, we find that it may include, but is not limited to, the following: (1) a methodology describing the learning procedure in natural language (e.g., core philosophy, multi-phase approaches with error analysis, context pruning strategies); (2) executable scripts implementing the methodology (e.g., Python code for error pattern extraction, LLM-based context generation, embedding-based similarity analysis); (3) structured context templates (e.g., decision frameworks, disambiguation rules, gap-driven refinements); (4) validation protocols (e.g., functions to assess context quality and measure generalization); and (5) dynamic context operators such as retrieval functions that selectively filter and compose relevant context based on query features (e.g., keyword-based section extraction, embedding-based similarity matching, rule-based pattern detection for error-prone cases). An example of a learned skill is provided in Appendix C .

Analysis of the evolved skills reveals three key technical advantages. First, we observe that MCE dynamically adjusts autonomy, expressivity, and granularity: learned skills are found to specify rigid workflows or delegate full autonomy depending on the need, enabling either holistic batch-level synthesis or targeted instance-level updates. Second, evolving skills tailor context verbosity to task complexity and model capacity, generating concise rules for simple tasks or capacity-limited models, while providing detailed explanations otherwise. Third, the meta-agent effectively monitors training and validation signals, detects overfitting, and steers skill evolution toward improved generalization. Further analysis are provided in Appendix C and Appendix D .

### 3.3 Base-Level: Fully Agentic Context Optimization

Given skill s k s_{k} from the meta-level, the base-level agent executes it to produce a context function. The agent operates within a workspace containing: (1) its skill folder s k s_{k} , (2) prior best context function c k − 1 ∗ c_{k-1}^{*} (warm-start), (3) training rollouts ℛ k = { ( x i , y ^ i , eval i ) } \mathcal{R}_{k}=\{(x_{i},\hat{y}_{i},\text{eval}_{i})\} obtained by evaluating c k − 1 ∗ c_{k-1}^{*} on 𝒟 train \mathcal{D}_{\text{train}} , and (4) optional utility functions to invoke other AI models ( Appendix E ). The base-agent’s objective is to update the context function by learning from rollout feedback. The process is fully agentic and guided by the current skill : c k = Engineer ​ ( τ , s k , c k − 1 ∗ , ℛ k ) . c_{k}=\textsc{Engineer}(\tau,s_{k};c_{k-1}^{*},\mathcal{R}_{k}). (5)

Here, a context function is instantiated as a collection of files in a designated directory, including both static and dynamic components. Static components ρ \rho may include knowledge bases, decision rules, or examples, while dynamic operators F F may implement retrieval, filtering, or composition logic. The code and file-based representation imposes no structural constraints , enabling arbitrary computational procedures for context generation and manipulation. This stands in contrast to prior methods that specify rigid context representations and optimization workflows.

### 3.4 Algorithmic Orchestration

Algorithm 1 summarizes the iterative MCE procedure. Each iteration consists of three phases: (1) skill evolution , where the meta-agent generates s k s_{k} by analyzing the task specification τ \tau and skill history ℋ k − 1 \mathcal{H}_{k-1} ; (2) context optimization , where training rollouts are programmatically performed and the base-agent executes s k s_{k} to produce context function c k c_{k} ; and (3) evaluation , where c k c_{k} is assessed on the validation dataset to update the skill database and track the best-so-far solution c k ∗ c_{k}^{*} . Training data batching can be optionally adopted for the base-agent when dataset size is large. Overall, the dual-level optimization implements a simple history-informed ( 1 + 1 ) (1+1) -ES : at each iteration, agentic crossover can reference the entire skill history ℋ k − 1 \mathcal{H}_{k-1} ; a single offspring context c k c_{k} is generated and compared against the current best c k − 1 ∗ c_{k-1}^{*} , with the better one retained. While we adopt this strategy for simplicity, more advanced search algorithms may further improve performance.

Both meta and base-level adopt fully agentic optimizations : each agent interacts with a programming environment through a standard tool set 𝒯 \mathcal{T} = { Read , Write , Edit , Bash , Glob , Grep , TodoWrite } and produces outputs by manipulating a file system workspace. The read/write permissions of both agents are strictly scoped according to their respective roles and the current iteration. This design is compatible with modern agentic frameworks such as Claude Agent SDK [ Anthropic, 2025a ] and LangChain DeepAgents [ langchain-ai, 2025 ] , enabling straightforward integration into existing infrastructure. To facilitate programmatic invocation during rollouts and evaluations, we require the base-agent to implement callable interface(s) with predefined input-output signatures; these interfaces can be task-specific and flexibly defined. They are validated upon completion of each base-agent execution.

## 4 Experiments

### 4.1 Experimental Setup

##### Tasks and Datasets.

We evaluate MCE across five benchmarks spanning different domains (financial, chemistry, medicine, law, and AI safety) to demonstrate its versatility and generality. Unless otherwise specified, we adhere to the original train/val/test splits but use data subsets due to computational budget constraints. All experiments use the same datasets in the same order during sequential processing to ensure fair comparison across baselines. We include ground-truth labels for CE methods when applicable. Details of the datasets and data processing are provided in Appendix A . We briefly describe the datasets below. (1) FiNER (Financial) [ Loukas et al., 2022 ] requires labeling tokens in XBRL financial documents with its entity types. We report the pass@1 prediction accuracy. (2) USPTO-50k (Chemistry) [ Schneider et al., 2016 ] requires predicting precursor reactants from product molecules. We report the pass@1 exact match accuracy. (3) Symptom2Disease (Medicine) [ Gretel AI, 2023 ] requires predicting diseases from patient symptom descriptions across 22 disease categories. We report pass@1 prediction accuracy. (4) LawBench (Law) [ Fei et al., 2024 ] is a comprehensive Chinese legal benchmark. We use the criminal charge prediction subtask from LawBench, and report micro-F1 score. (5) AEGIS2 (AI Safety) [ Ghosh et al., 2025 ] requires classifying user prompts as safe or unsafe and identifying specific violation categories. We report the F1 score.

##### Baselines.

We compare MCE against the following baselines. To ensure fair comparisons, we adhere to the suggested implementations in ACE [ Zhang et al., 2026 ] , use the identical initial context or prompt templates, and allow a training budget no less than that used in MCE. (1) Base Model : Zero-shot evaluation using the same prompt as MCE but without learned context. (2) In-Context Learning (ICL) : Provides task demonstrations in the prompt. Following Zhang et al. [2026] , we include all training samples fitting within the context window. (3) MIPROv2 [ Opsahl-Ong et al., 2024 ] : We implement the official DSPy implementation with auto="heavy" . (4) GEPA [ Agrawal et al., 2025 ] : We implement the official DSPy implementation with auto="heavy" and match MCE’s total rollout budget. (5) Dynamic Cheatsheet (DC) [ Suzgun et al., 2025 ] : We use the official implementation in cumulative mode (DC-CU). (6) ACE [ Zhang et al., 2026 ] : We use the official implementation with original parameter settings 1 1 1 https://github.com/ace-agent/ace and run offline training for 5 epochs unless playbook accumulation exceeds the context window or validation performance plateaus.

##### Models.

Following Zhang et al. [2026] , we use DeepSeek V3.1 [ Liu et al., 2024a ] as the default generator (the model performing inference during training and testing) across all methods and benchmarks. For AEGIS2, safety guardrails necessitate lightweight models; we use Qwen3-8B [ Team, 2025 ] as the generator across all methods. The reflector model is consistently set to DeepSeek V3.1. MCE additionally requires an agentic model; we use MiniMax M2.1 [ MiniMaxAI, 2025 ] by default. MCE base-agents are allowed to invoke DeepSeek V3.1 during its execution. All models are accessed via OpenRouter [ OpenRouter, Inc., 2025 ] . In § 4.3 , we show that MiniMax M2.1 does not improve ACE, ruling out knowledge transfer from the agentic model as the source of MCE’s gains.

##### MCE Instantiation.

In experiments, MCE optimizes context for five epochs. We instantiate the MCE agents using the Claude Agent SDK [ Anthropic, 2025a ] . To maintain methodological consistency with CE baselines and enable fair comparison, we define the context interface as a one-shot retrieval function: query → context \texttt{query}\rightarrow\texttt{context} . The system prompts for MCE agents under this instantiation are given in Appendix B .

##### Evaluation Settings.

We evaluate all methods under two complementary settings [ Zhang et al., 2026 ] . (1) Offline : CE methods have access to a training set and iterate over it for multiple epochs to optimize context before evaluation on a held-out test set. (2) Online : CE methods process the test set sequentially, with performance measured only on each instance’s first inference. For MCE, the base-level agent accumulates all processed instances in its file system for continuous learning. We evaluate two MCE variants: one using a fixed skill generated based on task specifications, and another where the base agent operates autonomously without skill guidance.

### 4.2 Main Results

#### 4.2.1 Context Performance

Table 1 presents our evaluation of context performance across methods and benchmarks. We summarize our observations below. We also refer to some of the results in Table 2 , which we will revisit in § 4.2.2 .

Obs.❶ MCE substantially improves base LLMs for domain adaptation. MCE achieves 89.1% average relative improvement over the base model (DeepSeek-V3.1) across the five benchmarks. The gains are even more pronounced for smaller models since they may lack basic domain knowledge without CE. As shown in Table 2 , Gemma3-4B with MCE context achieves 172.6% average relative gain.

Obs.❷ MCE consistently outperforms all baselines across benchmarks and settings. MCE ranks first on all five benchmarks in the offline setting, with 89.1% average relative gain compared to 70.7% for ACE (second-best). In the online setting, MCE maintains leadership with 74.1% average gain versus ACE’s 41.1%. This consistent superiority across diverse domains demonstrates MCE’s robustness as a general-purpose CE framework.

Obs.❸ MCE adapts to task-specific requirements, while baselines exhibit inconsistent performance due to their fixed inductive biases. Baselines show inconsistent rankings across tasks because their hard-coded agentic harnesses suit only certain problem structures. FiNER demands deep reflection and pattern abstraction; simple in-context imitation fails (ICL performs poorly), while ACE’s reflection-curation loop excels. Symptom2Disease benefits from raw examples due to high semantic similarity between train and test instances; here, ACE underperforms even ICL, as its reflection overhead adds noise without benefit. On Aegis2.0, the lightweight generator (Qwen3-8B) favors concise prompts, giving GEPA’s brevity bias an edge over ACE. MCE’s robust top-rank across all tasks indicates its ability to discover task-appropriate strategies beyond any single heuristic. We provide detailed analysis in Appendix D .

Obs.❹ MCE-enhanced general LLMs can surpass domain-specific vertical models. On benchmarks where specialized models are available, MCE-enhanced general LLMs outperform them. LawBench reports that the best legal-specific model achieves 0.56 F1, while MCE reaches 0.70. On Aegis2.0, Qwen3-8B with MCE attains 0.80 F1, surpassing Llama Guard 3 8B (0.72), a dedicated safety guardrail model. This suggests that learned context can substitute for expensive domain-specific fine-tuning.

#### 4.2.2 Context Adaptability, Efficiency, and Transferability

Obs.❺ MCE is free from the inductive biases in context length imposed by prior methods. Prior CE methods exhibit inherent biases: GEPA [ Agrawal et al., 2025 ] tends toward brevity, typically producing around 1–2K tokens, while ACE [ Zhang et al., 2026 ] suffers from context bloat, reaching up to 80K tokens after 5 epochs of optimization (when using 200 training instances). In contrast, MCE learns to produce context of suitable length for each task. The two most effective contexts on FiNER have 1.5K and 20K tokens ( Fig. 3 ), while those on LawBench and USPTO50k reach 44K and 86K tokens. These results demonstrate that MCE adapts context length flexibly to task requirements, overcoming the inductive biases of prior methods.

Obs.❻ MCE produces more efficient contexts than ACE. Fig. 3 compares context efficiency on FiNER. At comparable context lengths ( ∼ \sim 1.5K tokens), MCE-S achieves 73% accuracy versus 65% for ACE (Step 20). Moreover, MCE-L reaches 75% accuracy with only 20K tokens, outperforming ACE even after 5 epochs of optimization (70% at 79K tokens). We attribute MCE’s superior context quality to two factors: (1) the agent maintains a global view of accumulated context, enabling it to restructure and refine existing knowledge rather than blindly appending new items; and (2) MCE agentically processes large batches of training rollouts, aggregating feedback across many examples before updating the context. Together, these properties yield coherent, non-redundant contexts, avoiding the redundancy and degradation observed in ACE’s additive curation.