{"record":{"id":"5dd2690c5476b619","repo":"shadcn-ui/ui","slug":"no-assistant-response-found-for-this-transcript","errorCode":null,"errorMessage":"No assistant response found for this transcript.","messagePattern":"No assistant response found for this transcript\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/helpers/src/ai-sdk/format.ts","lineNumber":257,"sourceCode":"            type: \"custom\",\n          } as Chunk\n        default:\n          return assertNever(chunk)\n      }\n    },\n\n    createTransport(transportContext, options = {}) {\n      return {\n        async sendMessages({ messages, messageId, abortSignal, trigger }) {\n          // Automatic sends after tool results and approvals pass the last\n          // assistant message's id; only regeneration may replay a turn by id.\n          const turn = transportContext.resolveTurn(\n            messages,\n            trigger === \"regenerate-message\" ? messageId : undefined\n          )\n\n          if (!turn) {\n            throw new Error(\"No assistant response found for this transcript.\")\n          }\n\n          return transportContext.streamTurn(\n            turn,\n            format.encodeChunk,\n            options,\n            abortSignal\n          )\n        },\n\n        async reconnectToStream() {\n          return null\n        },\n      } satisfies ChatTransport<Message>\n    },\n  }\n\n  return format","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/helpers/src/ai-sdk/format.ts#L239-L275","documentation":"In the AI SDK transport produced by format.createTransport, sendMessages() resolves the matching scripted assistant turn via transportContext.resolveTurn(). If no turn matches the incoming message transcript (or the messageId on a regenerate), it throws. This means the scripted chat has been exhausted or the client sent an unexpected message order.","triggerScenarios":"Calling sendMessages after all scripted turns are consumed; regenerating a messageId that has no scripted turn; sending a message sequence that does not line up with the scripted user/assistant alternation.","commonSituations":"A demo or scripted assistant with a finite transcript receiving extra messages; a client retrying after completion; mismatched message ids.","solutions":["Ensure the scripted transcript has a turn that matches resolveTurn's lookup for the incoming messages.","Stop calling sendMessages once the transcript is exhausted (track completion on the client).","For regenerate, pass the exact messageId of an existing assistant turn."],"exampleFix":"// before\nawait transport.sendMessages({ messages, messageId, trigger })\n\n// after\nconst turn = context.resolveTurn(messages, trigger === \"regenerate-message\" ? messageId : undefined)\nif (!turn) return // no scripted response; end the conversation\nawait transport.sendMessages({ messages, messageId, trigger })","handlingStrategy":"validation","validationCode":"const turn = context.resolveTurn(\n  messages,\n  trigger === \"regenerate-message\" ? messageId : undefined\n)\nif (!turn) {\n  // nothing to stream; end the conversation instead of throwing\n  return\n}","typeGuard":"// resolveTurn returns ResolvedTurn | undefined; narrow before streaming\nconst turn = context.resolveTurn(messages, messageId)\nif (!turn) return\n// turn is ResolvedTurn here","tryCatchPattern":"try {\n  await transport.sendMessages({ messages, messageId, trigger })\n} catch (e) {\n  if ((e as Error).message === \"No assistant response found for this transcript.\") {\n    // end the chat gracefully\n  } else throw e\n}","preventionTips":["Track scripted-turn exhaustion on the client and disable further sends.","Validate that messageId exists in the transcript before requesting a regenerate."],"tags":["ai-sdk","transcript","chat","transport"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}