{{ message }}
Repository navigation
refactor(schema): remove recent from compaction messages and events - #57203
Merged
Merged
Conversation
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.

Problem
Since #56954, summary compactions reference their kept messages with
metadata.firstKeptMessageIDand always writerecent: "". The field itself was still part of compaction messages and thesession.compaction.started/.endedevents, so every API reader, client, and plugin saw an empty string that only meant something for compactions saved before that change.Change
recentis removed from the public contract: schema, OpenAPI, generated clients, plugins.CompactionRunning { status: "running", reason, summary, - recent } CompactionCompleted { status: "completed", reason, model?, native?, summary, - recent, providerContext?, cost?, tokens? } session.compaction.started { reason, inputID? - recent } session.compaction.ended { reason, model?, native?, providerContext?, text, - recent, cost?, tokens? }The kept text that replay needs now lives in the compaction's free-form
metadata:SessionRecentText.kept(message)is the single reader, used by replay and compaction./session/:id/contextand request hooks see the rebuilt text asmetadata.recent, as they saw it inrecentbefore. The message list shows it only for old compactions. Message metadata is never sent to providers.metadatais stored as-is, so a hook that setsmetadata.recentwithout a kept-message reference has that text replayed.metadata.recentinstead ofrecent.Old data (
@opencode/schema/session-legacy)recentwith text moves intometadata.recenton read; an empty one is dropped. This applies to stored rows and imported exports.recentis dropped from storedcompaction.started/.endedevents on read. Nothing reads it: messages, not events, are what replay uses. Replay idempotency compares stored events in their upgraded shape, so old events still match.Downgrades
Nothing writes
recentfor older versions; this follows the existing pattern of reading old shapes and never writing them. Versions before v2.1 requirerecenton compaction messages, so they cannot load a session that has a compaction created by this version. Sessions compacted only before the upgrade are unaffected.Older clients
An older Effect client, or a pinned plugin or SDK built on it, requires
recentwhen it decodes compaction messages and events. It fails against this server, as with any removed required field. Newer clients against an older server ignore the extra field.Out of scope
providerContext, thenativewritten by the summary call but never read).Verification
New tests:
packages/schema/test/session-legacy.test.ts: oldrecenttext moves into metadata, and empty values and event fields are dropped.packages/core/test/session-compaction.test.ts"summaries written before kept-message references keep their stored recent text": inserts a raw old-shape row. It fails without the legacy read.packages/core/test/session-projector.test.tsandsession-runner.test.ts: stored compaction rows and events have norecent.packages/core/test/v1-migration.test.ts: the V1 kept tail lands inmetadata.recent, with norecent.packages/core/test/bus.test.ts"replays compaction events stored before v2.1 with recent, reading them without it": an old event with kept text replays idempotently and reads back withoutrecent.packages/server/test/session-import.test.ts: an old export'srecenttext comes back asmetadata.recent.Tests:
bun testv2.1)bun testbun testbun testbun testbun test test/cli/tui/data.test.tsx test/cli/tui/session-rows.test.ts test/mini/stream-v2.transport.test.tsbun testv2.1)Typecheck:
bun typecheckpasses in schema, protocol, core, client, cli, server, sdk, tui, plugin, app, and session-ui, apart from errors already onv2.1.Generated files:
check:generatedpasses in packages/protocol, packages/client, and services/www.