Repository navigation
Compaction by fresh session: reuse the provider-switch handoff instead of native /compact #31096
DmitriyAlergant
started this conversation in
Ideas
Replies: 1 comment
|
+1 to a fresh-session compaction method. We run a similar design in Claude Code through a local plugin. Three details from it that this proposal does not cover yet:
The cost is that the agent must search before it acts on earlier work. With no summary, nothing carries forward unless it looks. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
Every compaction path (the Compact chip, "Compact idle threads", manual
/compact) defers to the provider's native/compact.On a cold thread this re-reads the whole uncached context, often 200K-600K input tokens on 1M-window models, just to produce a summary, and the next turn then pays for that summary on top.
As #17170 notes, compacting a cold thread costs about as much as sending the prompt into it, so it saves little and loses detail.
Existing mechanism: the provider-switch handoff
Switching a thread to another provider instance does not compact.
It starts a fresh native session seeded with a
ContextHandoff(ContextHandoffService.ts, strategyfull_thread_summary).The handoff is built deterministically from the app thread's own history (
historicalMessage/selectHistory/renderHistoryinpackages/provider-core/src/server/handoffBudget.ts), capped byT3CODE_CONTEXT_HANDOFF_TOKEN_CAP(default 16K), with no model call.#23086 shows the effect: the second Claude instance started at about 47K tokens while the original native session sat at about 543K.
docs/orchestration-v2/provider-switching-and-context.mdalready lists "user selected clean context" as a reason to create a new provider thread withfull_thread_summary, but there is no user-facing way to trigger it on the same provider.Proposal: "Fresh session" as a compaction method
Offer the same handoff on the same provider instance as an alternative to native
/compact.Close the current native session and open a new one on the same provider and model, seeded with two things:
historicalMessagealready does, selected newest-first under the token cap.~/.claude/projects/<project>/<session-id>.jsonl; Codex: its rollout file), so the new session can look up details that fell outside the cap on demand.Touchpoints:
/compact| Fresh session./freshcomposer command and a thread-menu action for doing it on demand.Related: #23086, #15128 (fresh thread with distilled context on quota cutoff), #17170, #19823, #28505.
All reactions