Repository navigation
fix(core): decode legacy media in compaction checkpoints - #51409
Merged
Merged
Conversation
Before 2.0.15, Core built media parts only from prompt attachments, whose data Prompt.Base64 validates, so data URL and http(s) handling was unreachable. Keep the fixture to data 2.0.14 could have written.
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.
Why
Sessions with a pre-2.0.15 native compaction containing media fail to load after upgrading:
Session.MessageDecodeError. #49181 changed the embedded AI media format, but existing checkpoints still contain the old shape underversion: 1.What changes
Read legacy media at the checkpoint boundary before applying the current message schema. Both
SessionProviderContext.validate()anddecode()use the same normalization.flowchart LR A[Stored checkpoint] --> B{Media shape} B -->|mediaType + data| C[Convert to media.source] B -->|media asset| D[Current Message decoder] C --> D D --> E[Load and replay session]Attachment metadata is preserved. Malformed current assets still fail validation.
Scope
One Core compatibility helper; recovery happens on read without rewriting the database. Frozen legacy JSON and a database-backed history test protect this boundary.
Verification
The history regression persists an old-format checkpoint, reloads it, and verifies native replay and original-transcript selection. Full lint/type checks pass (35 typecheck tasks). Simplification pass completed.