Model or dataset
facebookresearch/context-language-models avatar
facebookresearch/context-language-models

Context Language Models treat the context window as a file the model edits

Official repository for "Context Language Models"

756 stars88 forksPythonNOASSERTION

At a glance

What is it?
The CLM work from Meta Superintelligence Labs and the University of Washington gives a language model an editable transcript file as its context, letting the model decide what to keep, update and offload. The implementation is a Harbor agent harness rather than a model, and the repository publishes three training methods, a benchmark, and SGLang and vLLM serving extensions for suffix cache reuse.
Who is it for?
Adopt the CLM harness if you are running a long-horizon agent on a task where context overflow is the bottleneck, since the model editing its own transcript is the mechanism the reported gains come from. Skip it if you want a finished product, because the package version is 0.1.0 with a narrow dependency set, the licence is CC BY-NC 4.0 which blocks commercial use, and one of the two day-one integrations is explicitly not maintained by the authors.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 9 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The mechanism is a file the model is allowed to edit

Context Language Models are language models that natively manage their own context. The implementation treats the context as a file and allows the model to make unrestricted updates to it.

That single decision is the paper. A conventional agent has a fixed context window and a summarisation or retrieval step in the middle, and the model never sees the bookkeeping. Here the transcript is a file, the model writes to it, and the model therefore learns what is most important to maintain in context. The README's claim is that this naturally extends to multi-agent systems where multiple agent contexts coexist as files, which is a neat consequence: if the context is a file, a second agent can be pointed at a different file.

The package description in the project file is more specific still. CLM is a Harbor agent harness in which the model manages its own context by editing a mirrored transcript file.

So the artefact you install is not a model and not a training script. It is a harness, built on Harbor, that gives an existing model the ability to edit its own context. The model is the same model you were using before.

The reported results are the reason to look at it. Building CLMs zero-shot with existing models outperforms state of the art context-management strategies across a variety of tasks: 11.4 percent higher accuracy with 21.5 percent fewer FLOPs on BrowseComp-Plus, 5 percent higher scores with 59 percent fewer FLOPs on 12-hour EdgeBench, and 65 percent greater improvement with the same compute on a 24-hour multi-repository agent-swarm task.

Those are the authors' own numbers, and the framing is careful. Zero-shot means the harness does the work with an existing model, no training required.

Three training methods sit on top of the same harness

The repository is organised as a set of methods layered on the core idea, and the directory listing is the clearest description of the scope.

`clm/clm_harness` holds the CLMs implemented in Harbor, and it is the base everything else uses. `clm/clm_icl` is in-context learning for CLMs. `clm/clm_rl` is reinforcement learning for CLMs. `clm/clm_contextbench` is CLMs on ContextBench.

The in-context learning result is that CLMs can be steered with natural-language instructions evolved through a standard skill-optimization loop, improving held-out accuracy by up to 35.9 points on a context-management task while reducing compute. The idea is that if the model manages the file, you can also tell the model how to manage the file, and the instructions themselves can be evolved against a benchmark.

The reinforcement learning result is the introduction of an online reinforcement learning method for CLMs, improving Qwen3.5-9B performance on BrowseComp-Plus by 47.6 percent while using 12 percent fewer FLOPs.

The two methods are complementary rather than competing. In-context learning works with any model and no training, and reinforcement learning needs training but gives more. For most people evaluating this, the zero-shot path is the entry point, because it needs no training infrastructure at all.

The four directories map cleanly onto the questions a reader has: how do I run it, how do I steer it without training, how do I train it, and how do I measure it.

Running the minimal agent is one install and one command

Getting started is described as running the minimal CLM agent on any Harbor task, and it is a pip install followed by a single command:

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

The `-a clm-minimal` argument selects the CLM agent, and the model is named with the `openai/` prefix, which is a litellm model string. The `api_base` points at a local server, which tells you what the harness expects: an OpenAI-compatible endpoint.

The dependency list in the project file is short and explains the design. harbor is pinned at 0.16.1, litellm is there for the model calls, tiktoken for tokenization, and pyyaml for configuration. The console script is `clm-harbor = "clm_harness.cli:main"`.

The Python requirement is `>=3.12,<3.14`, which is a narrow window and worth checking before you set anything up. The optional `hf` extra installs transformers at 4.40 or newer, and the comment on it explains why: exact-tokenizer FLOPs accounting for open models, falling back to tiktoken without it. That is a measurement detail, and it matters because the FLOPs figures in the results depend on getting the token count exactly right.

The configuration lives in YAML files, packaged as data, under clm_harness/configs/, clm_harness.clm_agent, clm_harness.task_templates and clm_icl.

For the benchmark, the command is also one line:

bash
harbor jobs start --repo RulinShao/ContextBench -d contextbench \
  -a clm_contextbench:ClmStream -m openai/<model> --agent-kwarg api_base=http://localhost:8000/v1

ContextBench measures what an agent keeps, updates and offloads when its input does not fit in its context window, and the tasks are also on Hugging Face.

Suffix cache reuse is the serving half of the work

A separate top-level directory, suffix_cache_reuse, covers efficient serving, and it has implementations for two inference engines.

The reasoning connects directly to the core idea. If a model edits its own context file, then between turns the tail of the file often stays the same while the head changes, and an inference server that can reuse a cached prefix of the KV state could avoid recomputing the unchanged part. suffix_cache_reuse/sglang is the SGLang version and suffix_cache_reuse/vllm is the vLLM version, and the directory listing describes the pair as suffix cache reuse for CLM efficient serving, with an overview and results.

This is worth calling out because it explains the FLOPs numbers in the results. The headline claims are not only about accuracy, they are about doing the same work with fewer FLOPs, and a suffix cache that is actually reused is one of the ways to get there. Without the serving work, an agent that rewrites its own context would thrash the cache, since a changed middle invalidates everything after it.

The day-one support section shows how the work is meant to be used before you have built anything. There is a Pi integration installed with:

sh
pi install npm:@lolipopshock/pi-clm

And a community port for OpenCode:

sh
opencode plugin opencode-clm

That second one carries an important caveat in the README, which says it is not maintained by the CLM authors. Both are single-command installs, which is a good sign for the ergonomics, and the caveat is a good sign for the honesty.

The day-one framing is also the honest framing for a research release. The paper, the arXiv identifier 2609.37725, is linked along with a thread from the first author, and the citation is a BibTeX entry naming all twelve authors.

The licence is the one thing to read before anything else

This project is licensed under CC BY-NC 4.0, and there is a NOTICE file alongside the LICENSE.

That is a content licence, not a software licence, and the non-commercial clause is the part that matters. The licence field reads Other, a custom licence GitHub cannot classify, which is GitHub's way of saying it does not recognise CC BY-NC 4.0 as one of the standard software licences.

For research and for evaluating the idea, that is not a problem. For anyone who wants to run a CLM agent in a product, it is a hard stop until the licence situation is sorted out, and no amount of technical enthusiasm changes that.

The authorship is worth noting as a signal about the project's standing. Twelve authors, with the affiliations given in the header: University of Washington, Meta Superintelligence Labs, MIT and Trillium Labs. The paper is on arXiv as 2609.37725.

The repository structure otherwise is conventional for a Python research project. There is a pyproject.toml, an assets/ directory with the teaser image, a clm/ directory for the package, suffix_cache_reuse/ for the serving work, and the usual CODE_OF_CONDUCT.md and CONTRIBUTING.md. The package data configuration shows the configuration surface: YAML for the harness configs, the CLM agent and the task templates, and markdown for the in-context learning material.

The version is 0.1.0 and the build uses setuptools at 68 or newer, with the package found under clm/ and including clm_harness, clm_icl and clm_contextbench. Note what is not in that include list: clm_rl is not packaged with the wheel, which is consistent with reinforcement learning being the piece that needs more than a pip install to run.

Editorial conclusion

Adopt the CLM harness if you are running a long-horizon agent on a task where context overflow is the bottleneck, since the model editing its own transcript is the mechanism the reported gains come from. Skip it if you want a finished product, because the package version is 0.1.0 with a narrow dependency set, the licence is CC BY-NC 4.0 which blocks commercial use, and one of the two day-one integrations is explicitly not maintained by the authors. Verify first that your model endpoint speaks the OpenAI-compatible API the harness expects, that the licence allows your intended use given the non-commercial clause, and that you can serve the model locally, since the documented commands all point at a local base URL.

Frequently asked questions

What is a Context Language Model?

It is a language model that natively manages its own context by treating the context as a file and allowing unrestricted updates to it. The model therefore learns what is important to maintain, and the same mechanism extends to multi-agent systems where multiple agent contexts coexist as files.

How do I run the minimal CLM agent?

Run `pip install -e .` and then `clm-harbor run -p <harbor-task> -a clm-minimal -m openai/<model> --agent-kwarg api_base=http://localhost:8000/v1`. The `clm-harbor` command is the Harbor CLI with CLM available as `-a clm-minimal`, and the api_base argument points the harness at an OpenAI-compatible endpoint.

What results does the CLM work report?

Zero-shot CLMs built with existing models are reported as outperforming state of the art context-management strategies, with 11.4 percent higher accuracy and 21.5 percent fewer FLOPs on BrowseComp-Plus, 5 percent higher scores with 59 percent fewer FLOPs on 12-hour EdgeBench, and 65 percent greater improvement with the same compute on a 24-hour multi-repository agent-swarm task. In-context learning improves held-out accuracy by up to 35.9 points, and online reinforcement learning improves Qwen3.5-9B on BrowseComp-Plus by 47.6 percent with 12 percent fewer FLOPs.

What licence does the CLM project use?

CC BY-NC 4.0, with a NOTICE file alongside the LICENSE. The non-commercial clause means the code cannot be used in a commercial product as it stands, and the licence field reads Other because GitHub cannot classify it as a standard software licence.

Official sources

  1. facebookresearch/context-language-models on GitHub
  2. Issues
  3. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/facebookresearch-context-language-models.svg)](https://hysenlabs.com/projects/facebookresearch-context-language-models)

Was this useful?