feat(core): opt models into provider compaction - #47171
Draft
R44VC0RP wants to merge 1 commit into
Draft
Conversation
Allow model configuration and existing plugin catalog transforms to select the provider compaction strategy. Keep summary compaction as the default. For opted-in models, replace text-only model context with the complete native replacement window using the existing AI compact API. Persist the replacement in the normal checkpoint lifecycle, derive a readable UI and model-switch fallback from the compacted context, bind replay to catalog and runtime identities, and omit opaque payloads from sanitized exports. Preserve existing manual, automatic, and overflow scheduling. Verified focused compaction/replay, configuration, fork/revert, export, client, and AI regression checks; Core, Schema, Protocol, Plugin, Server, and Client typechecks; regenerated clients; and a live synthetic compact/persist/replay/recall flow through the changed Core service. A 350k-token workload was not stress-tested.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
None — draft proposal for
v2, building on #46431 and #46962.Type of change
What does this PR do?
Adds opt-in provider compaction to the existing Session compaction lifecycle. The default remains summary compaction.
{ "$schema": "https://opencode.ai/config.json", "providers": { "openai": { "models": { "gpt-5.3-codex": { "compaction": "provider" } } } } }A V2 plugin can also set
model.compaction = "provider"through its existing catalog transform; no new hook or separate plugin package is needed.Core calls the existing
LLMClient.compact, persists the complete replacement window, and replays it only for the matching catalog model and runtime provider/model/route. Other models use the readable summary. Forks, reverts, and exports retain their existing lifecycle; sanitized exports omit the replacement payload.Design tradeoff for discussion: native compaction is followed by summary generation from the compacted window. That preserves the current UI and provides a portable fallback, but costs an extra call. The originating model resumes from the native window, not that summary.
This is standalone compaction only. It does not enable in-band
context_management, change thresholds, or claim all models behind a capable route support the endpoint.How did you verify your code works?
Not verified: a 350k-token workload or long-running production sessions. Kept draft for API and product-policy discussion.
Screenshots / recordings
No visual component changes; existing compaction status and readable summary remain.
Checklist