Haystack Engineering: Context Engineering for Heterogeneous and Agentic Long-Context Evaluation
Authors: Mufei Li, Dongqi Fu, Limei Wang, Si Zhang, Hanqing Zeng, Kaan Sancak, Ruizhong Qiu, Haoyu Wang, Xiaoxin He, Xavier Bresson, Yinglong Xia, Chonglin Sun, Pan Li
Affiliations: Georgia Institute of Technology, Meta AI, University of Illinois Urbana-Champaign, National University of Singapore
Publication: arXiv:2510.07414 (October 2025)
Introduction
Modern long-context LLMs perform well on synthetic "needle-in-a-haystack" (NIAH) benchmarks, but these tests overlook how noisy contexts arise in the real world from biased retrieval and agentic workflows. More realistic evaluation is needed.
Haystack Engineering
- A new paradigm to construct realistic noisy long contexts
- Captures key real-world factors:
- Distraction from heterogeneous biased retrievers
- Cascading errors in agentic workflows
- Contrasts with "context engineering," which optimizes inputs for best performance
- Built on the full English Wikipedia hyperlink network
- Features multi-hop questions
- Extends traditional NIAH evaluations in two ways:
- Heterogeneous Retrieval-Dependent Haystacks
- Dynamic, LLM-Dependent Agentic Context Engineering
- Sparse Retrieval (BM25)
- Dense Retrieval (Qwen3-Embedding-0.6B)
- Hybrid Retrieval (BM25 + Qwen3-Embedding-0.6B)
- Graph-Based Reranking (Personalized PageRank, PPR)
- Dense retrievers introduce more challenging distractors than sparse ones
- Graph-based reranking with PPR significantly improves retrieval effectiveness
- Document ordering effects are model-dependent
- Even advanced models (Gemini 2.5 Pro, GPT-5) suffer from cascading self-distraction
- Models are more robust to noisy long contexts ("width") than to noisy reasoning iterations ("depth")
- Most models struggle with appropriate early stopping in variable-round settings
HaystackCraft Benchmark
Heterogeneous Retrieval Strategies
The benchmark evaluates how different retrieval strategies affect distractor composition, haystack ordering, and LLM performance:
Agentic Context Engineering
Extends NIAH to dynamic, LLM-dependent settings where models refine queries, reflect on past reasoning, and decide when to stop. Two dynamic settings: Enforced Multi-Round and Variable-Round.
Key Findings
Conclusion
Robust agentic long-context reasoning remains an unsolved challenge. HaystackCraft is established as a valuable testbed for future progress.
Code: <https://github.com/Graph-COM/HaystackCraft>