task_id stringlengths 20 31 | family stringclasses 4
values | level stringclasses 32
values | seed int32 42 49 | budget int32 32.8k 32.8k | reserve int32 2.05k 2.05k | n_ops int32 4 262 | streamed_tokens int64 302 881k | pressure float64 0.22 26.9 | chunks listlengths 4 262 | gold stringlengths 4.38k 3.26M | meta stringlengths 207 341 |
|---|---|---|---|---|---|---|---|---|---|---|---|
kv-store-R130-seed42 | kv_store | R130 | 42 | 32,768 | 2,048 | 26 | 7,358 | 0.225 | [
{
"index": 0,
"header": "set batch (keys 0-99)",
"body": "<<<SET-BATCH 0000#9226d9e1 BEGIN -- offload this whole block this turn>>>\nSET K00000 = ember crimson saffron falcon marble quartz thistle mistral cobalt cinder zebra crimson cobalt pewter marble fathom crimson cedar mistral onyx marble vellum sa... | {
"queries": [
{
"qid": 0,
"key": "K00122",
"value": "fathom lattice orbit cobble harbor lattice harbor indigo thistle ember marble fathom lantern zebra lantern falcon zebra russet lattice auburn willow nimbus zebra onyx #8104400c"
},
{
"qid": 1,
"key": "K00015",
"value... | {
"task_family": "kv_store",
"seed": 42,
"records": 130,
"value_words": 24,
"records_per_chunk": 100,
"queries": 24,
"n_set": 130,
"n_get": 24,
"n_batches": 2,
"n_actions": 26,
"approx_value_tokens": 6301,
"approx_per_value_tokens": 48
} |
kv-store-R130-seed43 | kv_store | R130 | 43 | 32,768 | 2,048 | 26 | 7,341 | 0.224 | [
{
"index": 0,
"header": "set batch (keys 0-99)",
"body": "<<<SET-BATCH 0000#93fed4f3 BEGIN -- offload this whole block this turn>>>\nSET K00000 = zebra boulder willow garnet lattice thistle garnet cobble crimson fathom cinder lattice cinder spruce nimbus orbit thistle ember auburn willow thistle harbor ... | {
"queries": [
{
"qid": 0,
"key": "K00020",
"value": "kindle lattice meadow lattice vellum lattice cobalt russet meadow ember willow quartz cobble onyx boulder copper saffron orbit spruce willow garnet copper glacier crimson #8303d7db"
},
{
"qid": 1,
"key": "K00079",
"v... | {
"task_family": "kv_store",
"seed": 43,
"records": 130,
"value_words": 24,
"records_per_chunk": 100,
"queries": 24,
"n_set": 130,
"n_get": 24,
"n_batches": 2,
"n_actions": 26,
"approx_value_tokens": 6303,
"approx_per_value_tokens": 48
} |
kv-store-R130-seed44 | kv_store | R130 | 44 | 32,768 | 2,048 | 26 | 7,239 | 0.221 | [
{
"index": 0,
"header": "set batch (keys 0-99)",
"body": "<<<SET-BATCH 0000#672e4e8b BEGIN -- offload this whole block this turn>>>\nSET K00000 = onyx kindle mistral ember nimbus auburn marble boulder crimson marble ember lantern thistle harbor fathom trellis auburn spruce glacier copper meadow verdant ... | {
"queries": [
{
"qid": 0,
"key": "K00027",
"value": "crimson cobalt harbor boulder auburn auburn boulder cedar marble ember lattice verdant spruce onyx lattice thistle garnet russet quartz garnet fathom harbor cedar kindle #f36ca91a"
},
{
"qid": 1,
"key": "K00017",
"va... | {
"task_family": "kv_store",
"seed": 44,
"records": 130,
"value_words": 24,
"records_per_chunk": 100,
"queries": 24,
"n_set": 130,
"n_get": 24,
"n_batches": 2,
"n_actions": 26,
"approx_value_tokens": 6292,
"approx_per_value_tokens": 48
} |
kv-store-R130-seed45 | kv_store | R130 | 45 | 32,768 | 2,048 | 26 | 7,361 | 0.225 | [
{
"index": 0,
"header": "set batch (keys 0-99)",
"body": "<<<SET-BATCH 0000#2c2d01b1 BEGIN -- offload this whole block this turn>>>\nSET K00000 = saffron onyx cobble indigo cobalt trellis verdant crimson meadow russet lantern ember boulder ember trellis zebra meadow quartz saffron willow pewter cinder m... | {
"queries": [
{
"qid": 0,
"key": "K00073",
"value": "mistral mistral vellum quartz zebra crimson cobble harbor fathom ember verdant harbor garnet cobble quartz verdant saffron nimbus glacier copper trellis auburn indigo ember #9aa8a2f9"
},
{
"qid": 1,
"key": "K00086",
... | {
"task_family": "kv_store",
"seed": 45,
"records": 130,
"value_words": 24,
"records_per_chunk": 100,
"queries": 24,
"n_set": 130,
"n_get": 24,
"n_batches": 2,
"n_actions": 26,
"approx_value_tokens": 6287,
"approx_per_value_tokens": 48
} |
kv-store-R130-seed46 | kv_store | R130 | 46 | 32,768 | 2,048 | 26 | 7,263 | 0.222 | [
{
"index": 0,
"header": "set batch (keys 0-99)",
"body": "<<<SET-BATCH 0000#e626958e BEGIN -- offload this whole block this turn>>>\nSET K00000 = meadow spruce zebra marble kindle willow mistral zebra crimson meadow glacier orbit crimson quartz boulder kindle verdant cobalt spruce russet lattice willow ... | {
"queries": [
{
"qid": 0,
"key": "K00068",
"value": "zebra mistral saffron spruce zebra vellum crimson quartz russet willow falcon mistral harbor garnet quartz garnet glacier russet cinder mistral russet cedar verdant auburn #1b879017"
},
{
"qid": 1,
"key": "K00129",
"... | {
"task_family": "kv_store",
"seed": 46,
"records": 130,
"value_words": 24,
"records_per_chunk": 100,
"queries": 24,
"n_set": 130,
"n_get": 24,
"n_batches": 2,
"n_actions": 26,
"approx_value_tokens": 6288,
"approx_per_value_tokens": 48
} |
kv-store-R130-seed47 | kv_store | R130 | 47 | 32,768 | 2,048 | 26 | 7,405 | 0.226 | [{"index":0,"header":"set batch (keys 0-99)","body":"<<<SET-BATCH 0000#c860a1b1 BEGIN -- offload thi(...TRUNCATED) | "{\n \"queries\": [\n {\n \"qid\": 0,\n \"key\": \"K00085\",\n \"value\": \"latti(...TRUNCATED) | "{\n \"task_family\": \"kv_store\",\n \"seed\": 47,\n \"records\": 130,\n \"value_words\": 24,\n(...TRUNCATED) |
kv-store-R130-seed48 | kv_store | R130 | 48 | 32,768 | 2,048 | 26 | 7,289 | 0.222 | [{"index":0,"header":"set batch (keys 0-99)","body":"<<<SET-BATCH 0000#42ed1b16 BEGIN -- offload thi(...TRUNCATED) | "{\n \"queries\": [\n {\n \"qid\": 0,\n \"key\": \"K00009\",\n \"value\": \"spruc(...TRUNCATED) | "{\n \"task_family\": \"kv_store\",\n \"seed\": 48,\n \"records\": 130,\n \"value_words\": 24,\n(...TRUNCATED) |
kv-store-R130-seed49 | kv_store | R130 | 49 | 32,768 | 2,048 | 26 | 7,316 | 0.223 | [{"index":0,"header":"set batch (keys 0-99)","body":"<<<SET-BATCH 0000#8753bc08 BEGIN -- offload thi(...TRUNCATED) | "{\n \"queries\": [\n {\n \"qid\": 0,\n \"key\": \"K00114\",\n \"value\": \"nimbu(...TRUNCATED) | "{\n \"task_family\": \"kv_store\",\n \"seed\": 49,\n \"records\": 130,\n \"value_words\": 24,\n(...TRUNCATED) |
kv-store-R260-seed42 | kv_store | R260 | 42 | 32,768 | 2,048 | 27 | 13,674 | 0.417 | [{"index":0,"header":"set batch (keys 0-99)","body":"<<<SET-BATCH 0000#9226d9e1 BEGIN -- offload thi(...TRUNCATED) | "{\n \"queries\": [\n {\n \"qid\": 0,\n \"key\": \"K00218\",\n \"value\": \"fatho(...TRUNCATED) | "{\n \"task_family\": \"kv_store\",\n \"seed\": 42,\n \"records\": 260,\n \"value_words\": 24,\n(...TRUNCATED) |
kv-store-R260-seed43 | kv_store | R260 | 43 | 32,768 | 2,048 | 27 | 13,648 | 0.417 | [{"index":0,"header":"set batch (keys 0-99)","body":"<<<SET-BATCH 0000#93fed4f3 BEGIN -- offload thi(...TRUNCATED) | "{\n \"queries\": [\n {\n \"qid\": 0,\n \"key\": \"K00129\",\n \"value\": \"thist(...TRUNCATED) | "{\n \"task_family\": \"kv_store\",\n \"seed\": 43,\n \"records\": 260,\n \"value_words\": 24,\n(...TRUNCATED) |
ContextBench
ContextBench measures what an agent keeps, updates, and offloads when its input does not fit in its context window. Each task streams a sequence of operations as ordinary user turns, more than the context budget holds, and the reward is read from the agent's own messages: what survived in its context, not what it wrote to disk.
Paper: Context Language Models (paper page)
Families
| config | task | reward |
|---|---|---|
kv_store |
batches of SET key = value, then GET key queries |
fraction of GETs answered with the right value |
log_triage |
batches of service log lines, then count and lookup questions | fraction of questions answered correctly |
needle_retention |
chunks with a few needle lines inside a large filler block | fraction of needle lines still present verbatim |
sudoku_sketchpad |
one fully specified move per turn on a 16x16 board | fraction of gold board versions the agent displayed |
The all config holds every instance. This release has 256 instances:
64 kv_store, 56 log_triage, 80 needle_retention, 56 sudoku_sketchpad (32 levels, seeds 42-49), with a context budget of 32768 tokens
and a reserve of 2048.
Columns
| column | type | meaning |
|---|---|---|
task_id |
string | <family>-<level>-seed<seed>, also the Harbor task directory name |
family |
string | task family |
level |
string | difficulty level |
seed |
int | generator seed |
budget |
int | context budget in tokens |
reserve |
int | tokens reserved for the reply; the agent may use budget - reserve |
n_ops |
int | number of streamed operations |
streamed_tokens |
int | tokens streamed over the episode (o200k_base) |
pressure |
float | streamed_tokens / budget |
chunks |
list of {index, header, body} |
the operations, one user turn each |
gold |
string (JSON) | the answers the graders score against |
meta |
string (JSON) | generator settings and instance statistics |
The budget is counted in o200k_base tokens for every agent. An agent may enforce a
stricter budget of its own; that is part of the agent, not of the benchmark.
Each operation is shown to the agent as
=== {header} ({remaining} op(s) remaining after this) === followed by its body.
Usage
With datasets
import json
from datasets import load_dataset
ds = load_dataset("context-language-model/ContextBench", "kv_store", split="test") # or "all"
row = ds[0]
ops = row["chunks"] # list of {"index", "header", "body"}
gold = json.loads(row["gold"])
To evaluate an agent from Python, install the contextbench package, write an
instance to disk, and pass your agent to contextbench.run:
from pathlib import Path
from contextbench import run
inst = Path("instances") / row["task_id"]
inst.mkdir(parents=True, exist_ok=True)
(inst / "chunks.jsonl").write_text(
"".join(json.dumps(c) + "\n" for c in row["chunks"]))
(inst / "gold.json").write_text(row["gold"])
(inst / "meta.json").write_text(row["meta"])
result = run(my_agent, inst, budget=row["budget"], reserve=row["reserve"],
out_dir=Path("runs") / row["task_id"])
With Harbor
The harbor/ directory holds one Harbor task per instance, and registry.json
lists the datasets contextbench (every task) and contextbench-<family>
(for example contextbench-kv-store). The same tasks are on GitHub, so Harbor runs
them in one line:
harbor jobs start --repo RulinShao/ContextBench -d contextbench \
-a contextbench.harbor.agents:Terminus2Stream -m <model>
Or download this repository and run Harbor from inside it:
hf download context-language-model/ContextBench --repo-type dataset --local-dir contextbench-hf
cd contextbench-hf
harbor jobs start --registry-path registry.json -d contextbench \
-a contextbench.harbor.agents:Terminus2Stream -m <model>
Use -d contextbench-sudoku-sketchpad for one family, -i <task_id> for one task,
-p harbor/ to run the downloaded directory without the registry, or -a oracle to
check a task with its reference solution. Agents that deliver operations into a running
conversation ship with the contextbench package (contextbench.harbor.agents).
Citation
ContextBench was introduced in the Context Language Models paper. If you use it, please cite:
@article{shao2026context,
title = {Context Language Models},
author = {Shao, Rulin and Shen, Shannon Zejiang and Yin, Junjie Oscar and Li, Yuetai and
Wang, Minheng and Ivison, Hamish and Poovendran, Radha and Lambert, Nathan and
Xiao, Teng and Lewis, Mike and Yih, Wen-tau and Zettlemoyer, Luke and Koh, Pang Wei},
journal = {arXiv preprint arXiv:2609.37725},
year = {2026}
}
License
Apache-2.0.
- Downloads last month
- 22