This repo includes trajectory extractors for different coding agents, exposed via a unified API.
- Format:
.traj.jsonfiles - Location:
contextbench/agents/minisweagent/extract.py - Notes:
- Extracts file views from bash commands in messages
- Supports
cat,sed -n,head,grep,nl | sedcommands - Parses
patch_context_data.patch_contextfor final context - Returns model patch from
info.submission
- Format:
.checkpoints.jsonlfiles - Location:
contextbench/agents/sweagent/extract.py - Notes:
- Extracts from
str_replace_editor viewcommands with--view_range - Only includes steps with explicit line ranges
- Parses
patch_contextstring format (File:/Lines:)
- Extracts from
from contextbench.agents import extract_trajectory
result = extract_trajectory("path/to/trajectory.traj.json")
result = extract_trajectory("path/to/trajectory.checkpoints.jsonl")The extractor returns a unified structure:
{
"pred_steps": [{"files": [...], "spans": {...}}, ...],
"pred_files": [...],
"pred_spans": {...},
}python -m contextbench.evaluate \
--gold Context-dataset/Verified/annots_pass \
--pred traj_verified-mini/instance/instance.traj.json \
--out results.jsonl