ContextPipe: Database-Inspired Context Assembly for Long-Horizon Agents
cs.AI, cs.DB
Submitted: 2026-09-01
Updated: 2026-09-01
License: http://creativecommons.org/publicdomain/zero/1.0/
The gist: Long-horizon large language model (LLM) agents require context assembly: the runtime must decide what to include in each prompt, in what order, and when to compact history under a hard context-window
Terminology
Abstract
Long-horizon large language model (LLM) agents require context assembly: the runtime must decide what to include in each prompt, in what order, and when to compact history under a hard context-window budget and a byte-sensitive prompt cache. In production agentic systems, this logic is scattered across prompt builders, ad hoc compaction routines, cache-break workarounds, and per-provider shims. We argue that context assembly is structurally isomorphic to query execution in a relational database: both execute under a hard budget, exploit a tiered cache, and leverage statistics. We adopt this discipline in ContextPipe: a five-phase pipeline (Plan Bind Optimize Execute Feedback) backed by a structured data-source catalog, a deterministic cache-aware optimizer, and an EXPLAIN ANALYZE trace. We show that context in ContextPipe is auditable, replayable, and failure-isolated. A preliminary evaluation using the SWE-bench Pro Qutebrowser subset shows that, compared with the append-only context construction policy, ContextPipe reduces total token volume by 31%, LLM calls by 23%, and response time by 9%, at the cost of a lower KV cache-hit ratio.
Sources
- Longformer: The Long-Document Transformer
- Optimizing Prompts for Large Language Models: A Causal Approach
- SWE-Bench Pro: Can AI Agents Solve Long-Horizon Software Engineering Tasks?
- PEEK: Context Map as an Orientation Cache for Long-Context LLM Agents
- GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning
- Voyager: An Open-Ended Embodied Agent with Large Language Models
- DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence
- MemGPT: Towards LLMs as Operating Systems
Related papers
- MAVEN-T: Reinforced Heterogeneous Distillation for Real-Time Multi-Agent Trajectory Prediction
- Model Discovery Agent: LLM-assisted Bayesian experiment design for data-efficient discovery of mechanistic world models
- The Clinician's Veto: Navigating Trust, Liability, and Uncertainty in Autonomous AI Prescribing
- MindHelper: Closed-Loop Embodied Mental-State Reasoning for Precision Intervention
- Incumbent Advantage: Brand Bias and Cognitive Manipulation Dynamics in LLM Recommendation Systems
- VSAL: A Vision Solver with Adaptive Layouts for Graph Property Detection