Skip to content

feat(sdk): persist compaction and injected context through the transcript storage state - #4894

Open
ericallam wants to merge 1 commit into
feat/transcript-storage-seam-tri-13667from
feat/transcript-storage-changesets-tri-13667
Open

feat(sdk): persist compaction and injected context through the transcript storage state#4894
ericallam wants to merge 1 commit into
feat/transcript-storage-seam-tri-13667from
feat/transcript-storage-changesets-tri-13667

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

Makes a compaction summary and chat.inject context survive a continuation run, for every storage including the default.

Until now the model lane after a compaction lived only in the running worker. When the next run booted it rebuilt the lane from the transcript, so every continuation re-read the whole conversation and summarised it again. The same applied to conversational messages added with chat.inject: they lived for the worker's life and vanished on a continuation.

Design

The runtime records what it cannot rebuild from the transcript in the storage's state slot: after a compaction, the compacted model lane together with the transcript id it covers and a fingerprint of that prefix; for injections, the messages anchored to the transcript message they followed. At boot the compacted lane is used when the covered prefix is unchanged, otherwise the lane is converted from the transcript as before, and injections are re-inserted after their anchors.

A rollback or edit that reconverts the lane clears the state in the same changeset as the truncateAfter, so a storage never holds a summary for a transcript it no longer matches. A mid-turn steering message reaches the storage as a put in that turn's changeset.

An in-memory storage that logs the changesets it receives, and a test-only override for the storage the runtime persists through, let the tests assert the exact changesets for a turn, a steer, a compaction, a rollback and an injection.

@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fc7e243

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 3c4cae75-e4b1-4c52-b0f1-f7552e1297c4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The change adds in-memory transcript storage and persisted runtime-state helpers. chat.agent now restores and saves compaction state and transcript-anchored injections. Model-lane rebuilds and history replacements reset runtime state. New tests cover turn changesets, steering messages, compaction continuation, rollback, and injection restoration.

Merge Risk: 🟡 Moderate · up to b986d

Conversational context injected during tool-result flows can affect the current model step but be missing from later transcript processing and continuation runs. This breaks the new persistence guarantee for a reachable injection path and should be fixed before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the design and behavior in detail, but it omits the required issue reference, checklist, testing steps, changelog, and screenshots sections from the repository template. Add the required template sections. Include the closed issue number, complete the checklist, describe the tests that were run, add a short changelog entry, and provide screenshots or state that screenshots are not applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: persisting compaction and injected context through transcript storage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (1 skipped: 1 too large.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/transcript-storage-changesets-tri-13667

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ericallam
ericallam force-pushed the feat/transcript-storage-changesets-tri-13667 branch from b986d19 to 92d04a8 Compare September 5, 2026 20:29
@pkg-pr-new

pkg-pr-new Bot commented Sep 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@fc7e243

trigger.dev

npm i https://pkg.pr.new/trigger.dev@fc7e243

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@fc7e243

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@fc7e243

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@fc7e243

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@fc7e243

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@fc7e243

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@fc7e243

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@fc7e243

commit: fc7e243

@ericallam
ericallam force-pushed the feat/transcript-storage-changesets-tri-13667 branch from 92d04a8 to 1677c26 Compare September 5, 2026 20:38
coderabbitai[bot]

This comment was marked as resolved.

@ericallam
ericallam force-pushed the feat/transcript-storage-changesets-tri-13667 branch from 1677c26 to 1bf36ef Compare September 6, 2026 05:42
@ericallam
ericallam force-pushed the feat/transcript-storage-changesets-tri-13667 branch 2 times, most recently from 7a020c4 to 516c8de Compare September 6, 2026 06:16
@ericallam
ericallam force-pushed the feat/transcript-storage-changesets-tri-13667 branch from 516c8de to 192cc15 Compare September 6, 2026 06:18
@ericallam
ericallam marked this pull request as ready for review September 6, 2026 07:49
devin-ai-integration[bot]

This comment was marked as resolved.

…ript storage state

The model lane after a compaction cannot be rebuilt from the transcript, so every continuation used to re-read the whole conversation and summarise it again. The runtime now records the compacted lane in the storage's state slot, with the transcript id it covers and a fingerprint of that prefix, and rebuilds from it at boot when the prefix is unchanged. A rollback or edit that reconverts the lane clears the state in the same changeset as the truncate.

Conversational messages added with chat.inject are recorded the same way, anchored to the transcript message they followed, so they survive a continuation instead of living only in the worker that received them.

Adds an in-memory storage that logs the changesets it receives, and a test-only override for the storage the runtime persists through, so the exact changesets for a turn, a mid-turn steer, a compaction, a rollback and an injection are asserted.
@ericallam
ericallam force-pushed the feat/transcript-storage-changesets-tri-13667 branch from 192cc15 to fc7e243 Compare September 6, 2026 08:05
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