Repository navigation
fix(chat): Preserve agent history through SQL storage - #1926
Merged
Merged
Conversation
Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: David Cramer <[email protected]> Co-Authored-By: Dave Rosenthal <[email protected]>
Co-Authored-By: David Cramer <[email protected]>
dcramer
marked this pull request as ready for review
September 25, 2026 14:08
dcramer
approved these changes
Sep 25, 2026
This was referenced Nov 2, 2026
This branch was successfully deployed
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.
Store agent history message fields as JSON strings in the existing event log. This prevents JSONB from changing nested key order and SQL sanitization from replacing NUL characters. Replay decodes the saved fields instead of rebuilding messages from a field list.
Handoff and compaction encode each replacement item directly. SQL reports keep the model, provider, usage, and tool-call fields they already read. Replay ignores those copies. No second history store or database migration is added.
Existing version-one rows remain readable. Data already lost cannot be recovered.
Validation: 150 tests passed across 13 files, including history replay, handoff, compaction, checkpoints, event search, and SQL reports. Typecheck and full lint passed. The replay test uses real Postgres and Pi's Anthropic parser and serializer with fake model HTTP responses. It compares stored messages and serialized request prefixes without sorting keys. Only cache markers are excluded. Production cache savings still need measurement.
Rollout: stop old workers before enabling version-two writes. Old releases cannot replay the new events. Rollback requires a compatible reader.
Refs #1844.
via David Cramer.
--
View Junior Session [Sentry]