feat(sdk): persist compaction and injected context through the transcript storage state - #4894
Conversation
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe change adds in-memory transcript storage and persisted runtime-state helpers. Merge Risk: 🟡 Moderate · up to 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)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation 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 💡
🧪 Generate unit tests (beta)
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. Comment |
b986d19 to
92d04a8
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
92d04a8 to
1677c26
Compare
1677c26 to
1bf36ef
Compare
7a020c4 to
516c8de
Compare
516c8de to
192cc15
Compare
…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.
192cc15 to
fc7e243
Compare
Summary
Makes a compaction summary and
chat.injectcontext 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
stateslot: 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 aputin 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.