Long horizon coding agents accumulate large amounts of context in the form of conversational history, tool call results, code chunks, and system instructions among other things.
Context management becomes especially crucial with longer, more nuanced tasks.
Each component contributes to the context of the coding agent and indirectly plays a role in its behavior towards the completion of the task.
With each model having its defined context window limit, the approach for context management can also differ.
In Metaphor's Native setup, automatic compaction was configured to run when context approached its limit, replacing older history with a summary.
Metaphor runs its own coding-agent harness, including the context management used when it calls the underlying model.
We built a semantic context-compaction system for our coding agent, reduced its working context measurably, while it cost more to complete tasks.
We set out to make Metaphor more price effective by improving the efficiency of the context window. The central idea was that an agent shouldn't need to retain all of the exploration history once it had resolved the sub task that prompted that exploration, and instead preserve the decisions, evidence, and active working state for the primary task, maintaining the precise context needed by the model for that turn.
However, the implementation worked, the economics didn't.
The experiment
Existing context compaction addresses what needs to be focused on from the context, as the task progresses. But we wanted to investigate whether when and how the context was compacted could be improved by understanding the structure of the task itself.
The premise was that instead of primarily relying on context pressure when it approaches the context window limit, to determine when to compact, what if we could identify meaningful transitions in the agent's work? When an investigation concludes, an implementation phase begins, or a subtask is resolved, we could checkpoint the relevant state, preserve the decisions and evidence that still matter, and flush out the history that produced them.
The objective was different from summarizing more aggressively. We wanted to reduce the total inference cost of completing a coding task without compromising the agent's ability to finish it correctly. And that's the distinction that shaped the experiment approach.
Implementation overview
We built a semantic context-compaction (SCC) mechanism, and integrated it directly into Metaphor's coding-agent harness.
A task when defined with the objective, followed a broadly structured process of understanding the task, tool calls and analyzing the relevant files, and execution followed by tests and follow up corrections if needed. This structure served as a potential to improve the context maintained in a session.
SCC evaluated whether the agent had reached an appropriate checkpoint boundary. When a checkpoint was triggered, SCC summarized the relevant history and reconstructed the context presented to the model, retaining the information needed to continue while removing portions of the earlier execution trace.
Different from an external memory system, this operated inside Metaphor's context-management path and physically changed the message history, replacing eligible earlier spans with a phase-based summary used for subsequent inference calls.
There is a clear tradeoff with this approach of identifying checkpoints and producing summaries requiring additional model invocations. And we needed to measure this trade-off. It would only be worthwhile if the compactions resulted in future reduction of inference costs enough to more than compensate for the cost of these additional steps.
Testing the implementation
We evaluated SCC against Metaphor's native context management on long horizon software engineering tasks.
This was an internal comparison between two context-management configurations of Metaphor's own coding-agent harness, not a comparison against other coding agents. Native was already an efficient baseline; we were testing whether SCC could improve it further.
For the primary benchmark campaigns, we used GPT-6.1 Sol at high reasoning effort. Within each paired comparison, we used the same frozen Metaphor runtime and model, changing the context-management configuration to isolate the effect of SCC. An earlier, limited four-task pilot used GPT-5.2; the SCC implementation also evolved between the later benchmark campaigns.
The evaluation setup consisted of SWE-bench Pro tasks, Harbor for benchmark orchestration, and Modal for isolated execution environments.
The two primary configurations were Metaphor Native, with its existing context management and compaction behavior, and SCC, with semantic checkpointing enabled to replace eligible earlier history with a structured summary.
Within each paired benchmark comparison, we held the underlying model, reasoning configuration, task definitions, execution environment, and runtime artifact constant. We collected provider-level inference telemetry, including model requests, cached and uncached input, output tokens, subagent activity, checkpoint events, and total inference cost. The outcome that mattered was the cost of completing the task, alongside whether the agent's execution remained correct. The later 15-task evaluation used an updated SCC revision, and the multiturn V1 and V2 comparisons used different user scripts.
The expectation, as mentioned above, was that semantic checkpoints would allow Metaphor to retain smaller, more relevant working contexts and avoid paying repeatedly for history it no longer needed.
What we found: SCC reduced context occupancy, but it didn't reduce inference cost in our completed revised V2 comparisons.
The results led to a deeper dive into the overheads of the checkpoint identification and summarization, the attempts to reduce the cost, and the understanding of how these attempts worked and didn't.
The evolution of the Semantic Context Compaction system
The first implementation of the SCC was built with the distinction of the agent's execution history and the state it actually needed to continue the task.
Blanket compaction of the agent's history would be obviously counterproductive. We wanted the compaction to be sensitive to the progress of the task, rather than treating the accumulated conversation as a single block of history to summarize.
We introduced a structured representation of the agent's context inside Metaphor. The initial design separated the task objective (Q), a summary of earlier work (M), and the active working context (W). As we further iterated, we added a fourth component (R) which was the pinned evidence which allowed specific file contents, observations, and technical findings to remain intact even across checkpoint boundaries without depending entirely on their summarized representation.
Based on the semantic approach of identifying checkpoints, these components were fundamental — the task contract maintained the focus on the task objective, the summary retained what had been learned from previous phases, the working context kept recent messages and tool interactions in their original form, and the pinned evidence preserved information that was important not to lose through summarization.

Figure 1. Illustrative SCC checkpoint showing the task contract (Q), summarized prior work (M), pinned evidence (R), and active working context (W).
The checkpoints
SCC was set up to have a semantic controller into the coding agent to evaluate the phase of the task the agent was at a given moment. The controller evaluated the state and whether the agent had reached a meaningful boundary at which older work could be compacted. Rather than applying checkpoint purely based on token count threshold, the system could consider whether a phase of work had actually concluded.
When a checkpoint was approved, the summarizer consolidated eligible earlier history into an updated summary. The context was then reconstructed for the next model request, retaining the task contract, summarized history, selected evidence in later versions, and active working context.
The active phase was not summarized along with everything preceding it. The setup intentionally deprioritized completed work while retaining the new interactions in raw form.
The cost of context decisions
With each checkpoint analysis and summarization for the accepted checkpoint, came the cost associated with each component. Checkpoint decisions required additional inference and so did generating the summary. In addition, reconstructing the conversation could change the prompt prefix presented to the model and reduce cache reuse on subsequent calls.
This made the SCC setup one layer more complex than being able to simply compare the effects of regular phase wise compaction of context vs native context window threshold compaction.
Fundamentally, the cost saved from having a smaller context in the subsequent model requests, was supposed to be larger than the cost of identifying checkpoints, and summarizing at each checkpoint.
If checkpoints were too frequent, occurred too early, or changed the agent's subsequent behavior in costly ways, the additional overhead could diminish or erase the benefit.
Before the full benchmark: the initial pilot
Before the larger evaluation, we piloted SCC on four difficult SWE-bench Pro tasks using GPT-5.2. Six of eight scored runs reached the 2,940-second time cap and cost accounting was incomplete, so we treated the pilot as an early implementation test rather than a dependable cost comparison. It exposed a mismatch between reconstructed context and file-read state, which we corrected before scaling up, along with stricter checks against empty or undersized checkpoints.
The First Large-Scale Results
We then evaluated SCC across the SWE-bench Pro V2 Hard-51 tasks.
Of the 51 tasks, 41 produced valid paired runs. The remaining 10 pairs did not start because of an execution-environment incompatibility, and were excluded from the reported results.
The HARD-51 subset refers to the 51 most challenging, long-horizon software engineering tasks featured in the SWE-Bench Pro V2 benchmark.
The results with running the Hard 51 tasks proceed that the SCC implementation could do what it was designed to do mechanically. It could reduce the amount of historical context carried through the context used by the coding agent through the task execution.
But it didn't go far enough to support the entire claim. In the 41 valid paired runs, Native solved 36 tasks and SCC solved 35, so task-solving outcomes were close but not identical. At the same time, SCC reduced the mean peak context from approximately 110k to 60k tokens.
The other important distinction was comparing the default compaction trigger for Metaphor against the SCC setup. In the tested high-context configuration, Metaphor's Native automatic compaction was triggered by context pressure rather than task-phase boundaries. It did not trigger in any of the HARD-51 pairs. This made an important distinction in the experiment: these runs compared proactive SCC against Native retaining the original history, rather than a comparison between two mechanisms that had both actively compacted context.
The early pilot had already exposed a file-read-state defect, which we corrected before the large-scale campaign. The HARD-51 results then sharpened the questions around checkpoint evidence handling and whether further improvements could overcome the added inference cost.
The further changes and tweaks addressed specific implementation problems, but weren't enough to establish SCC as more economical.
What the full HARD-51 benchmark results showed
Across the Hard-51 pairs, total provider inference spending was $86.47 for Metaphor Native versus $117.19 for SCC, approximately 35.5% higher for SCC.

Figure 2. HARD-51: 41 valid paired tasks; mean peak context, total provider inference cost, and task-solving outcomes.
Native automatic compaction did not trigger during the valid runs. That distinction mattered: SCC was introducing paid checkpoint decisions and summarization in executions where the Native approach had not yet needed to compact. Reducing the retained history was working, but there was not enough avoided inference cost to pay for the intervention.
The results made it difficult to justify the system economically in its initial form. We still had to resolve implementation issues, but the larger question was whether better checkpoint decisions and more reliable evidence handling could change the cost equation.
Making checkpoints reliable
A fascinating consideration we found was that compacting an agent's conversation can leave other parts of its execution state inconsistent with what the model knows at that point. Our early task runs revealed exactly this.
The coding agent tracked previous read files to avoid repeatedly returning unchanged contents. Native compaction cleared this state when considering the earlier history to be redundant. However, our initial checkpoint implementation did not.
This resulted in the agent requesting a file and receiving a response indicating that its contents were unchanged from an earlier read even though that earlier result had been removed from the conversation by SCC.
The issue wasn't about summarization done by SCC but more about the fact that the tool layer and the reconstructed conversation did not match on what information was available to the model.
We corrected file-read state management after the early pilot, before the first large-scale HARD-51 campaign. Later revisions separately improved how checkpoints preserved evidence.
The later tweaks added a dedicated evidence layer and refined range handling and cache stability so we could preserve important source information without repeatedly rewriting the same context. In one Tutanota regression, the V2 run failed at $19.30 while V2.1 passed at $6.79. However, that single-task improvement wasn't evidence of a general cost advantage.
The collateral effects caused by singular changes were interesting to see.
Evidence handling was not the end of the iterations
The evidence layer was only one of several changes we made after the first HARD-51 results. We added a controller pre-gate intended to avoid unnecessary expensive checkpoint decisions and tested the revised system on a small set of regression tasks. The Tutanota improvement was encouraging, but the other results and the broader Native comparison still worked in favor of the native approach and failed to make SCC as a generally cheaper default.
We also investigated whether checkpoint selection could be cheaper. One experiment used GPT-6 Luna instead of calling the more expensive Sol model. Across 104 shadow decisions, it recovered only 45.5% of the positive decisions made by Sol, below the 90% recall gate we had set. We did not continue to use that cheaper controller in a paid solver run. We also built a Jev-based pre-gate to decide when the expensive Sol controller could be skipped. It was fast and inexpensive, but the conservative rule skipped no calls; a less restrictive rule showed only modest savings. These were shadow investigations, not changes to the GPT-6.1 Sol executor in our paid benchmark runs. Neither Jev nor the later feature-based gates were enabled in those runs. The purpose of these changes was to attempt to bring the costs down for the SCC compaction overhead.
The cost problem remained
Using a later frozen SCC revision, V2.2, we ran another paired evaluation on 15 HARD tasks with GPT-6.1 Sol. Native solved 15/15 tasks and SCC solved 14/15; total inference cost was $26.14 for Native and $31.21 for SCC.
SCC reduced executor prompt tokens by 23.7%, but the total provider inference cost rose by 19.4%. We had now seen a similar mismatch across two successive evaluations of the HARD task family, using different SCC revisions: less context entering the executor, but no corresponding reduction in what it cost to complete the work. These were not independent benchmark populations.

Figure 3. Later 15-task V2.2 evaluation: lower executor prompt tokens, higher total inference cost, and 15/15 versus 14/15 solves.
The earlier HARD-51 study had also shown why. Native's automatic compaction never fired. So SCC had to recover costs that the baseline wasn't paying for in the first place. Even as we improved checkpoint correctness and reduced some wasted operations, the basic economics remained difficult.
At that point, further tuning on isolated benchmark issues was unlikely to answer whether SCC could become worthwhile in a long-lived session. These runs showed the cost of proactive checkpointing before Native needed to compact, but not whether preserving less history would pay off when the agent continued through multiple related requests.
So we wanted to test the system under a different workload: one where the agent would keep working in the same repository and session across multiple related user requests, rather than treating each benchmark issue as an isolated run. If SCC had a natural advantage, it was more likely to emerge once earlier phases of work had become genuinely historical, while the session still had more work ahead of it.
Evaluating continuous multi-turn work
We moved to scripted user conversations built around SWE-bench Pro V2 tasks. Each scenario consisted of eight sequential user instructions delivered into a continuous coding session. The later turns extended the development workflow with related follow-up work and review, rather than starting over with a new task and a fresh conversation history.
The idea was to replicate a natural user flow and conversation when working on a task, including discussion, brainstorming, planning, and review in addition to the execution of the task itself.
This gave us a way to evaluate what happened to the cost of the whole session as completed work accumulated. Native and SCC started from matched task environments and received the same scripted user turns in separate runs. The comparison kept the underlying model and the frozen Metaphor runtime constant within the scenario. The main question was whether semantic checkpoints became economically useful in a longer sequence where the agent had to keep carrying forward earlier decisions and results.
The results that seemed to work
The first completed multiturn run on an Element Web task appeared to validate the intuition/hypothesis we began with.
We ran native and SCC and both reported a reward of 1.0, but their inference costs differed substantially.
Native cost $18.41 and SCC cost $8.73.
The first multi-turn result looked promising
The first completed Element Web multi-turn comparison looked much closer to what we had expected. SCC was about 52.6% cheaper than Native, and peak context fell from around 350K to 102K tokens.
It was encouraging, but we didn't treat the difference as a general result. The savings were concentrated in later turns, so we went back to the execution traces to understand what those turns had asked the agent to do.
The result changed when we revised the scenario
That investigation found that two later user turns contained largely overlapping requests to review the work completed so far. Native had accumulated a substantial conversation by that point, and one of those turns alone cost $8.35 at long-context rates.
SCC had a genuine advantage on that workload: it could retire historical execution details before the expensive review turns. But the repeated review requests also made the scenario unusually favorable to proactive compaction.
We revised the later turns so the scenario no longer depended on repeated broad reviews and re-did the comparison, without changing the frozen Metaphor runtime.
The results were reversed. Both reported a reward of 1.0. But on Element Web V2, Native cost $6.13 and SCC cost $7.18. On Teleport V2, Native cost $8.38 and SCC cost $8.80. Across the two completed paired scenarios, SCC was 10.1% more expensive.

Figure 4. Multiturn provider inference cost across Element Web V1, revised Element Web V2, and Teleport V2. V1 and V2 used different user scripts.
These were the two completed V2 paired scenarios; other attempted scenarios timed out or remained unfinished, so we could not draw a five-scenario conclusion.
The V1 saving was strongly dependent on the workload. Once the duplicated review behavior was removed, SCC was still reducing context, but the avoided cost no longer covered checkpoint selection, summarization, and changes in subsequent execution.
Assessing the cost
By this point, the question was no longer whether SCC could compact successfully. It could. We needed to understand why reduced context wasn't translating into a lower cost across the completed, more controlled workloads.
The provider-call logs showed that the relevant comparison was the full execution cost — the main agent's requests, subagent activity, checkpoint controller calls, summarization, and the cache behavior of the resulting prompts. Shorter context could lower the cost of individual requests while still increasing the number of requests, altering cache reuse, or sending the agent down a more expensive execution path.
We evaluated and investigated the previous run's trajectories. Some policies appeared to recover part of the overhead under fixed-behavior assumptions. But those replays could not establish what the agent would actually do once its context changed; the same history that determines cost also affects the next decisions the model makes.
The later cost-opportunity audit did not support a credible path to our roughly 20% targeted savings from checkpoint tweaking alone. We had reduced context, identified and repaired correctness problems, and improved specific regressions, but we could not establish that SCC was a better default for cost.
Why we paused SCC
We stopped further SCC experiments because the economics hadn't justified the overhead complexity. Nor were we seeing the needle move in that direction with progressive tweaks. That was a decision about the system we tested and the goal we had set for it, not a claim that semantic checkpointing can never be useful.
The experiments led to a specific conclusion that SCC could help in certain long-context workloads, especially when Native was paying heavily to revisit a large history. But across the completed revised multi-turn comparisons, and in the broader HARD-task evaluations, reducing the context alone had not resulted in lower total cost at comparable task-solving performance, and SCC solved one fewer task in each HARD-task evaluation.
The more general finding was that the context compaction caused collateral changes in behavior, not just a reduction in input tokens. Its value depends on when the intervention happens, how it changes cache economics, what it preserves, and how the agent behaves afterward.

Figure 5. Measured inference-cost differences for SCC versus Native within each completed paired evaluation. These are different workloads and SCC revisions.
The additional investigations
The following is a technical record of further testing and experiment attempts we made to improve the results and assess whether SCC could still be made economical.
Checkpoint policy and controller cost
We tested stricter checkpoint gates, cheaper boundary decisions, and alternative approaches of combining controller and summarization work. The Luna shadow controller did not meet our decision-quality gate and we did not consider it for a solver run. We then investigated whether a pre-gate could avoid some of the expensive Sol controller calls without making the checkpoint decision itself. We also tried to combine the gate and the summary, but did not see the cost reduction we expected. The crucial distinction came down to the setup present in the codebase and the setup actually exercised by the agent.
Jev: could a cheap classifier skip the expensive controller?
The Sol semantic controller was a meaningful cost of SCC. Rather than replace Sol's checkpoint decision with a cheaper model, we tried having Jev be a precursor to it. Jev received a snapshot of the current task state, previous summary, and recent agent activity. It estimated whether the agent had transitioned to a new phase, whether it was continuing the same activity, and whether skipping Sol was safe. Jev could only skip the Sol call. It never selected a checkpoint boundary or wrote a summary. Errors were configured to fall through to Sol.
We shadow-tested the gate on 104 archived controller opportunities: 33 historical Sol checkpoint decisions and 71 no-checkpoint decisions, including 11 manually labeled critical transitions. Jev returned valid responses for all 104. The 104 calls cost $0.069 in total and averaged 168 ms, versus approximately 9.9 seconds for the historical Sol controller calls. The cost advantage per decision was large, but it only mattered if Jev could safely avoid enough of the expensive calls.
Our original three-question rule preserved every Sol checkpoint decision and every labeled critical transition, but it skipped zero of the 71 Sol no-checkpoint calls. It was conservative enough to be ineffective, therefore adding Jev made that replay about 1.7% more expensive than calling Sol alone.
We then reanalyzed the same frozen Jev responses using a simpler rule — skip Sol when Jev's estimated probability of a phase transition was at most 0.35. That retained all 33 historical Sol checkpoint decisions and all 11 labeled critical transitions, while skipping 14 of 71 historical no-checkpoint decisions. In a static cost replay, Sol-controller spending including Jev decreased from $4.132 to $3.846, a 6.9% saving on the controller portion, not on the end-to-end agent. The skipped calls tended to be the less expensive, early backstops, and a static Tutanota replay still left SCC about 4.7% costlier than Native.

Figure 6. Jev shadow-analysis results. Controller replays are counterfactual; Jev was not used during the paid solver benchmarks.
That limitation led us to V2.4's deterministic-feature analysis. We extracted 113 features from agent activity and tested rule-based and learned gates against archived Sol decisions. Some rules preserved critical transitions in the development data, but recovered too little controller cost.
The important observation was that the easiest decisions to skip were also the cheapest. Longer model controller checkpoint checks were more expensive but were more accurate to distinguish safely from actual phase transitions. We left the Jev gate disabled. These figures came from shadow measurements and fixed-trajectory/offline replay; no Harbor or SWE solver run used Jev, and the savings were not validated through a changed live execution trajectory.
Offline costs
We reconstructed provider-level costs and evaluated alternative checkpoint schedules against recorded trajectories. A candidate gate suggested savings relative to Native under modeled, unchanged-agent behavior, but stronger follow-up audits found the remaining realistic opportunity insufficient for the original target. These were counterfactual calculations, not paid confirmation runs of modified policies. They helped decide which ideas not to implement; they did not demonstrate a new cheaper configuration.
We also investigated whether fewer model turns could be achieved by batching file reads and related tool operations. The first analysis suggested a much larger opportunity than really existed. It had counted flattened tool events as if they represented separate provider requests.
When we revisited the original provider calls, we found 149 responses containing multiple tool uses across the recorded Element Web and Teleport runs. Metaphor already supported concurrent read-only tools. The corrected offline replay put the central additional-batching opportunity at only a few percent rather than a transformative reduction.
What we learned
We aimed to investigate whether understanding the progress of a coding task could make context management more efficient than counting on the native compaction behavior. The implementation demonstrated that we could identify meaningful checkpoints, preserve the relevant information, and substantially reduce the context carried forward during execution. However, the reduction in context did not translate into lower inference costs across our broader evaluations. The additional costs of checkpoint decisions, summarization, changes in cache reuse, and the potential effects on subsequent agent behavior made the economics more complex than simply reducing the number of tokens in the context.
This doesn't necessarily mean that semantic compaction cannot be useful. Our initial multi-turn results showed that certain workloads could benefit substantially, but the revised evaluations also showed how dependent those benefits were on the nature of the task. Considering that we were attempting to further improve Metaphor's already efficient native context management, the results weren't sufficient to justify the additional complexity, and we decided to pause further development of SCC. The larger takeaway from this experiment was that optimizing the context an agent maintains and optimizing the total cost of completing a task are not necessarily the same thing.
