ContextPipe: Database-Inspired Context Assembly for Long-Horizon Agents

Peng Xu, Zuyu Zhang, Yuze Sun, Feng Tian, Long Wang +1 more
9/1/2026
cs.AIcs.DB

No confident code implementation found for this paper.

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{xu2026contextpipe,
  title  = {ContextPipe: Database-Inspired Context Assembly for Long-Horizon Agents},
  author = {Peng Xu and Zuyu Zhang and Yuze Sun and Feng Tian and Long Wang and Chen Zhang},
  year   = {2026},
  eprint = {2609.00749},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2609.00749v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2609.00749.svg)](https://codeofpaper.com/paper/2609.00749)

Discussion