ContextWeaver: Selective and Dependency-Structured Memory Construction for LLM Agents

arXiv cs.CL / 4/28/2026

📰 NewsModels & Research

Key Points

  • LLM agents can lose important earlier information in long conversations because common context methods (like sliding windows or prompt compression) may omit structured details needed later.
  • ContextWeaver proposes a dependency-structured memory that turns an agent’s interaction trace into a graph of reasoning steps, linking each step to the earlier steps it depends on.
  • The framework builds compact, reusable summaries along root-to-step reasoning paths, enabling more efficient reuse of logical structure for future actions.
  • A lightweight validation layer uses execution feedback to improve the reliability of the selected context.
  • On SWE-Bench Verified and Lite, ContextWeaver outperforms a sliding-window baseline in pass@1 while using fewer reasoning steps and fewer tokens.

Abstract

Large language model (LLM) agents often struggle in long-context interactions. As the agent accumulates more interaction history, context management approaches such as sliding window and prompt compression may omit earlier structured information that later steps rely on. Recent retrieval-based memory systems surface relevant content but still overlook the causal and logical structure needed for multi-step reasoning. We introduce ContextWeaver, a selective and dependency-structured memory framework that organizes an agent's interaction trace into a graph of reasoning steps and selects the relevant context for future actions. Unlike prior context management approaches, ContextWeaver supports: (1) dependency-based construction and traversal that link each step to the earlier steps it relies on; (2) compact dependency summarization that condenses root-to-step reasoning paths into reusable units; and (3) a lightweight validation layer that incorporates execution feedback. On the SWE-Bench Verified and Lite benchmarks, ContextWeaver improves performance over a sliding-window baseline in pass@1, while reducing reasoning steps and token usage. Our observations suggest that modeling logical dependencies provides a stable and scalable memory mechanism for LLM agents that use tools.