Long-horizon agent traces are complete records of runs with many steps, often more tokens than the model's context window and hours of work. To fit, harnesses compact the context into a summary, clear old tool results or offload large ones, which cuts the middle out of what the model sees. Keep a second, raw run log with every step and full tool result, so the run stays whole even when the context does not.
- A long run is measured in steps, tokens and wall time. Record all three.
- Compaction, tool-result clearing and offloading each change what the model sees mid-run.
- Keep two histories: the model-facing context and a raw run log.
- Do not trim runs yourself. A buyer can always cut a full run; nobody can restore a cut one.
- Label any run whose middle was summarised.
What is a long-horizon agent run?
A run with many steps that takes more context than the model can hold at once, often over hours. In production that might be an incident investigation that reads dozens of logs, or a month-end reconciliation that works through hundreds of lines.
They are the minority. A survey of production teams found "68% execute at most 10 steps before human intervention" (Measuring Agents in Production, arXiv 2512.04123). That is part of why complete long runs are scarce and why buyers ask for runs of about 100K tokens or more.
Why do buyers want nothing cut from the middle of agent traces?
The middle is where the agent picks a wrong tool, re-reads a file, notices a mistake and recovers. A run with only its start and end shows that the job got done, not how.
Buyers turn traces into tasks for training and testing, and a task can be built only from a run that keeps "enough of the original environment for another model to attempt the work", as a trace buyer's published essay (1 October 2026) puts it. How much of a run to train on is a choice the trainer makes. One study found "Reliability improves with longer horizons but saturates", and that "short horizons cause premature termination, intermediate horizons yield productive error recovery" (arXiv 2610.05831). A buyer can shorten a full run; nobody can restore a cut one.
Does context compaction delete parts of an agent's trace?
From the model's view, yes: after compaction the model works from a summary, not the original steps. Whether the steps survive anywhere else depends on what your harness writes to its log.
Researchers who studied it note that compaction is "typically triggered when context usage exceeds a threshold, e.g., 95% of the allowed context window" and that "Context compaction itself introduces a new failure mode" (Context Compaction Theory, arXiv 2608.01326). Three techniques are common.
| Technique | What it does | What to check in your logs |
|---|---|---|
| Compaction | Rewrites the history into a summary. OpenHands' condenser "replaces the dropped events with an LLM-generated summary" (OpenHands docs) | Whether the events before the summary are still stored |
| Tool-result clearing | "Clearing drops old, re-fetchable results while keeping the record that the call happened" (Claude cookbook) | Whether the full tool result was logged before it was cleared |
| Offloading | "Tool result and media offloading keep large data out of the model's context and the database" (Agno) | Where the offloaded results went, and whether they are kept as long as the run |
How do you keep a complete record of a 100K-token agent run?
Keep two histories. The model-facing context can be compacted and cleared as the harness needs; the raw run log keeps every step, every full tool result and the reasoning, written as the run happens and never rewritten.
Many tools already keep such a log if you let them. OpenHands' persisted events represent "the same trajectory data you would find in the trajectory.json file" (OpenHands docs). Agno v3.0 "moves runs out of the sessions blob into a dedicated" runs table (Agno). In LangGraph, checkpoints keep each step's state, and "the checkpoints will be ordered chronologically with the most recent checkpoint" first (LangGraph docs). The export guide covers getting them out.
Where does each harness keep the full run?
Check each one against the three techniques above. Settings and defaults change between versions, so read the docs for the version you run.
| Harness | What can cut the middle | Where the full record can live |
|---|---|---|
| Claude Agent SDK and Claude Code | Compaction and tool-result clearing | Your own log of every request and response, written before compaction |
| OpenHands | Condensers | The persisted event store |
| Agno | Tool result and media offloading | The runs table, plus wherever offloaded results are stored |
| LangGraph | Summarisation nodes you add | Checkpoints, joined to model-call spans |
| OpenAI Agents SDK | Your own trimming of inputs | Spans; "Tracing is enabled by default" (Agents SDK docs), and you can add your own processor to keep a copy |
One gap to know about: "Tracing is unavailable for organizations that use OpenAI's APIs under a Zero Data Retention (ZDR) policy" (Agents SDK docs). Teams under such a policy need their own log if they want a record at all.
How do you measure tokens per agent run?
Add up the usage fields of every model call in the run: input, output and reasoning tokens, plus the number of steps and the wall time from task to result. Record cached input separately if your provider reports it.
If you use OpenTelemetry GenAI spans, the output token count "SHOULD include reasoning tokens and tokens of all modalities" (OpenTelemetry), so do not add reasoning on top. Open-weight servers return reasoning in its own field; see open-weight agent traces.
Checklist: is the run complete?
Run these checks on a sample before you call a set complete.
| Check | Pass when |
|---|---|
| Every step present | Step count in the raw log equals the model-call count in usage |
| Full tool results | No result is a reference, a placeholder or cut at a fixed length |
| Compaction marked | Each compaction event is in the log, with the steps before it kept |
| Offloaded results joined | Every offloaded result is back in the run or linked by a stored ID |
| Reasoning | Full, summary or none is recorded for each run |
| Measured | Tokens in, out and reasoning, steps and wall time are filled in |
| Outcome | An outcome label and its source are filled in |
Common mistakes with long runs
Most of them lose the middle without anyone noticing.
- Exporting the model-facing context and calling it the trace.
- Logging tool results only up to a character limit.
- Turning compaction off in production to keep traces whole, instead of keeping a raw log beside it.
- Deleting offloaded results on a shorter schedule than the runs.
- Trimming long runs before sharing them to make them look tidy.
- Counting reasoning tokens twice.
Complete long runs as a data asset
Long runs with every step kept, reasoning included and a checked outcome are the rarest part of agent data. If your raw log already holds them, you have something many teams lost to compaction.
Origin helps you check how complete your runs are, describe them and plan the redaction with the redaction checklist. Nothing leaves the company at the start. We help you license your data. Origin Data Partners is an independent data partner: we tell you what your records could be worth and prepare the records, the terms and the license with you. The AI company that licenses them pays your company; a buyer may pay Origin when a deal closes.
Does your company hold records like these? See what your data is worth.
Common questions
Does compaction mean our old agent runs are useless?
No, if a raw log of each step exists somewhere else. Check your tracing tool, checkpoints or event store before you decide; many keep more than the model saw.
How long does an agent run have to be to count as long-horizon?
There is no fixed line. State steps and tokens for each run; the runs buyers ask for are about 100K tokens or more each.
Should we turn context compaction off to keep traces complete?
No. Compaction keeps the agent working. Keep a raw run log beside it instead, written before anything is compacted or cleared.
Do summarised agent runs have any value?
Some, mainly for checking outcomes. Label them as summarised so nobody mistakes them for complete runs.
How do we count reasoning tokens in a long agent run?
From each call's usage fields. Open-weight servers return reasoning separately; under OpenTelemetry GenAI the output count already includes reasoning tokens.
Sources and further reading
- Measuring Agents in Production (arXiv 2512.04123)
- Supervision horizon in terminal-agent training (arXiv 2610.05831)
- Context Compaction Theory (arXiv 2608.01326)
- OpenHands SDK docs: context condenser
- Claude cookbook: memory vs. compaction vs. tool clearing
- Agno: what actually breaks agents in production (Agno v3.0)
- OpenHands SDK: conversation persistence
- LangGraph docs: checkpointers
- OpenAI Agents SDK docs: tracing
- OpenTelemetry GenAI semantic conventions: agent spans
