You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: V2 plugin support for managing context-window transitions #47810
I have verified this feature I'm about to request hasn't been suggested before.
The related V1 proposal is linked below; I did not find an existing request for this V2 capability.
Describe the enhancement you want to request
I’m building a V2 plugin that uses Astra’s native history and notes to continue across context windows without a generated summary.
The plugin can control which messages are sent to the model, but OpenCode’s builtin automatic compaction can run before that request hook or during context-overflow recovery. There doesn’t appear to be a supported way for a plugin to take over context-window transitions for the sessions it manages.
Could V2 expose a way to support this? The motivation is to integrate model-native context management through a plugin without requiring a custom OpenCode build.
I reproduced both compaction paths in an isolated runtime fixture on 0.0.0-beta-19157.
Related: #27366 proposed a compaction bypass for V1 but was closed for inactivity.
Same request from the memory side: an open-source local-first memory library (Awareness, Apache-2.0) + OpenCode plugin. We can inject a structured brief via the compaction context[], but we cannot replace the window with Message[], and required() still runs against durable history — so we race compaction instead of owning it.
This is the return value half of the missing capability; #50862 is the trigger half. Both are needed for a plugin to manage context-window transitions without a custom OpenCode build.
To restate it: you'd like a supported way for a V2 plugin to take over context-window transitions (both automatic threshold compaction and context-overflow recovery) for the sessions it manages, so you can rely on the model's own history and notes instead of a generated summary, without a custom build.
I checked the current code, and this isn't possible from a plugin today. The ctx.session.hook("compaction") hook can replace what a compaction produces, and its result can include a native replacement window. But the engine alone decides whether and when compaction runs. The only off switch is the global compaction.auto setting, and turning it off also disables overflow recovery. There's no per-session or plugin-controlled opt-out. Maintainers will consider adding something like a decision hook before automatic and overflow compaction that lets a plugin skip it or report that it handled it.
Activity
everest-an commentedon Oct 3, 2026
Same request from the memory side: an open-source local-first memory library (Awareness, Apache-2.0) + OpenCode plugin. We can inject a structured brief via the compaction
context[], but we cannot replace the window withMessage[], andrequired()still runs against durable history — so we race compaction instead of owning it.This is the return value half of the missing capability; #50862 is the trigger half. Both are needed for a plugin to manage context-window transitions without a custom OpenCode build.
opencodejr commentedon Oct 28, 2026
Thanks for the clear write-up!
To restate it: you'd like a supported way for a V2 plugin to take over context-window transitions (both automatic threshold compaction and context-overflow recovery) for the sessions it manages, so you can rely on the model's own history and notes instead of a generated summary, without a custom build.
I checked the current code, and this isn't possible from a plugin today. The
ctx.session.hook("compaction")hook can replace what a compaction produces, and its result can include a native replacement window. But the engine alone decides whether and when compaction runs. The only off switch is the globalcompaction.autosetting, and turning it off also disables overflow recovery. There's no per-session or plugin-controlled opt-out. Maintainers will consider adding something like a decision hook before automatic and overflow compaction that lets a plugin skip it or report that it handled it.Related issues: