As large language models (LLMs) are used in more and more new tasks, context engineering becomes a fundamental method to efficiently steer LLMs by constructing instruction prompts or metadata without intensive training. A growing number of LLM context engineering (LCE) approaches automate the task by casting the LLM itself as the engineer that draws generalizable instructions or experiences from offline trials as context. Although these methods resemble how humans learn from experiences, it remains unclear when and how LLMs can engineer effective context from data. To answer the question, we first establish a benchmark composed of datasets with different reasoning patterns. We compared different LCE methods with different LLM families in 8B size, showing that there is no single winner for all tasks, even compared with simple baselines like chain-of-thought. Even when scaling model capabilities via more parameters or generation iterations, LCEs do not consistently boost existing performance. Across all datasets and models, the performance gains of LCEs are negatively correlated (r=−0.5,p≤0.05) with the diversity of the failure modes of reasoning trajectories. Investigating how LCEs work, we find that (1) the improvement in instruction adherence can explain some success of LCEs; (2) one major bottleneck is whether LLMs can extract effective experiences out of natively diverse failures. Through this study, we uncover the limited capabilities of LCEs in abstracting principled contexts from diverse failure modes and understand how LCEs work, providing guidelines for future work.
Figures & tables
Figure 1: Overview of our work. We investigate whether LCEs can engineer effective context and further examine the mechanisms underlying their successes and failures.
Method
Context π
Main Strategy
TextGrad
Sys
Textual gradient backpropagation
GEPA
Sys
Textual reflection + Mutation sampling
TF-GRPO
Exp
Group-relative textual advantage
ACE
Exp + metadata
Textual reflection
Table 1: Comparison of evaluated context engineering methods. Sys denotes the system prompt; Exp denotes experience (e.g., a pool of distilled insights or a playbook injected into context).
Figure 2: Validation performance gains after context engineering in 4 datasets.
Model
Dataset
CoT
ICL
TF-GRPO
GEPA
ACE
Δbest
Qwen3
MiddleMatch
31.27±2.10
46.07±4.80
37.73±8.57 (+6.47)
42.33±3.80 (+12.53)
25.20±3.96 (+4.73)
−3.74
IFBench
32.35±0.82
30.54±0.94
32.21±1.58 (-0.14)
33.30±3.64 (-0.37)
32.17±1.28 (+0.64)
+0.95
MATH500
83.20±2.51
79.80±1.04
82.10±2.43 (-1.10)
80.60±1.43 (-0.20)
63.80±2.93 (-7.30)
−1.10
HotpotQA
38.00±0.75
37.60±0.83
38.00±0.97 (0.00)
32.80±0.99 (-1.54)
33.67±0.97 (-3.26)
0.00
AppWorld
21.55±1.95
23.10±3.89
23.69±2.08 (+2.14)
23.33±1.54 (+0.48)
18.93±1.29 (-3.45)
+0.59
Gemma4
MiddleMatch
79.33±1.93
80.47±2.32
90.13±3.43 (+10.80)
93.33±2.91 (+7.40)
87.47±6.16 (+0.73)
+12.86∗
Table 2: Performance of LCEs across LLM families. No method consistently improves the context. Bold and (⋅) denote the best performance and performance changes relative to the initial, respectively. In the Δbest column, ∗ denotes a significant difference ( p≤0.05 ); significant improvements and degradations are shaded blue and red, respectively.
Figure 3: Ablation on the scale of the Reflector and Generator across four datasets. Scaling the reflector cannot rescue failures but further enhances existing improvements.
Figure 4: Scaling experiments. Top: Parameter-size scaling of self-reflection from 0.6B to 235B-A22B (Qwen3) across different datasets. Bottom: Comparison of model generations from Qwen1.5 to Qwen3.5. CoT and GEPA initial are the initials for TF-GRPO and GEPA, respectively.
Figure 5: Left: Correlation between LCE performance gains and the Vendi Score of failure modes . Markers and error bars show means and standard deviations on both axes for LCEs. The significant negative correlation indicates that LCEs tend to achieve larger performance gains when failure modes are less diverse. Right: Changes in the Vendi Score of experiences across epochs. The small changes imply that LCEs struggle to distill experiences into shared principles.
Figure 6: Ratio of total variance in Vendi Score of failure modes.
Figure 9
Method
R
E
ϕ
k
MiddleMatch Q
MATH500 G
MATH500 M
IFBench G
ICL>LCE>CoT
LCE≥CoT>ICL
CoT
0
31.27±2.10
67.70±1.04
87.50±1.06
39.76±2.22
ICL
✓
3
46.07±4.80
77.90±3.54
68.10±2.41
34.63±2.17
GRPO-ICL RAG
✓
3
44.00±3.46
74.10±2.25
26.50±4.23
37.41±1.44
All-Exps Random
✓
✓
3
32.00±6.00
69.70±0.91
87.40±0.55
40.92±2.07
Final-Exps
✓
✓
✓
var.
37.73±8.57
73.80±4.12
88.30±1.15
41.63±1.21
Table 3: Performance under different experience utilization and retrieval settings. R , E , and ϕ denote training rollouts, knowledge extraction, and experience consolidation, respectively. k denotes the number of examples or experiences used, with var. indicating that the number varies depending on the optimized experiences. Bold and underlined values indicate the best and second-best results. Q, G, and M denote Qwen3, Gemma4, and Min3, respectively.
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
Method
Reported Benchmarks
TextGrad
BBH, GSM8K ( Suzgun et al., 2023 ; Cobbe et al., 2021 )
GEPA
HotpotQA, IFBench, HoVer, PUPA, AIME25, LiveBench-Math ( Yang et al., 2018 ; Jiang et al., 2020 ; Pyatkin et al., 2025 ; Siyan et al., 2025 ; White et al., 2025 )
TF-GRPO
AIME24, AIME25, WebWalkerQA ( Art of Problem Solving, 2025 ; Wu et al., 2025 )
ACE
AppWorld, FiNER, Formula ( Trivedi et al., 2024 ; Loukas et al., 2022 ; Wang et al., 2025 )
Appendix
Table 4: Reported benchmarks of evaluated context engineering methods.
Figure 17: Correlation between LCE performance gains and the Vendi Score of failure modes that are labeled by generator models themselves. Markers and error bars show means and standard deviations on both axes for LCEs. The significant negative correlation indicates that LCEs tend to achieve larger performance gains when failure modes are less diverse.
Figure 18: Pass@K or Best@K on four benchmarks. Top row : GEPA. Bottom row : TF-GRPO. Each figure compares the different optimized contexts by GEPA/TF-GRPO versus their initial performance.
Figure 19: Pass^K Evaluation on four benchmarks. Top row : GEPA. Bottom row : TF-GRPO. Each figure compares the different optimized contexts by GEPA/TF-GRPO versus their initial performance.
Method
R
E
ϕ
k
MiddleMatch Q
MATH500 G
MATH500 M
IFBench G
ICL>LCE>CoT
LCE≥CoT>ICL
CoT
0
31.27±2.10
67.70±1.04
87.50±1.06
39.76±2.22
ICL
✓
3
46.07±4.80
77.90±3.54
68.10±2.41
34.63±2.17
GRPO-ICL RAG
✓
3
44.00±3.46
74.10±2.25
26.50±4.23
37.41±1.44
All-Exps Random
✓
✓
3
32.00±6.00
69.70±0.91
87.40±0.55
40.92±2.07
All-Exps RAG
✓
✓
3
39.07±11.87
68.30±2.89
88.50±1.27
38.78±1.67
Appendix
Table 5: Performance under different experience utilization and retrieval settings. R , E , and ϕ denote training rollouts, knowledge extraction, and experience consolidation, respectively. k denotes the number of examples or experiences used, with var. indicating that the number varies depending on the optimized experiences. Bold and underlined values indicate the best and second-best results. Q, G, and M denote Qwen3, Gemma4, and Min3, respectively.
Method
k
Avg. Prompt Tokens
Accuracy
ICL
3
3,859
68.10
GRPO-ICL RAG
1
3,807
68.50
GRPO-ICL RAG
3
11,112
26.50
Appendix
Table 6: Performance under different ICL settings with varying prompt lengths.
Method
k
Answer Any ICL
ICL
3
15.10%
GRPO-ICL RAG
1
14.90%
GRPO-ICL RAG
3
64.30%
Appendix
Table 7: Ratio of the predictions that incorrectly match the in-context demonstration answer.
Figure 20: Ablation on context length. As high-quality context grows longer, performance eventually drops below both baselines.
Variable
β
p-value
Failure-mode diversity
−0.793
p≤0.05
Initial performance
−0.038
n.s.
HotpotQA
−2.070
n.s.
IFBench
−5.427
n.s.
MATH500
−1.698
n.s.
MiddleMatch
+2.658
n.s.
Appendix
Table 8: Coefficients and corresponding p-values for each variable in the linear mixed-effects model, with performance gain as the outcome variable. We observe that the coefficient of failure-model diversity is significantly negative, implying that the LCEs can improve the context better when facing less heterogeneous failure modes.
Figure 21: Correlation between LCE performance gains and optimization budgets ( Left: LLM calls. Right: token consumption in millions). Markers and error bars represent means and standard deviations, respectively, on both axes. Neither correlation is significant. We find no evidence that larger optimization budgets are associated with more LCE performance gains.
Model
Dataset
w/o Prompt
w/ Prompt
GEPA
TF-GRPO
ACE
GEPA
TF-GRPO
ACE
Qwen3
MATH500
-0.20
-1.10
-7.30
-0.80
+0.80
-5.70
HotpotQA
-1.54
+0.00
-3.26
-0.33
+1.27
-2.07
IFBench
-0.37
-0.14
+0.64
-1.16
-1.16
+1.12
MiddleMatch
+12.53
+6.47
+4.73
+12.93
+6.60
+5.40
Gemma4
MATH500
+3.50
+6.10
+1.60
+2.20
+9.00
+1.10
Appendix
Table 9: Performance gains of LCEs with and without additional prompts across models on different tasks. Our experiments cannot provide sufficient evidence that simplified explanations can affect the LCEs’ performance.
Figure 22: Correlation between LCE performance gains and the Left: Baseline Task Accuracy and Right: Baseline Task Accuracy controlling for model size. Markers and error bars show means and standard deviations on both axes for LCEs. Both settings show the non-significant correlations. Improvements in baseline task accuracy brought by model scales are insufficient to contribute to better LCE performance gains.
Method
w/ LLM-Extractor
w/o LLM-Extractor
Initial
Final
Gain
Initial
Final
Gain
GEPA
91.70
91.20
-0.50
67.70
71.20
+3.50
TF-GRPO
91.10
92.60
+1.50
67.70
73.80
+6.10
ACE
88.80
88.00
-0.80
67.80
69.40
+1.60
Appendix
Table 10: Performance of LCEs with and without the LLM-based answer extractor. The performance gains substantially decrease and nearly vanish after applying the extractor, indicating that the observed improvements achieved by LCEs stem primarily from better adherence to format instructions.