feat(plugin-chatbot): send a stable per-turn turnId for safe Retry (ADR-0013 D1)#1755
Merged
Conversation
…DR-0013 D1) The chat transport now stamps a stable `turnId` on every outgoing turn, derived from the id of the user message that triggered it. On Retry the AI SDK re-sends the SAME triggering user message (regenerate-message keeps the trailing user turn), so the id — and thus the turnId — is identical across the original send and the retry. The server (framework @objectstack/service-ai) uses this key to dedup the inbound user message and short-circuit a completed turn instead of re-running tools / re-planning. Builds on D2 (#1742), which reconciles a turn that actually succeeded; D1 covers the genuinely-failed retry path. - useObjectChat: DefaultChatTransport.prepareSendMessagesRequest → withTurnId (extracted + exported for unit testing). - tests: withTurnId — derivation, stability across Retry, distinct per new turn, defensive no-user case. Cross-repo: pairs with framework turnId dedup/short-circuit + a cloud SHA bump, per the ADR-0012 cross-repo recipe. Refs cloud#334. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
❌ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
…agesRequest (ADR-0013 D1)
Browser E2E caught this: when DefaultChatTransport.prepareSendMessagesRequest
returns a `body`, the AI SDK sends it VERBATIM — it does NOT merge back the
default fields (id/messages/trigger/messageId). The first version returned
only `{...body, turnId}`, dropping `messages`, so the live agent rejected the
turn with 400 "messages array is required".
withTurnId now replicates the transport's default body exactly and only ADDS
turnId. Verified end-to-end in the browser against the running cloud+runtime
stack: send → turn completes with a draft; Retry (regenerate) reuses the same
turnId, the server short-circuits (no duplicate user row, no tool re-run, no
second draft), and returns the stored reply.
Refs cloud#334.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
❌ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
ADR-0013 D1 — client turnId
Part of the cross-repo durable-turn work for cloud#334. Pairs with framework #1900 (server-side dedup/short-circuit) and a cloud SHA bump, coordinated via the ADR-0012 cross-repo recipe. Builds on D2 (#1742) which reconciles a turn that actually succeeded; D1 covers the genuinely-failed retry path.
Change
The chat transport now stamps a stable
turnIdon every outgoing turn, derived from the id of the user message that triggered it. On Retry the AI SDK re-sends the SAME triggering user message (regenerate-message keeps the trailing user turn), so the id — and thus theturnId— is identical across the original send and the retry. The server uses this key to dedup the inbound user message and short-circuit a completed turn instead of re-running tools / re-planning.useObjectChat:DefaultChatTransport.prepareSendMessagesRequest→withTurnId(extracted + exported for unit testing). One transport covers both consoles (AiChatPage+ConsoleFloatingChatbot); it is the onlyDefaultChatTransportin the codebase.Tests
withTurnId: derivation from last user message, stability across Retry, distinct id per new turn, defensive no-user case. Green alongsidemapMessages.🤖 Generated with Claude Code