fix(sdk): chat.agent transcript follow-ups - #4910
Conversation
- Drop the compaction prefix fingerprint. A compacted lane is reused while its throughId still exists in the transcript, so a rollback that crosses the compaction point rebuilds from the transcript and an in-place edit of a summarized message is tolerated (unsupported by design). A custom TranscriptStorage no longer has to preserve exact message JSON for a compaction to survive. - Skip persisting a content-less assistant response, so a turn that errors before the model writes anything no longer leaves an empty assistant bubble in the transcript or the next turn's context. - Fall back to a generic error message when a thrown error has no message, instead of surfacing a blank error to the client. - The test harness seedSessionInTail stamps the harness clientData onto seeded records, matching how production preserves each record's metadata, so recovery re-dispatch is testable for clientDataSchema agents. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VG39FXXkFFU24U5EtJMwPi
🦋 Changeset detectedLatest commit: 1ee0952 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (44)
🧰 Additional context used📓 Path-based instructions (9)Always import from `@trigger.dev/sdk`.📄 CodeRabbit inference engine (AGENTS.md) Files:
We use vitest exclusively.📄 CodeRabbit inference engine (AGENTS.md) Files:
**Prefer static imports over dynamic imports.**📄 CodeRabbit inference engine (AGENTS.md) Files:
Add crumbs as you write code — not just when debugging.📄 CodeRabbit inference engine (AGENTS.md) Files:
In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Use vitest for all tests in the Trigger.dev repository📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Use function declarations instead of default exports📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Use types over interfaces for TypeScript Avoid using enums; prefer string unions or const objects instead📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs Do not use high-cardinality attributes in OTEL metr...📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc) Files:
🧠 Learnings (1)📚 Learning: 2026-06-16T09:19:47.637ZApplied to files:
🔇 Additional comments (5)
WalkthroughThe change updates Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to Chat-agent transcripts now omit empty assistant responses, retain late response parts when applicable, preserve hook removals, and restore compaction by transcript boundary. The covered behavior changes are ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 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 |
When the model returns no content the response is no longer accumulated, but a non-transient data part written during onBeforeTurnComplete still has to be persisted. The late-part drain now commits the previously skipped response into the UI transcript (kept out of the model lane, since the parts are UI-only) instead of clearing the parts without saving them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VG39FXXkFFU24U5EtJMwPi
The comment described metadata: undefined; seeded records now carry the harness clientData. The code is self-explanatory, so remove the comment rather than reword it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VG39FXXkFFU24U5EtJMwPi
@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: |
The late-parts drain distinguished nothing between a content-less response skipped before onBeforeTurnComplete and a real response the hook removed via chat.history/setMessages: both reached the drain with findIndex === -1, so the drain re-added a deliberately-removed reply and double-pushed it into turnNewUIMessages. Track whether the response was skipped as content-less and only re-insert in that case; a hook-removed response stays removed and its late parts are dropped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VG39FXXkFFU24U5EtJMwPi
Follow-ups to the transcript storage feature (#4896), surfaced by dogfooding it in the durable-chat example.
Changes
throughIdstill exists in the transcript. A rollback that crosses the compaction point rebuilds from the transcript; an in-place edit of a summarized message is tolerated (unsupported by design). This removes the implicit requirement that a customTranscriptStoragepreserve exact message JSON — no more "store as TEXT not JSONB / canonicalize keys" trap.seedSessionInTailstamps the harnessclientDataonto seeded records (matching how production carries each record's metadata), so recovery re-dispatch is testable forclientDataSchemaagents.Verification
@trigger.dev/sdk+@trigger.dev/coretypecheck clean@trigger.dev/sdksuite: 633 passing (includes new tests for the throughId-boundary compaction behavior, the empty-response skip, and clientData-scoped recovery re-dispatch)