Revisiting LLMs as Context Engineers

Junrui Zhang1, Zeyu Xu2, Runchuan Zhu1, Jie Peng2, Long Zhang2, Zixin Ding3, Jiaxin Lin4, Kai Wang1, Jianmin Ji2, Junyuan Hong1

1 National University of Singapore 2 University of Science and Technology of China 3 University of Chicago 4 Independent Researcher

Study overview showing the benchmark comparison, scaling experiments, failure-mode analysis, and case studies.
Overview of our work. We investigate whether LCEs can engineer effective context and further examine the mechanisms underlying their successes and failures.

Overview

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 then examine when LCEs are effective and what drives their successes and failures.

  • LLMs can engineer contexts via task-specific training, but no single method can achieve the best performance in all datasets at test time.
  • Scaling helps but cannot reverse existing failures of LCEs. Even scaling to newer generations and more parameters remains insufficient to make LCEs more effective across different settings.
  • When & How: Through aggregate analysis, we find that LCEs work better when facing less diverse failure modes of reasoning. Case studies show that the ability to abstract principled contexts from heterogeneous failures is the major bottleneck and that the success of some LCE methods is attributed to the improvement in adherence to (format) instruction rather than reasoning.

Benchmark of LCEs

No free lunch for LCEs at test time. We compare the representative LCEs across various tasks, from math reasoning to agentic tasks, using three LLM families, with Chain-of-Thought (CoT) Prompting and In-Context Learning (ICL) included as reference baselines.

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*
IFBench 39.76 ± 2.22 34.63 ± 2.17 41.63 ± 1.21 (+1.87) 46.70 ± 4.54 (−1.22) 42.09 ± 1.43 (+1.13) +6.94*
MATH500 67.70 ± 1.04 77.90 ± 3.54 73.80 ± 4.12 (+6.10) 71.20 ± 1.92 (+3.50) 69.40 ± 1.14 (+1.60) −4.10
HotpotQA 33.80 ± 0.80 32.60 ± 3.27 33.67 ± 1.29 (−0.13) 29.47 ± 1.45 (+0.73) 31.67 ± 0.78 (−0.20) −0.13
AppWorld 25.24 ± 2.25 26.67 ± 2.50 29.05 ± 3.13 (+3.81) 28.81 ± 0.68 (+1.67) 26.07 ± 4.40 (−0.36) +2.38
Min3 MiddleMatch 62.00 ± 3.44 49.53 ± 3.91 71.40 ± 6.46 (+9.40) 59.60 ± 4.64 (+22.20) 38.93 ± 8.69 (−1.07) +9.40*
IFBench 28.50 ± 2.19 26.46 ± 1.87 28.57 ± 1.88 (+0.07) 36.70 ± 1.84 (+0.82) 31.21 ± 1.90 (+0.27) +8.20*
MATH500 87.50 ± 1.06 68.10 ± 2.41 88.30 ± 1.15 (+0.80) 85.10 ± 1.43 (−1.30) 80.10 ± 3.90 (−3.00) +0.80
HotpotQA 23.07 ± 1.26 27.07 ± 0.95 24.13 ± 1.91 (+1.07) 31.00 ± 1.60 (+2.80) 31.27 ± 1.38 (+3.13) +4.20*
AppWorld 26.43 ± 1.96 28.45 ± 2.12 27.14 ± 2.75 (+0.71) 24.29 ± 7.52 (−1.90) 30.60 ± 1.08 (+4.40) +2.15

Performance of LCEs across LLM families. No method consistently improves the context.

LCEs with Scaling

After testing LCE methods with 8B-scale models, we further investigate whether scaling up models can improve the effectiveness of LCEs.

Heatmaps comparing context engineering with 8B and 32B reflectors and generators on four tasks.
Scaling the reflector cannot rescue failures but further enhances existing improvements.
Line charts comparing task performance as Qwen parameter counts and model generations increase.
Top: Parameter-size scaling of self-reflection. Bottom: Comparison of different model generations.

When & How

The study measures failure-mode diversity by embedding diagnoses of failed reasoning trajectories and computing their Vendi Score. Greater diversity is associated with smaller gains across model and dataset settings (r = −0.5, p ≤ 0.05).

Left: The significant negative correlation indicates that LCEs tend to achieve larger performance gains when failure modes are less diverse. Right: The small changes imply that LCEs struggle to distill experiences into shared principles.

Case Study: LCEs improve adherence to the task instructions. In multiple samples, we notice that the experiences extracted in LCEs are related to the output format or instruction details, less relevant to problem solution ideas.

The Min3 example asks which band had more members. The answer becomes simply Beady Eye after context engineering. The plots show accuracy and false failure rates.
LCE behavior on HotpotQA. Top: Example of a verbose prediction from Min3 leading to failure. Bottom: LCEs reduce the false failure rate in Ministral alongside performance gains.
Gemma4 gives the answer 2k+2 before and after context engineering and uses the required boxed format afterward. The plots show accuracy and format compliance.
LCE behavior on MATH500. Top: Example of a format failure from Gemma4. Bottom: LCEs improve compliance with the required format in Gemma4 while improving performance.

Case Study: TF-GRPO. To further investigate method-level failures, we conduct an additional ablation study with TF-GRPO, which has clearly separated workflow stages and achieves the best performance in more settings in the benchmark table across LCEs.

Method R E ϕ k MiddleMatchQ MATH500G MATH500M IFBenchG
ICL > LCE > CoT LCE ≥ CoT > ICL
CoT 0 31.27 ± 2.1067.70 ± 1.0487.50 ± 1.0639.76 ± 2.22
ICL ✓3 46.07 ± 4.8077.90 ± 3.5468.10 ± 2.4134.63 ± 2.17
GRPO-ICL RAG ✓3 44.00 ± 3.4674.10 ± 2.2526.50 ± 4.2337.41 ± 1.44
All-Exps Random ✓✓3 32.00 ± 6.0069.70 ± 0.9187.40 ± 0.5540.92 ± 2.07
Final-Exps ✓✓✓var. 37.73 ± 8.5773.80 ± 4.1288.30 ± 1.1541.63 ± 1.21

Performance under different experience utilization and retrieval settings.

Experience extraction (E) plays the most critical role. Across all four cases, either catastrophic performance loss (left two columns) or gain (right two columns) starts from the All-Exps Random, where Experience Extraction was first introduced to the ablation. That means when LLMs did not extract useful experiences from rollouts, the performance will not be improved over simply ICL of rollouts. Instead, when useful experiences are extracted (i.e., gains via E), the shorter experiences improve performance.

BibTeX

We would be delighted if you find our research helpful. Feel free to email zhangjunrui@u.nus.edu to discuss any insights or questions!

@article{zhang2026revisiting,
  title   = {Revisiting LLMs as Context Engineers},
  author  = {Zhang, Junrui and Xu, Zeyu and Zhu, Runchuan and Peng, Jie
             and Zhang, Long and Ding, Zixin and Lin, Jiaxin and Wang, Kai
             and Ji, Jianmin and Hong, Junyuan},
  journal = {arXiv preprint arXiv:2611.30494},
  year    = {2026}
}