Skip to content

feat(core): opt models into provider compaction - #47171

Draft
R44VC0RP wants to merge 1 commit into
v2from
model-provider-compaction
Draft

feat(core): opt models into provider compaction#47171
R44VC0RP wants to merge 1 commit into
v2from
model-provider-compaction

Conversation

@R44VC0RP

@R44VC0RP R44VC0RP commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Issue for this PR

None — draft proposal for v2, building on #46431 and #46962.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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?

  • Live synthetic conversation through the changed Core service: compact → persisted checkpoint → full replacement replay → correct recall on a real OpenAI Responses deployment. No real conversation data or credentials are included in the PR.
  • 50 focused compaction/replay tests, plus targeted config, fork/revert, export-redaction, and client projection checks passed. Existing Core, Client, and AI compaction regression checks passed, with affected assertions rechecked after fixes.
  • Repository pre-push typecheck passed (33 tasks); regenerated clients.
  • Read-only review caught a runtime-alias compatibility gap, now guarded and covered. The live check caught undefined provider metadata during serialization, now normalized and covered.

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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant