Agent memory and context

facebookresearch/

context-language-models

A research repo that treats agent context as a writable file the model edits itself, cutting FLOPs while improving task accuracy.

What’s new here

CLMs treat the context as a file and give the model unrestricted write access to it. The model decides what to keep, discard, or reformat. That same mechanism extends to multi-agent setups, where multiple agent contexts coexist as files.

What it does

The repo ships three things. First, a zero-shot CLM harness built on Harbor, runnable with an openai/<model> flag. Second, an in-context learning loop that evolves natural-language instructions to steer context management, gaining up to 35.9 accuracy points on a context-management task. Third, an online RL training method that improved Qwen3.5-9B on BrowseComp-Plus by 47.6% with 12% fewer FLOPs.

The paper reports concrete efficiency numbers for the zero-shot version: 21.5% fewer FLOPs with 11.4% higher accuracy on BrowseComp-Plus, 59% fewer FLOPs with 5% higher scores on a 12-hour EdgeBench run, and 65% more improvement on a 24-hour multi-repo agent-swarm task at equal compute.

A suffix cache reuse module handles efficient serving when the context file changes incrementally.

Who it’s for

Researchers studying agent efficiency and context management, and engineers who want to experiment with prompting or training LLMs to manage their own working memory. The Harbor integration provides a ready-made harness for the zero-shot version.

Try it

From a clone of the repo, install and run the minimal CLM agent on a Harbor task:

pip install -e .
clm-harbor run -p <harbor-task> -a clm-minimal -m openai/<model> \
  --agent-kwarg api_base=http://localhost:8000/v1

For the Pi agent framework:

pi install npm:@lolipopshock/pi-clm

How mature is it

668 stars, 77 forks, 1 contributor, 4 commits in the past 90 days. Created September 2026, last pushed October 2026. No releases. Licensed CC BY-NC 4.0 (non-commercial). ContextBench, listed as a coming-soon evaluation suite, is not yet published.