Skip to content

fix(chat): Preserve agent history through SQL storage - #1926

Merged
dcramer merged 3 commits into
mainfrom
fix/stable-tool-argument-replay
Sep 25, 2026
Merged

dcramer merged 3 commits into
mainfrom
fix/stable-tool-argument-replay

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

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]

@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Sep 25, 2026 2:03pm UTC

Request Review

@sentry-junior sentry-junior Bot changed the title fix(chat): Stabilize tool arguments across history replay fix(chat): Preserve native message payloads across history replay Sep 25, 2026
@sentry-junior sentry-junior Bot changed the title fix(chat): Preserve native message payloads across history replay fix(chat): Preserve agent history through SQL storage Sep 25, 2026
@dcramer
dcramer marked this pull request as ready for review September 25, 2026 14:08
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Sep 25, 2026
@dcramer
dcramer merged commit 6ff3bf1 into main Sep 25, 2026
46 checks passed
@dcramer
dcramer deleted the fix/stable-tool-argument-replay branch September 25, 2026 14:35

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 9d8e194b Deployed Sep 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant