Skip to content

Commit 04c89b9

Browse files
committed
docs(sdk): correct the createSession example to use chat.customAgent
The docstring showed a plain task(), but createSession resolves its stop signal and message channels through the session handle that only the chat.customAgent (or chat.agent) wrapper binds at run boot. A plain task() would throw "session handle is not initialized" on the first turn. Aligns the example with the reference project and the docs.
1 parent 09f8e7a commit 04c89b9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • packages/trigger-sdk/src/v3

packages/trigger-sdk/src/v3/ai.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9003,14 +9003,18 @@ export type ChatTurn = {
90039003
* signaling, and idle/suspend between turns. You control: initialization,
90049004
* model/tool selection, persistence, and any custom per-turn logic.
90059005
*
9006+
* Call from inside a `chat.customAgent()` run — the wrapper binds the
9007+
* backing Session that the iterator's stop signal and message channels
9008+
* resolve to. (A plain `task()` does not bind it, so `createSession`
9009+
* would throw "session handle is not initialized".)
9010+
*
90069011
* @example
90079012
* ```ts
9008-
* import { task } from "@trigger.dev/sdk";
90099013
* import { chat, type ChatTaskWirePayload } from "@trigger.dev/sdk/ai";
90109014
* import { streamText } from "ai";
90119015
* import { openai } from "@ai-sdk/openai";
90129016
*
9013-
* export const myChat = task({
9017+
* export const myChat = chat.customAgent({
90149018
* id: "my-chat",
90159019
* run: async (payload: ChatTaskWirePayload, { signal }) => {
90169020
* const session = chat.createSession(payload, { signal });

0 commit comments

Comments
 (0)