Haystack Engineering: Context Engineering for Heterogeneous and Agentic Long-Context Evaluation
On the map: LLM agents and tool use → Web, search, and research agents
Abstract (arXiv)
Modern long-context large language models (LLMs) perform well on synthetic "needle-in-a-haystack" (NIAH) benchmarks, but such tests overlook how noisy contexts arise from biased retrieval and agentic workflows. We argue that haystack engineering is necessary to construct noisy long contexts that faithfully capture key real-world factors -- distraction from heterogeneous biased retrievers and cascading errors in agentic workflows -- to test models' long-context robustness. We instantiate it through HaystackCraft, a new NIAH benchmark built on the full English Wikipedia hyperlink network with multi-hop questions. HaystackCraft evaluates how heterogeneous retrieval strategies (e.g., sparse, dense, hybrid, and graph-based) affect distractor composition, haystack ordering, and downstream LLM performance. HaystackCraft further extends NIAH to dynamic, LLM-dependent settings that simulate agentic operations, where models refine queries, reflect on their past reasonings, and decide when to stop. Experiments with 15 long-context models show that (1) while stronger dense retrievers can introduce more challenging distractors, graph-based reranking simultaneously improves retrieval effectiveness and mitigates more harmful distractors; (2) in agentic tests, even advanced models like Gemini 2.5 Pro and GPT-5 suffer cascading failures from self-generated distractors or struggle to perform early stops. These results highlight persistent challenges in agentic long-context reasoning and establish HaystackCraft as a valuable testbed for future progress.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Placed in Web, search, and research agents, one of 16 directions in LLM agents and tool use. Builds on 57 of its 71 references that are in the map. First posted on arXiv 8 Oct 2025.
Builds on
57 of 71 references.
References · 57
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
- 2025Qwen3 Technical Reportcited by 8,820
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,695
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
- 2025DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learningcited by 6,330
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,944
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
- 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,276
- 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,824
- 2018HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answeringcited by 3,754
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
38 more
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,455
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2023Efficient Streaming Language Models with Attention Sinkscited by 2,186
- 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,839
- 2025Gemma 3 Technical Reportcited by 1,824
- 2023LongBench: A Bilingual, Multitask Benchmark for Long Context Understandingcited by 1,417
- 2024RULER: What's the Real Context Size of Your Long-Context Language Models?cited by 1,346
- 2020Constructing A Multi-hop QA Dataset for Comprehensive Evaluation of Reasoning Stepscited by 1,282
- 2023AgentBench: Evaluating LLMs as Agentscited by 1,267
- 2025Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Modelscited by 1,261
- 2021BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Modelscited by 1,252
- 2023Large Language Models Cannot Self-Correct Reasoning Yetcited by 1,017
- 2022Interleaving Retrieval with Chain-of-Thought Reasoning for Knowledge-Intensive Multi-Step Questionscited by 923
- 2021MuSiQue: Multihop Questions via Single-hop Question Compositioncited by 916
- 2017Reading Wikipedia to Answer Open-Domain Questionscited by 777
- 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 601
- 2023Active Retrieval Augmented Generationcited by 516
- 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 457
- 2025LLMs Get Lost In Multi-Turn Conversationcited by 429
- 2025Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attentioncited by 407
- 2024LongBench v2: Towards Deeper Understanding and Reasoning on Realistic Long-context Multitaskscited by 379
- 2024∞Bench: Extending Long Context Evaluation Beyond 100K Tokenscited by 367
- 2023NLP Evaluation in trouble: On the Need to Measure LLM Data Contamination for each Benchmarkcited by 348
- 2023MINT: Evaluating LLMs in Multi-turn Interaction with Tools and Language Feedbackcited by 297
- 2024MT-Bench-101: A Fine-Grained Benchmark for Evaluating Large Language Models in Multi-Turn Dialoguescited by 250
- 2023L-Eval: Instituting Standardized Evaluation for Long Context Language Modelscited by 233
- 2024BABILong: Testing the Limits of LLMs with Long Context Reasoning-in-a-Haystackcited by 215
- 2023Query Rewriting for Retrieval-Augmented Large Language Modelscited by 213
- 2025MultiChallenge: A Realistic Multi-Turn Conversation Evaluation Benchmark Challenging to Frontier LLMscited by 180
- 2023ZeroSCROLLS: A Zero-Shot Benchmark for Long Text Understandingcited by 176
- 2022SCROLLS: Standardized CompaRison Over Long Language Sequencescited by 170
- 2025Qwen2.5-1M Technical Reportcited by 164
- 2023Query2doc: Query Expansion with Large Language Modelscited by 149
- 2025A Survey of Context Engineering for Large Language Modelscited by 126
- 2025MMTEB: Massive Multilingual Text Embedding Benchmarkcited by 125
- 2024Long-Context LLMs Meet RAG: Overcoming Challenges for Long Inputs in RAGcited by 123
- 2024Leave No Document Behind: Benchmarking Long-Context LLMs with Extended Multi-Doc QAcited by 122
- 2023Retrieval meets Long Context Large Language Modelscited by 115
50 most cited of 57 All 57 (JSON)
Built on by
Citing papers per year: 2026: 4.
4 papers.
- 2026Gated Differentiable Working Memory for Long-Context Language Modelingcited by 6
- 2026KVEraser: Learning to Steer KV Cache for Efficient Localized Context Erasingcited by 6
- 2026Do LLMs Benefit From Their Own Words?cited by 5
- 2026Reconstructing the Right Episode: Evaluating Interleaved Conversational Memory Beyond Long Contextcited by 0
- 2026Reconstructing the Right Episode: Evaluating Interleaved Conversational Memory Beyond Long Context26 Aug 2026
- 2026KVEraser: Learning to Steer KV Cache for Efficient Localized Context Erasing15 Jun 2026
- 2026Do LLMs Benefit From Their Own Words?27 Feb 2026
- 2026Gated Differentiable Working Memory for Long-Context Language Modeling19 Jan 2026
Similar, not cited
Close in wording, no citation either way
- 2025Hidden in the Haystack: Smaller Needles are More Difficult for LLMs to Find
- 2025Graph of Agents: Principled Long Context Modeling by Emergent Multi-Agent Collaboration
- 2024Michelangelo: Long Context Evaluations Beyond Haystacks via Latent Structure Queries
- 2026Understanding Axes of Difficulty For Long Context Tasks Via PredicateLongBench
- 2026TS-Haystack: A Multi-Task Retrieval Benchmark for Long-Context Time-Series Reasoning
- 2025Can LLMs reason over extended multilingual contexts? Towards long-context evaluation beyond retrieval and haystacks
- 2024NeedleBench: Evaluating LLM Retrieval and Reasoning Across Varying Information Densities
- 2024Chain of Agents: Large Language Models Collaborating on Long-Context Tasks