Semantic Context Handoff: On-Demand Evidence Recall for Long-Horizon Agents

SCH separates agent state from evidence and recalls early evidence on demand, achieving both accuracy and low cost.
Stuffing all action-observation history into the context of long-horizon LLM agents inflates inference cost and can reduce accuracy, while existing compression schemes retain conclusions and discard observations—risking loss of evidence that becomes critical later. Semantic Context Handoff (SCH) proposes state-evidence separation: a compact semantic state carries the agent's current understanding, while raw evidence remains independently addressable and re-enters context on demand, with no extra summarization or retrieval model calls. In a controlled 150-task SWE-bench study, evidence recovery raised Pass@1 from 80.0% to 86.9% with token usage and execution time essentially unchanged; in a full-system comparison it used 43% fewer tokens and 41% less wall-clock time than the strongest baseline. Trajectory analysis confirms that recalled evidence comes from a fairly early point in history, not merely from a recent window.
The traditional approach for long-horizon LLM agents is to stuff every historical action-observation interaction into the context. As execution progresses, the history keeps growing, inference costs rise, and accuracy may actually decline. Existing compression schemes typically retain condensed conclusions while discarding early observations—but discarded evidence may become critical again in later steps. Semantic Context Handoff (SCH) proposes a new approach: managing "state" and "evidence" separately.

Core Mechanism: Separating State and Evidence
The core abstraction of SCH is state–evidence separation. A compact semantic state carries the agent's current understanding of the task, while the action-observation evidence supporting that understanding remains independently addressable and is not compressed along with the state. When later execution makes some piece of early evidence relevant again, it can re-enter the context on demand—without any additional summary generation or retrieval model calls.
This is fundamentally different from "keep the recent window" sliding-context strategies. SCH's design goal is not to maintain a fixed-length recent memory, but to allow evidence to be recalled from much earlier in the interaction history when needed. Trajectory analysis confirms this: the evidence SCH recovers comes from a fairly early position in the interaction history, rather than merely preserving a recent context window.
Action-observation evidence refers to the two types of information the agent produces at each execution step: what tool it called or what action it took (action), and what result the environment returned (observation). In coding agents, this typically corresponds to a file read, a command execution, or a test run and its output. Unlike natural-language dialogue history, this kind of evidence is structured and precisely locatable, making it suitable as an independently addressable storage unit rather than being mixed into the same context as semantic summaries.
Measured Results: A Win-Win for Accuracy and Cost
In a controlled 150-task SWE-bench study, SCH's evidence recovery mechanism raised Pass@1 from 80.0% to 86.9%, while token usage and execution time stayed essentially unchanged. This shows that the gains from on-demand evidence recall do not come at the cost of extra inference overhead.
In a full-system comparison, SCH achieved 86.9% Pass@1 while using 43% fewer tokens and 41% less wall-clock time than the strongest-performing baseline. Across models and benchmarks, SCH consistently reduced token usage relative to full-history prompting while matching or outperforming the evaluated baselines.
Pass@1 is a metric commonly used in code generation and software engineering benchmarks: a single solution is generated per task, and if it passes all tests it counts as a success; the final score is the success rate across all tasks. It is stricter than Pass@k (which allows multiple samples and counts a success if any one passes) and more directly reflects a model's ability to get it right in one shot in real deployment. SWE-bench is a benchmark for evaluating agents on fixing issues in real GitHub repositories; tasks typically require multi-step localization, modification, and verification, making it especially sensitive to long-horizon context management.
Why Evidence Shouldn't Be Discarded Prematurely
The difficulty of long-horizon tasks is that relevance changes dynamically. An early observation that seems irrelevant at the moment may become the basis for a decision dozens of steps later. Full-history prompting retains all evidence, at the cost of continuously growing context; "compress conclusions, discard observations" schemes control cost but sacrifice the traceability of evidence.
SCH's trade-off: conclusions are retained as a compact semantic state, and raw evidence does not participate in normal context growth but remains addressable. This layered management approach lets agents avoid carrying heavy history during long-horizon execution without losing the ability to look back at early evidence.
Sliding window context is a common context management strategy: keep only the most recent several turns of interaction and truncate anything beyond the window. Its advantages are simple implementation and constant context length, but its drawbacks are obvious—once key evidence slides out of the window, it cannot be recovered, and the choice of window size depends heavily on task length. SCH differs from it not in window size, but in that evidence is not discarded as context advances; it simply exits the normal context while retaining addressability, enabling recall across history far beyond the window range when needed.
Implications for Agent Engineering
From an engineering perspective, SCH's value lies in splitting "context management" into two independently optimizable dimensions: state representation needs to be compact, and evidence storage needs to be retrievable. This is easier to implement than blanket context compression, and it avoids the extra inference overhead of calling a summarization or retrieval model separately for each piece of history.
For teams building long-horizon coding or automation agents, this means the context strategy does not have to be a binary choice between "retain everything" and "aggressive compression." Separating conclusions from evidence and recalling on demand is a path that balances both accuracy and cost.
Related articles

Hero or Luck? Technical Reflections Sparked by an Arizona Grandfather Finding a Missing Toddler in the Desert
An Arizona grandfather finding a missing toddler in the desert hits Hacker News. This article analyzes emergency search, drone thermal imaging, child location devices, and community collaboration, exploring the boundaries of technology and human effort in extreme environments, while noting the material's limitations.

Run Agentic Coding on Mac with One Command: The Localcode Open-Source Tool
Localcode is an open-source agentic coding tool for Mac that launches with a single command. This article examines its local, open-source, minimal-install positioning, who it suits, and the information gaps to consider before adoption.

Lean Formalization of Masullo Manuscript: Progress Map Sparks Discussion
A public progress map for a Lean formalization project of Alessandro Masullo's manuscript sparks Hacker News discussion on formalization costs, collaboration, and AI-assisted proving.