Overview
A coding agent may need an observation made many steps earlier. ContextWeaver links each step to the observations and decisions it depends on, then uses those links to choose what to keep in the next context. Execution feedback tracks steps that have failed or been superseded.
On SWE-bench Verified and Lite, Claude Sonnet 4 improves over a sliding window. The model building the memory matters: GPT-5 benefits when Claude Sonnet 4 constructs its dependency graph.
Paper
Two debugging trajectories
The paper compares these SWE-bench tasks over five paired runs each.
Django · Changes across files
The fix requires coordinated edits to several components. ContextWeaver retains the early architectural analysis; the sliding window often loses it and repeats exploration or makes incompatible partial fixes.
django__django-14631
ContextWeaver wins 4 of 5 comparisons
pytest · A change in one location
The fix is confined to one location in one file. Recent edit history is sufficient here. Extra branches in ContextWeaver’s memory divert attention from the immediate change.
pytest-dev__pytest-7205
Sliding window wins 4 of 5 comparisons
How context is built
After each step, ContextWeaver updates the dependency graph and prepares the context for the next action.
Add a node
Represent the latest history entry as a node in the graph.
Choose its parents
Rank earlier steps by dependency likelihood and keep up to m parents. Exclude nodes marked Failed or Superseded.
Follow the dependencies
After warmup, collect the selected parents and their ancestors, up to the W-node limit.
Build the context
Keep the selected entries in full and compress the others. Preserve their original order.
During warmup, the agent receives the full history. Algorithm 1 gives the complete procedure.
- Preprint
- Method, experiments, ablations, and case studies.
Citation
View BibTeX
@misc{contextweaver2026,
title={{ContextWeaver: Selective and Dependency-Structured Memory Construction for LLM Agents}},
author={Wu, Yating and Zhang, Yuhao and Ghosh, Sayan and Basu, Sourya and Deoras, Anoop and Huan, Jun and Gupta, Gaurav},
year={2026},
eprint={2604.23069},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2604.23069}
}