[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-trigger-dev-trigger-chat-agent-advanced":3,"mdc-7dks4u-key":44,"related-org-trigger-dev-trigger-chat-agent-advanced":7591,"related-repo-trigger-dev-trigger-chat-agent-advanced":7751},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":21,"repoUrl":22,"updatedAt":23,"license":24,"forks":25,"topics":26,"repo":39,"sourceUrl":42,"mdContent":43},"trigger-chat-agent-advanced","manage Trigger.dev chat sessions and transports","Advanced and operational chat.agent capabilities for Trigger.dev, loaded on demand. Load this when working on the raw Sessions primitive (sessions \u002F SessionHandle), a custom chat transport or the realtime wire protocol, durable sub-agents (AgentChat, chat.stream.writer), human-in-the-loop, steering, actions, background injection (chat.defer \u002F chat.inject), fast starts (preload, Head Start via @trigger.dev\u002Fsdk\u002Fchat-server), context resilience (compaction, recovery boot, OOM, large payloads), chat.local run-scoped state, offline testing with mockChatAgent, or prerelease\u002Fversion upgrades. For the everyday chat.agent({...}) definition and the useTriggerChatTransport happy path, use the trigger-authoring-chat-agent skill instead.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},"trigger-dev","Trigger.dev","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Ftrigger-dev.jpg","triggerdotdev",[13,15,18],{"name":9,"slug":8,"type":14},"tag",{"name":16,"slug":17,"type":14},"Agents","agents",{"name":19,"slug":20,"type":14},"Workflow Automation","workflow-automation",14401,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Ftrigger.dev","2026-07-02T17:12:51.03018",null,1131,[27,28,29,30,31,32,33,34,35,36,37,20,38],"ai","ai-agent-framework","ai-agents","automation","background-jobs","mcp","mcp-server","nextjs","orchestration","scheduler","serverless","workflows",{"repoUrl":22,"stars":21,"forks":25,"topics":40,"description":41},[27,28,29,30,31,32,33,34,35,36,37,20,38],"Trigger.dev – build and deploy fully‑managed AI agents and workflows","https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Ftrigger.dev\u002Ftree\u002FHEAD\u002Fpackages\u002Ftrigger-sdk\u002Fskills\u002Ftrigger-chat-agent-advanced","---\nname: trigger-chat-agent-advanced\ndescription: >\n  Advanced and operational chat.agent capabilities for Trigger.dev, loaded on demand. Load this when\n  working on the raw Sessions primitive (sessions \u002F SessionHandle), a custom chat transport or the\n  realtime wire protocol, durable sub-agents (AgentChat, chat.stream.writer), human-in-the-loop,\n  steering, actions, background injection (chat.defer \u002F chat.inject), fast starts (preload, Head\n  Start via @trigger.dev\u002Fsdk\u002Fchat-server), context resilience (compaction, recovery boot, OOM, large\n  payloads), chat.local run-scoped state, offline testing with mockChatAgent, or prerelease\u002Fversion\n  upgrades. For the everyday chat.agent({...}) definition and the useTriggerChatTransport happy path,\n  use the trigger-authoring-chat-agent skill instead.\ntype: core\nlibrary: trigger.dev\nsources:\n  - docs\u002Fai-chat\u002Fsessions.mdx\n  - docs\u002Fai-chat\u002Fserver-chat.mdx\n  - docs\u002Fai-chat\u002Fclient-protocol.mdx\n  - docs\u002Fai-chat\u002Fpending-messages.mdx\n  - docs\u002Fai-chat\u002Factions.mdx\n  - docs\u002Fai-chat\u002Fbackground-injection.mdx\n  - docs\u002Fai-chat\u002Fcompaction.mdx\n  - docs\u002Fai-chat\u002Ffast-starts.mdx\n  - docs\u002Fai-chat\u002Fchat-local.mdx\n  - docs\u002Fai-chat\u002Fmcp.mdx\n  - docs\u002Fai-chat\u002Ftesting.mdx\n  - docs\u002Fai-chat\u002Fupgrade-guide.mdx\n  - docs\u002Fai-chat\u002Fpatterns\u002Fsub-agents.mdx\n  - docs\u002Fai-chat\u002Fpatterns\u002Fhuman-in-the-loop.mdx\n  - docs\u002Fai-chat\u002Fpatterns\u002Fpersistence-and-replay.mdx\n  - docs\u002Fai-chat\u002Fpatterns\u002Frecovery-boot.mdx\n  - docs\u002Fai-chat\u002Fpatterns\u002Foom-resilience.mdx\n  - docs\u002Fai-chat\u002Fpatterns\u002Flarge-payloads.mdx\n  - docs\u002Fai-chat\u002Fpatterns\u002Fversion-upgrades.mdx\n  - docs\u002Fai-chat\u002Ftools.mdx\n---\n\n# chat.agent: advanced and operational\n\n`chat.agent` is built on **Sessions**: a durable, task-bound, bi-directional I\u002FO channel pair keyed\non a stable `externalId` (e.g. `chatId`) that outlives any single run. This skill covers the layers\nbeneath and around the everyday agent: the raw `sessions` API, server-side `AgentChat`, durable\nsub-agents, actions \u002F background injection, fast starts, compaction and recovery, and the wire\nprotocol for custom transports.\n\nTwo `chat` namespaces are easy to confuse: the agent definition imports `chat` from\n`@trigger.dev\u002Fsdk\u002Fai`; Head Start \u002F Node-listener server entries import `chat` from\n`@trigger.dev\u002Fsdk\u002Fchat-server`.\n\n## Setup\n\nHappy path: drive an agent from server-side code (task, webhook, or script) with `AgentChat`.\n\n```ts\nimport { AgentChat } from \"@trigger.dev\u002Fsdk\u002Fchat\";\nimport type { myAgent } from \".\u002Ftrigger\u002Fmy-agent\";\n\nconst chat = new AgentChat\u003Ctypeof myAgent>({ agent: \"my-chat\", clientData: { userId: \"user_123\" } });\nconst stream = await chat.sendMessage(\"Review PR #42\");\nconst text = await stream.text();\nawait chat.close();\n```\n\n`sendMessage()` triggers a run on the first call, then reuses it via input streams. `ChatStream`\nexposes `text()`, `result()` (`{ text, toolCalls, toolResults }`), `messages()` (UIMessage\nsnapshots), and the raw `.stream`. Other methods: `steer(text)`, `stop()`, `sendRaw(uiMessages)`,\n`sendAction(action)`, `preload()`, `reconnect()`.\n\n## Core patterns\n\n### 1. Raw Sessions for non-chat, bi-directional I\u002FO\n\nReach for `sessions` directly when the chat abstraction does not fit: agent inboxes, approval flows,\nserver-to-server pipelines. `sessions.start` is idempotent on `(env, externalId)`; `externalId`\ncannot start with `session_`.\n\n```ts\nimport { sessions } from \"@trigger.dev\u002Fsdk\";\n\nconst { id, publicAccessToken } = await sessions.start({\n  type: \"chat.agent\",\n  externalId: chatId,\n  taskIdentifier: \"my-chat\",\n  triggerConfig: { tags: [`chat:${chatId}`], basePayload: { chatId, trigger: \"preload\" } },\n});\n\nconst session = sessions.open(chatId); \u002F\u002F no network call; methods are lazy\nawait session.out.append({ kind: \"message\", text: \"hello\" });\nconst next = await session.in.once\u003CMyEvent>({ timeoutMs: 30_000 });\n```\n\n`sessions.open(id).in` also has `send`, `on(handler)`, `peek`, `wait` (suspends the run, only inside\n`task.run()`), and `waitWithIdleTimeout`. `.out` has `append`, `pipe`, `writer`, `read`,\n`writeControl`, and `trimTo`. List with `sessions.list({ type, tag, status, ... })` (`for await`),\nmutate with `sessions.update`, end with `sessions.close` (terminal, idempotent).\n\n### 2. Durable sub-agent as a streaming tool\n\n`AgentChat` inside an AI SDK `tool()` delegates to a durable sub-agent; its response streams as\npreliminary tool results. Give the tool a `toModelOutput` so the model sees a compact summary.\n\n```ts\nimport { tool } from \"ai\";\nimport { AgentChat } from \"@trigger.dev\u002Fsdk\u002Fchat\";\nimport { z } from \"zod\";\n\nconst researchTool = tool({\n  description: \"Delegate research to a specialist agent.\",\n  inputSchema: z.object({ topic: z.string() }),\n  execute: async function* ({ topic }, { abortSignal }) {\n    const chat = new AgentChat({ agent: \"research-agent\" });\n    const stream = await chat.sendMessage(topic, { abortSignal });\n    yield* stream.messages(); \u002F\u002F UIMessage snapshots become preliminary tool results\n    await chat.close();\n  },\n  toModelOutput: ({ output: message }) => {\n    const lastText = message?.parts?.findLast((p: { type: string }) => p.type === \"text\") as\n      | { text?: string }\n      | undefined;\n    return { type: \"text\", value: lastText?.text ?? \"Done.\" };\n  },\n});\n```\n\nFor a subtask exposed via `execute: ai.toolExecute(task)`, stream progress to the agent's run with\n`chat.stream.writer({ target: \"root\" })`. `target` accepts `\"self\" | \"parent\" | \"root\" | \u003CrunId>`.\nInside the subtask, read context with `ai.toolCallId()` and `ai.chatContextOrThrow\u003Ctypeof myChat>()`\n(`{ chatId, turn, continuation, clientData }`).\n\n```ts\nimport { chat, ai } from \"@trigger.dev\u002Fsdk\u002Fai\";\n\nconst { waitUntilComplete } = chat.stream.writer({\n  target: \"root\",\n  execute: ({ write }) =>\n    write({ type: \"data-research-status\", id: partId, data: { query, status: \"in-progress\" } }),\n});\nawait waitUntilComplete();\n```\n\n### 3. Background injection: defer + inject\n\n`chat.defer(promise)` runs work in parallel with streaming (all deferred promises are awaited, with a\n5s timeout, before `onTurnComplete`). `chat.inject(messages)` queues `ModelMessage[]` that drain at\nthe next turn start or `prepareStep` boundary.\n\n```ts\nexport const myChat = chat.agent({\n  id: \"my-chat\",\n  onTurnComplete: async ({ messages }) => {\n    chat.defer(\n      (async () => {\n        const analysis = await analyzeConversation(messages);\n        chat.inject([{ role: \"system\", content: `[Analysis]\\n\\n${analysis}` }]);\n      })()\n    );\n  },\n  run: async ({ messages, signal }) =>\n    streamText({ ...chat.toStreamTextOptions({ registry }), messages, abortSignal: signal, stopWhen: stepCountIs(15) }),\n});\n```\n\n### 4. Compaction (threshold-based)\n\n`compaction.shouldCompact` decides when, `summarize` produces the summary that replaces the model\nmessages. UI messages are preserved by default (customize via `compactUIMessages`). The `prepareStep`\nthat performs inner-loop compaction is auto-injected by `chat.toStreamTextOptions()`; a `prepareStep`\nyou pass after the spread wins.\n\n```ts\ncompaction: {\n  shouldCompact: ({ totalTokens }) => (totalTokens ?? 0) > 80_000,\n  summarize: async ({ messages }) =>\n    (await generateText({\n      model: anthropic(\"claude-haiku-4-5\"),\n      messages: [...messages, { role: \"user\", content: \"Summarize concisely.\" }],\n    })).text,\n},\n```\n\n### 5. Actions: mutate state without a turn\n\n`actionSchema` validates; `onAction` mutates via `chat.history` (`slice`, `replace`, `rollbackTo`,\n`remove`, `getPendingToolCalls`, `extractNewToolResults`). Actions fire `hydrateMessages` and\n`onAction` only, never `run()` or the turn hooks. Return a `StreamTextResult`, string, or `UIMessage`\nto also emit a model response.\n\n```ts\nexport const myChat = chat.agent({\n  id: \"my-chat\",\n  actionSchema: z.discriminatedUnion(\"type\", [\n    z.object({ type: z.literal(\"undo\") }),\n    z.object({ type: z.literal(\"rollback\"), targetMessageId: z.string() }),\n  ]),\n  onAction: async ({ action }) => {\n    if (action.type === \"undo\") chat.history.slice(0, -2);\n    if (action.type === \"rollback\") chat.history.rollbackTo(action.targetMessageId);\n  },\n  run: async ({ messages, signal }) => streamText({ model: anthropic(\"claude-sonnet-4-5\"), messages, abortSignal: signal }),\n});\n```\n\nSend from the browser with `transport.sendAction(chatId, { type: \"undo\" })`, or server-side with\n`agentChat.sendAction({ type: \"rollback\", targetMessageId: \"msg-3\" })`.\n\n### 6. Fast starts: Head Start\n\n`chat.headStart` (from `@trigger.dev\u002Fsdk\u002Fchat-server`, NOT `\u002Fai`) returns a Web Fetch handler that\nserves turn 1 from your own warm process, then hands off to the agent on turn 2+. Tools passed here\nmust be **schema-only** (a module importing `ai` + `zod` only); heavy executes stay in the task.\n\n```ts\nimport { chat } from \"@trigger.dev\u002Fsdk\u002Fchat-server\";\nimport { streamText, stepCountIs } from \"ai\";\nimport { anthropic } from \"@ai-sdk\u002Fanthropic\";\nimport { headStartTools } from \"@\u002Flib\u002Fchat-tools\u002Fschemas\";\n\nexport const chatHandler = chat.headStart({\n  agentId: \"my-chat\",\n  run: async ({ chat: helper }) =>\n    streamText({\n      ...helper.toStreamTextOptions({ tools: headStartTools }),\n      model: anthropic(\"claude-sonnet-4-6\"),\n      system: \"You are helpful.\",\n      stopWhen: stepCountIs(15),\n    }),\n});\n\u002F\u002F Next.js: export const POST = chatHandler;  Transport: headStart: \"\u002Fapi\u002Fchat\"\n```\n\nNode-only frameworks wrap a Web Fetch handler with `chat.toNodeListener(handler)`. Use the **same\nmodel** on both sides to avoid a tone shift between turn 1 and turn 2+.\n\n### 7. chat.local: init in onBoot, not onChatStart\n\n`chat.local\u003CT>({ id })` is module-level, shallow-proxy, run-scoped state. Initialize it in `onBoot`\n(fires on every fresh worker, including continuation runs), never `onChatStart`.\n\n```ts\nconst userContext = chat.local\u003C{ name: string; plan: \"free\" | \"pro\" }>({ id: \"userContext\" });\n\nexport const myChat = chat.agent({\n  id: \"my-chat\",\n  onBoot: async ({ clientData }) => userContext.init({ name: \"Alice\", plan: \"pro\" }),\n  run: async ({ messages, signal }) => streamText({ \u002F* ... *\u002F }),\n});\n```\n\n### 8. Pending messages (mid-stream user input)\n\nA message sent while a turn is streaming should NOT cancel the stream. Configure\n`pendingMessages` (`shouldInject`, `prepare`, `onReceived`, `onInjected`) on the agent so the SDK's\nauto-injected `prepareStep` folds them in at the next boundary. On the frontend, `usePendingMessages`\nreturns `pending`, `steer(text)`, `queue(text)`, and `promoteToSteering(id)`; send via\n`transport.sendPendingMessage(chatId, uiMessage, metadata?)`.\n\n### 9. Recovery and version upgrades\n\n`onRecoveryBoot` fires only when a **partial assistant message exists on the tail** (interrupted\ndeploy, crash, OOM retry). It does NOT fire on `chat.requestUpgrade()`, which is a graceful exit with\nno partial. `chat.requestUpgrade()` (called in `onTurnStart` \u002F `onValidateMessages` to skip `run()`,\nor in `run()` \u002F `chat.defer()` to exit after the turn) rotates the Session's `currentRunId` to a run\non the latest deployment without a client reconnect. Pair it with a contract version on `clientData`.\n\n```ts\nconst SUPPORTED_VERSIONS = new Set([\"v2\", \"v3\"]);\nonTurnStart: async ({ clientData }) => {\n  if (clientData?.protocolVersion && !SUPPORTED_VERSIONS.has(clientData.protocolVersion)) {\n    chat.requestUpgrade();\n  }\n},\n```\n\nFor OOM resilience, set `oomMachine` (and `machine`) on the agent so retries land on a larger preset.\n\n### 10. Offline testing with mockChatAgent\n\n`@trigger.dev\u002Fsdk\u002Fai\u002Ftest` runs the real turn loop in-memory. Import it **before** the agent module\nso the resource catalog is installed. Drive with `sendMessage`, `sendRegenerate`, `sendAction`,\n`sendStop`, `sendHeadStart`, `sendHandover`; seed state with `seedSnapshot` \u002F `seedSessionOutTail` \u002F\n`seedSessionOutPartial` \u002F `seedSessionInTail`; assert against `turn.chunks` and `harness.allChunks`.\n\n```ts\nimport { mockChatAgent } from \"@trigger.dev\u002Fsdk\u002Fai\u002Ftest\"; \u002F\u002F BEFORE the agent module\nimport { myChatAgent } from \".\u002Fmy-chat.js\";\n\nconst harness = mockChatAgent(myChatAgent, { chatId: \"test-1\", clientData: { model } });\ntry {\n  const turn = await harness.sendMessage({ id: \"u1\", role: \"user\", parts: [{ type: \"text\", text: \"hi\" }] });\n  \u002F\u002F assert against turn.chunks\n} finally {\n  await harness.close();\n}\n```\n\nOptions include `mode` (`\"preload\" | \"submit-message\" | \"handover-prepare\" | \"continuation\"`),\n`preload`, `continuation`, `previousRunId`, `snapshot`, `taskContext`, and `setupLocals`. Set\n`taskContext.ctx.attempt.number > 1` to simulate an OOM-retry attempt. `runInMockTaskContext` drives a\nnon-chat task offline.\n\n### 11. Custom transport: the wire protocol\n\nEndpoints: `POST \u002Fapi\u002Fv1\u002Fsessions` (create), `GET \u002Frealtime\u002Fv1\u002Fsessions\u002F{id}\u002Fout` (SSE),\n`POST \u002Frealtime\u002Fv1\u002Fsessions\u002F{id}\u002Fin\u002Fappend`, `POST \u002Fapi\u002Fv1\u002Fsessions\u002F{id}\u002Fclose`. `ChatInputChunk` is\n`{ kind: \"message\"; payload: ChatTaskWirePayload } | { kind: \"stop\"; message? }`. The\n`ChatTaskWirePayload` carries `chatId`, `trigger` (`submit-message | regenerate-message | preload |\nclose | action | handover-prepare`), `message?`, `metadata?`, `action?`, `continuation?`,\n`previousRunId?`, and more. Control records are header-form: `trigger-control: turn-complete` (with\noptional `public-access-token`, `session-in-event-id`) and `trigger-control: upgrade-required`. The\nTS helpers `SSEStreamSubscription` and `controlSubtype(headers)` (documented in\n`docs\u002Fai-chat\u002Fclient-protocol.mdx`) handle batch decoding and control-record filtering for you.\n\n## Common mistakes\n\n- **CRITICAL: sending a follow-up by re-POSTing `POST \u002Fapi\u002Fv1\u002Fsessions`.**\n  ```ts\n  \u002F\u002F Wrong - a cached re-POST silently drops basePayload.message; basePayload is trigger config, not a channel\n  await fetch(\"\u002Fapi\u002Fv1\u002Fsessions\", { method: \"POST\", body: JSON.stringify({ ...createBody }) });\n  \u002F\u002F Correct - append to the session's input channel\n  await fetch(`\u002Frealtime\u002Fv1\u002Fsessions\u002F${id}\u002Fin\u002Fappend`, { method: \"POST\", body: JSON.stringify({ kind: \"message\", payload }) });\n  ```\n\n- **Using the wrong token for `.in` \u002F `.out`.** Use `publicAccessToken` from the create response\n  body (session-scoped). The `x-trigger-jwt` response header is run-scoped and cannot subscribe.\n\n- **Initializing `chat.local` in `onChatStart`.** It is skipped on continuation runs, so `run()`\n  crashes with `chat.local can only be modified after initialization`. Init in `onBoot`.\n\n- **`chat.defer` for the message-history write.** A mid-stream refresh would read `[]`. `await` that\n  write inline before the model streams; reserve `chat.defer` for analytics, audit, cache warming.\n\n- **Giving the HITL tool an `execute`.** `streamText` calls it immediately. Leave it execute-less;\n  the frontend supplies the answer via `addToolOutput` + `sendAutomaticallyWhen`.\n\n- **Declaring sub-agent \u002F heavy tools only on `streamText`.** Also declare them on\n  `chat.agent({ tools })` (or pass to `convertToModelMessages(uiMessages, { tools })` in a custom\n  agent) so `toModelOutput` re-applies on every turn.\n\n- **Importing heavy-execute tools into the Head Start route module.** This is a build-time import\n  chain problem; runtime strip helpers do not fix it. Keep schemas in an `ai` + `zod`-only module.\n\n- **Returning a megabyte tool output on the stream.** One `tool-output-available` record over ~1 MiB\n  throws `ChatChunkTooLargeError`. Persist to your store, write the row first, then emit only an id.\n\n- **Setting `X-Peek-Settled: 1` on the active-send path.** It races the new turn's first chunk and\n  closes the stream early. Use it only on reconnect-on-reload paths.\n\n> Note on docs vocabulary: agent-side examples in some docs still use the legacy\n> `trigger:turn-complete` chunk type. That is the agent-emit vocabulary. A custom **reader** must\n> filter on the `trigger-control` header, not on `chunk.type`.\n>\n> MCP-driven agent chats (`list_agents`, `start_agent_chat`, `send_agent_message`,\n> `close_agent_chat`) are MCP server tools used from Claude Code \u002F Cursor, not importable SDK\n> functions. See `\u002Fmcp-tools#agent-chat-tools`.\n\n## References\n\n- `trigger-authoring-chat-agent` skill - the everyday `chat.agent({...})` definition, lifecycle hooks, and\n  the `useTriggerChatTransport` happy path. Start there before reaching for this skill.\n- `trigger-realtime-and-frontend` skill - Realtime hooks and frontend streaming beyond the chat transport.\n- `trigger-authoring-tasks` skill - base `task()` semantics, `ctx`, and standard lifecycle hooks.\n\nReference docs ship beside this skill in the same package, read them locally (no network), pinned to your installed version. The `sources:` frontmatter above lists every doc this skill draws from, all under `@trigger.dev\u002Fsdk\u002Fdocs\u002Fai-chat\u002F` (including `patterns\u002F`). For HITL, sessions, and sub-agents start with `sessions.mdx`, `server-chat.mdx`, `client-protocol.mdx`, `patterns\u002Fhuman-in-the-loop.mdx`, `patterns\u002Fsub-agents.mdx`.\n\nFor `trigger.config.ts` and build extensions a chat-agent task may need (Prisma, Playwright, Python, etc.), read the bundled config docs under `@trigger.dev\u002Fsdk\u002Fdocs\u002Fconfig\u002F` (`config\u002Fextensions\u002F` for the per-extension setup).\n\n## Version\n\nThis skill is bundled inside `@trigger.dev\u002Fsdk` and read directly from `node_modules`, so it always matches your installed SDK version (see the adjacent `package.json`). The full documentation for these APIs ships alongside it under `@trigger.dev\u002Fsdk\u002Fdocs\u002F`.\n",{"data":45,"body":69},{"name":4,"description":6,"type":46,"library":47,"sources":48},"core","trigger.dev",[49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68],"docs\u002Fai-chat\u002Fsessions.mdx","docs\u002Fai-chat\u002Fserver-chat.mdx","docs\u002Fai-chat\u002Fclient-protocol.mdx","docs\u002Fai-chat\u002Fpending-messages.mdx","docs\u002Fai-chat\u002Factions.mdx","docs\u002Fai-chat\u002Fbackground-injection.mdx","docs\u002Fai-chat\u002Fcompaction.mdx","docs\u002Fai-chat\u002Ffast-starts.mdx","docs\u002Fai-chat\u002Fchat-local.mdx","docs\u002Fai-chat\u002Fmcp.mdx","docs\u002Fai-chat\u002Ftesting.mdx","docs\u002Fai-chat\u002Fupgrade-guide.mdx","docs\u002Fai-chat\u002Fpatterns\u002Fsub-agents.mdx","docs\u002Fai-chat\u002Fpatterns\u002Fhuman-in-the-loop.mdx","docs\u002Fai-chat\u002Fpatterns\u002Fpersistence-and-replay.mdx","docs\u002Fai-chat\u002Fpatterns\u002Frecovery-boot.mdx","docs\u002Fai-chat\u002Fpatterns\u002Foom-resilience.mdx","docs\u002Fai-chat\u002Fpatterns\u002Flarge-payloads.mdx","docs\u002Fai-chat\u002Fpatterns\u002Fversion-upgrades.mdx","docs\u002Fai-chat\u002Ftools.mdx",{"type":70,"children":71},"root",[72,81,134,176,183,194,586,688,694,701,743,1313,1451,1457,1483,2326,2386,2711,2717,2760,3277,3283,3332,3642,3648,3756,4441,4461,4467,4514,5013,5033,5039,5065,5476,5482,5573,5579,5664,5886,5907,5913,6017,6454,6532,6538,6706,6712,7298,7378,7384,7452,7516,7544,7550,7585],{"type":73,"tag":74,"props":75,"children":77},"element","h1",{"id":76},"chatagent-advanced-and-operational",[78],{"type":79,"value":80},"text","chat.agent: advanced and operational",{"type":73,"tag":82,"props":83,"children":84},"p",{},[85,92,94,100,102,108,110,116,118,124,126,132],{"type":73,"tag":86,"props":87,"children":89},"code",{"className":88},[],[90],{"type":79,"value":91},"chat.agent",{"type":79,"value":93}," is built on ",{"type":73,"tag":95,"props":96,"children":97},"strong",{},[98],{"type":79,"value":99},"Sessions",{"type":79,"value":101},": a durable, task-bound, bi-directional I\u002FO channel pair keyed\non a stable ",{"type":73,"tag":86,"props":103,"children":105},{"className":104},[],[106],{"type":79,"value":107},"externalId",{"type":79,"value":109}," (e.g. ",{"type":73,"tag":86,"props":111,"children":113},{"className":112},[],[114],{"type":79,"value":115},"chatId",{"type":79,"value":117},") that outlives any single run. This skill covers the layers\nbeneath and around the everyday agent: the raw ",{"type":73,"tag":86,"props":119,"children":121},{"className":120},[],[122],{"type":79,"value":123},"sessions",{"type":79,"value":125}," API, server-side ",{"type":73,"tag":86,"props":127,"children":129},{"className":128},[],[130],{"type":79,"value":131},"AgentChat",{"type":79,"value":133},", durable\nsub-agents, actions \u002F background injection, fast starts, compaction and recovery, and the wire\nprotocol for custom transports.",{"type":73,"tag":82,"props":135,"children":136},{},[137,139,145,147,152,154,160,162,167,168,174],{"type":79,"value":138},"Two ",{"type":73,"tag":86,"props":140,"children":142},{"className":141},[],[143],{"type":79,"value":144},"chat",{"type":79,"value":146}," namespaces are easy to confuse: the agent definition imports ",{"type":73,"tag":86,"props":148,"children":150},{"className":149},[],[151],{"type":79,"value":144},{"type":79,"value":153}," from\n",{"type":73,"tag":86,"props":155,"children":157},{"className":156},[],[158],{"type":79,"value":159},"@trigger.dev\u002Fsdk\u002Fai",{"type":79,"value":161},"; Head Start \u002F Node-listener server entries import ",{"type":73,"tag":86,"props":163,"children":165},{"className":164},[],[166],{"type":79,"value":144},{"type":79,"value":153},{"type":73,"tag":86,"props":169,"children":171},{"className":170},[],[172],{"type":79,"value":173},"@trigger.dev\u002Fsdk\u002Fchat-server",{"type":79,"value":175},".",{"type":73,"tag":177,"props":178,"children":180},"h2",{"id":179},"setup",[181],{"type":79,"value":182},"Setup",{"type":73,"tag":82,"props":184,"children":185},{},[186,188,193],{"type":79,"value":187},"Happy path: drive an agent from server-side code (task, webhook, or script) with ",{"type":73,"tag":86,"props":189,"children":191},{"className":190},[],[192],{"type":79,"value":131},{"type":79,"value":175},{"type":73,"tag":195,"props":196,"children":201},"pre",{"className":197,"code":198,"language":199,"meta":200,"style":200},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { AgentChat } from \"@trigger.dev\u002Fsdk\u002Fchat\";\nimport type { myAgent } from \".\u002Ftrigger\u002Fmy-agent\";\n\nconst chat = new AgentChat\u003Ctypeof myAgent>({ agent: \"my-chat\", clientData: { userId: \"user_123\" } });\nconst stream = await chat.sendMessage(\"Review PR #42\");\nconst text = await stream.text();\nawait chat.close();\n","ts","",[202],{"type":73,"tag":86,"props":203,"children":204},{"__ignoreMap":200},[205,260,307,317,452,513,556],{"type":73,"tag":206,"props":207,"children":210},"span",{"class":208,"line":209},"line",1,[211,217,223,229,234,239,244,250,255],{"type":73,"tag":206,"props":212,"children":214},{"style":213},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[215],{"type":79,"value":216},"import",{"type":73,"tag":206,"props":218,"children":220},{"style":219},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[221],{"type":79,"value":222}," {",{"type":73,"tag":206,"props":224,"children":226},{"style":225},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[227],{"type":79,"value":228}," AgentChat",{"type":73,"tag":206,"props":230,"children":231},{"style":219},[232],{"type":79,"value":233}," }",{"type":73,"tag":206,"props":235,"children":236},{"style":213},[237],{"type":79,"value":238}," from",{"type":73,"tag":206,"props":240,"children":241},{"style":219},[242],{"type":79,"value":243}," \"",{"type":73,"tag":206,"props":245,"children":247},{"style":246},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[248],{"type":79,"value":249},"@trigger.dev\u002Fsdk\u002Fchat",{"type":73,"tag":206,"props":251,"children":252},{"style":219},[253],{"type":79,"value":254},"\"",{"type":73,"tag":206,"props":256,"children":257},{"style":219},[258],{"type":79,"value":259},";\n",{"type":73,"tag":206,"props":261,"children":263},{"class":208,"line":262},2,[264,268,273,277,282,286,290,294,299,303],{"type":73,"tag":206,"props":265,"children":266},{"style":213},[267],{"type":79,"value":216},{"type":73,"tag":206,"props":269,"children":270},{"style":213},[271],{"type":79,"value":272}," type",{"type":73,"tag":206,"props":274,"children":275},{"style":219},[276],{"type":79,"value":222},{"type":73,"tag":206,"props":278,"children":279},{"style":225},[280],{"type":79,"value":281}," myAgent",{"type":73,"tag":206,"props":283,"children":284},{"style":219},[285],{"type":79,"value":233},{"type":73,"tag":206,"props":287,"children":288},{"style":213},[289],{"type":79,"value":238},{"type":73,"tag":206,"props":291,"children":292},{"style":219},[293],{"type":79,"value":243},{"type":73,"tag":206,"props":295,"children":296},{"style":246},[297],{"type":79,"value":298},".\u002Ftrigger\u002Fmy-agent",{"type":73,"tag":206,"props":300,"children":301},{"style":219},[302],{"type":79,"value":254},{"type":73,"tag":206,"props":304,"children":305},{"style":219},[306],{"type":79,"value":259},{"type":73,"tag":206,"props":308,"children":310},{"class":208,"line":309},3,[311],{"type":73,"tag":206,"props":312,"children":314},{"emptyLinePlaceholder":313},true,[315],{"type":79,"value":316},"\n",{"type":73,"tag":206,"props":318,"children":320},{"class":208,"line":319},4,[321,327,332,337,342,347,352,356,361,366,371,377,382,386,391,395,400,405,409,413,418,422,426,431,435,439,443,448],{"type":73,"tag":206,"props":322,"children":324},{"style":323},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[325],{"type":79,"value":326},"const",{"type":73,"tag":206,"props":328,"children":329},{"style":225},[330],{"type":79,"value":331}," chat ",{"type":73,"tag":206,"props":333,"children":334},{"style":219},[335],{"type":79,"value":336},"=",{"type":73,"tag":206,"props":338,"children":339},{"style":219},[340],{"type":79,"value":341}," new",{"type":73,"tag":206,"props":343,"children":345},{"style":344},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[346],{"type":79,"value":228},{"type":73,"tag":206,"props":348,"children":349},{"style":219},[350],{"type":79,"value":351},"\u003Ctypeof",{"type":73,"tag":206,"props":353,"children":354},{"style":225},[355],{"type":79,"value":281},{"type":73,"tag":206,"props":357,"children":358},{"style":219},[359],{"type":79,"value":360},">",{"type":73,"tag":206,"props":362,"children":363},{"style":225},[364],{"type":79,"value":365},"(",{"type":73,"tag":206,"props":367,"children":368},{"style":219},[369],{"type":79,"value":370},"{",{"type":73,"tag":206,"props":372,"children":374},{"style":373},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[375],{"type":79,"value":376}," agent",{"type":73,"tag":206,"props":378,"children":379},{"style":219},[380],{"type":79,"value":381},":",{"type":73,"tag":206,"props":383,"children":384},{"style":219},[385],{"type":79,"value":243},{"type":73,"tag":206,"props":387,"children":388},{"style":246},[389],{"type":79,"value":390},"my-chat",{"type":73,"tag":206,"props":392,"children":393},{"style":219},[394],{"type":79,"value":254},{"type":73,"tag":206,"props":396,"children":397},{"style":219},[398],{"type":79,"value":399},",",{"type":73,"tag":206,"props":401,"children":402},{"style":373},[403],{"type":79,"value":404}," clientData",{"type":73,"tag":206,"props":406,"children":407},{"style":219},[408],{"type":79,"value":381},{"type":73,"tag":206,"props":410,"children":411},{"style":219},[412],{"type":79,"value":222},{"type":73,"tag":206,"props":414,"children":415},{"style":373},[416],{"type":79,"value":417}," userId",{"type":73,"tag":206,"props":419,"children":420},{"style":219},[421],{"type":79,"value":381},{"type":73,"tag":206,"props":423,"children":424},{"style":219},[425],{"type":79,"value":243},{"type":73,"tag":206,"props":427,"children":428},{"style":246},[429],{"type":79,"value":430},"user_123",{"type":73,"tag":206,"props":432,"children":433},{"style":219},[434],{"type":79,"value":254},{"type":73,"tag":206,"props":436,"children":437},{"style":219},[438],{"type":79,"value":233},{"type":73,"tag":206,"props":440,"children":441},{"style":219},[442],{"type":79,"value":233},{"type":73,"tag":206,"props":444,"children":445},{"style":225},[446],{"type":79,"value":447},")",{"type":73,"tag":206,"props":449,"children":450},{"style":219},[451],{"type":79,"value":259},{"type":73,"tag":206,"props":453,"children":455},{"class":208,"line":454},5,[456,460,465,469,474,479,483,488,492,496,501,505,509],{"type":73,"tag":206,"props":457,"children":458},{"style":323},[459],{"type":79,"value":326},{"type":73,"tag":206,"props":461,"children":462},{"style":225},[463],{"type":79,"value":464}," stream ",{"type":73,"tag":206,"props":466,"children":467},{"style":219},[468],{"type":79,"value":336},{"type":73,"tag":206,"props":470,"children":471},{"style":213},[472],{"type":79,"value":473}," await",{"type":73,"tag":206,"props":475,"children":476},{"style":225},[477],{"type":79,"value":478}," chat",{"type":73,"tag":206,"props":480,"children":481},{"style":219},[482],{"type":79,"value":175},{"type":73,"tag":206,"props":484,"children":485},{"style":344},[486],{"type":79,"value":487},"sendMessage",{"type":73,"tag":206,"props":489,"children":490},{"style":225},[491],{"type":79,"value":365},{"type":73,"tag":206,"props":493,"children":494},{"style":219},[495],{"type":79,"value":254},{"type":73,"tag":206,"props":497,"children":498},{"style":246},[499],{"type":79,"value":500},"Review PR #42",{"type":73,"tag":206,"props":502,"children":503},{"style":219},[504],{"type":79,"value":254},{"type":73,"tag":206,"props":506,"children":507},{"style":225},[508],{"type":79,"value":447},{"type":73,"tag":206,"props":510,"children":511},{"style":219},[512],{"type":79,"value":259},{"type":73,"tag":206,"props":514,"children":516},{"class":208,"line":515},6,[517,521,526,530,534,539,543,547,552],{"type":73,"tag":206,"props":518,"children":519},{"style":323},[520],{"type":79,"value":326},{"type":73,"tag":206,"props":522,"children":523},{"style":225},[524],{"type":79,"value":525}," text ",{"type":73,"tag":206,"props":527,"children":528},{"style":219},[529],{"type":79,"value":336},{"type":73,"tag":206,"props":531,"children":532},{"style":213},[533],{"type":79,"value":473},{"type":73,"tag":206,"props":535,"children":536},{"style":225},[537],{"type":79,"value":538}," stream",{"type":73,"tag":206,"props":540,"children":541},{"style":219},[542],{"type":79,"value":175},{"type":73,"tag":206,"props":544,"children":545},{"style":344},[546],{"type":79,"value":79},{"type":73,"tag":206,"props":548,"children":549},{"style":225},[550],{"type":79,"value":551},"()",{"type":73,"tag":206,"props":553,"children":554},{"style":219},[555],{"type":79,"value":259},{"type":73,"tag":206,"props":557,"children":559},{"class":208,"line":558},7,[560,565,569,573,578,582],{"type":73,"tag":206,"props":561,"children":562},{"style":213},[563],{"type":79,"value":564},"await",{"type":73,"tag":206,"props":566,"children":567},{"style":225},[568],{"type":79,"value":478},{"type":73,"tag":206,"props":570,"children":571},{"style":219},[572],{"type":79,"value":175},{"type":73,"tag":206,"props":574,"children":575},{"style":344},[576],{"type":79,"value":577},"close",{"type":73,"tag":206,"props":579,"children":580},{"style":225},[581],{"type":79,"value":551},{"type":73,"tag":206,"props":583,"children":584},{"style":219},[585],{"type":79,"value":259},{"type":73,"tag":82,"props":587,"children":588},{},[589,595,597,603,605,611,613,619,621,627,629,635,637,643,645,651,652,658,659,665,667,673,674,680,681,687],{"type":73,"tag":86,"props":590,"children":592},{"className":591},[],[593],{"type":79,"value":594},"sendMessage()",{"type":79,"value":596}," triggers a run on the first call, then reuses it via input streams. ",{"type":73,"tag":86,"props":598,"children":600},{"className":599},[],[601],{"type":79,"value":602},"ChatStream",{"type":79,"value":604},"\nexposes ",{"type":73,"tag":86,"props":606,"children":608},{"className":607},[],[609],{"type":79,"value":610},"text()",{"type":79,"value":612},", ",{"type":73,"tag":86,"props":614,"children":616},{"className":615},[],[617],{"type":79,"value":618},"result()",{"type":79,"value":620}," (",{"type":73,"tag":86,"props":622,"children":624},{"className":623},[],[625],{"type":79,"value":626},"{ text, toolCalls, toolResults }",{"type":79,"value":628},"), ",{"type":73,"tag":86,"props":630,"children":632},{"className":631},[],[633],{"type":79,"value":634},"messages()",{"type":79,"value":636}," (UIMessage\nsnapshots), and the raw ",{"type":73,"tag":86,"props":638,"children":640},{"className":639},[],[641],{"type":79,"value":642},".stream",{"type":79,"value":644},". Other methods: ",{"type":73,"tag":86,"props":646,"children":648},{"className":647},[],[649],{"type":79,"value":650},"steer(text)",{"type":79,"value":612},{"type":73,"tag":86,"props":653,"children":655},{"className":654},[],[656],{"type":79,"value":657},"stop()",{"type":79,"value":612},{"type":73,"tag":86,"props":660,"children":662},{"className":661},[],[663],{"type":79,"value":664},"sendRaw(uiMessages)",{"type":79,"value":666},",\n",{"type":73,"tag":86,"props":668,"children":670},{"className":669},[],[671],{"type":79,"value":672},"sendAction(action)",{"type":79,"value":612},{"type":73,"tag":86,"props":675,"children":677},{"className":676},[],[678],{"type":79,"value":679},"preload()",{"type":79,"value":612},{"type":73,"tag":86,"props":682,"children":684},{"className":683},[],[685],{"type":79,"value":686},"reconnect()",{"type":79,"value":175},{"type":73,"tag":177,"props":689,"children":691},{"id":690},"core-patterns",[692],{"type":79,"value":693},"Core patterns",{"type":73,"tag":695,"props":696,"children":698},"h3",{"id":697},"_1-raw-sessions-for-non-chat-bi-directional-io",[699],{"type":79,"value":700},"1. Raw Sessions for non-chat, bi-directional I\u002FO",{"type":73,"tag":82,"props":702,"children":703},{},[704,706,711,713,719,721,727,729,734,736,742],{"type":79,"value":705},"Reach for ",{"type":73,"tag":86,"props":707,"children":709},{"className":708},[],[710],{"type":79,"value":123},{"type":79,"value":712}," directly when the chat abstraction does not fit: agent inboxes, approval flows,\nserver-to-server pipelines. ",{"type":73,"tag":86,"props":714,"children":716},{"className":715},[],[717],{"type":79,"value":718},"sessions.start",{"type":79,"value":720}," is idempotent on ",{"type":73,"tag":86,"props":722,"children":724},{"className":723},[],[725],{"type":79,"value":726},"(env, externalId)",{"type":79,"value":728},"; ",{"type":73,"tag":86,"props":730,"children":732},{"className":731},[],[733],{"type":79,"value":107},{"type":79,"value":735},"\ncannot start with ",{"type":73,"tag":86,"props":737,"children":739},{"className":738},[],[740],{"type":79,"value":741},"session_",{"type":79,"value":175},{"type":73,"tag":195,"props":744,"children":746},{"className":197,"code":745,"language":199,"meta":200,"style":200},"import { sessions } from \"@trigger.dev\u002Fsdk\";\n\nconst { id, publicAccessToken } = await sessions.start({\n  type: \"chat.agent\",\n  externalId: chatId,\n  taskIdentifier: \"my-chat\",\n  triggerConfig: { tags: [`chat:${chatId}`], basePayload: { chatId, trigger: \"preload\" } },\n});\n\nconst session = sessions.open(chatId); \u002F\u002F no network call; methods are lazy\nawait session.out.append({ kind: \"message\", text: \"hello\" });\nconst next = await session.in.once\u003CMyEvent>({ timeoutMs: 30_000 });\n",[747],{"type":73,"tag":86,"props":748,"children":749},{"__ignoreMap":200},[750,791,798,859,887,908,936,1051,1067,1075,1121,1220],{"type":73,"tag":206,"props":751,"children":752},{"class":208,"line":209},[753,757,761,766,770,774,778,783,787],{"type":73,"tag":206,"props":754,"children":755},{"style":213},[756],{"type":79,"value":216},{"type":73,"tag":206,"props":758,"children":759},{"style":219},[760],{"type":79,"value":222},{"type":73,"tag":206,"props":762,"children":763},{"style":225},[764],{"type":79,"value":765}," sessions",{"type":73,"tag":206,"props":767,"children":768},{"style":219},[769],{"type":79,"value":233},{"type":73,"tag":206,"props":771,"children":772},{"style":213},[773],{"type":79,"value":238},{"type":73,"tag":206,"props":775,"children":776},{"style":219},[777],{"type":79,"value":243},{"type":73,"tag":206,"props":779,"children":780},{"style":246},[781],{"type":79,"value":782},"@trigger.dev\u002Fsdk",{"type":73,"tag":206,"props":784,"children":785},{"style":219},[786],{"type":79,"value":254},{"type":73,"tag":206,"props":788,"children":789},{"style":219},[790],{"type":79,"value":259},{"type":73,"tag":206,"props":792,"children":793},{"class":208,"line":262},[794],{"type":73,"tag":206,"props":795,"children":796},{"emptyLinePlaceholder":313},[797],{"type":79,"value":316},{"type":73,"tag":206,"props":799,"children":800},{"class":208,"line":309},[801,805,809,814,818,823,828,833,837,841,845,850,854],{"type":73,"tag":206,"props":802,"children":803},{"style":323},[804],{"type":79,"value":326},{"type":73,"tag":206,"props":806,"children":807},{"style":219},[808],{"type":79,"value":222},{"type":73,"tag":206,"props":810,"children":811},{"style":225},[812],{"type":79,"value":813}," id",{"type":73,"tag":206,"props":815,"children":816},{"style":219},[817],{"type":79,"value":399},{"type":73,"tag":206,"props":819,"children":820},{"style":225},[821],{"type":79,"value":822}," publicAccessToken ",{"type":73,"tag":206,"props":824,"children":825},{"style":219},[826],{"type":79,"value":827},"}",{"type":73,"tag":206,"props":829,"children":830},{"style":219},[831],{"type":79,"value":832}," =",{"type":73,"tag":206,"props":834,"children":835},{"style":213},[836],{"type":79,"value":473},{"type":73,"tag":206,"props":838,"children":839},{"style":225},[840],{"type":79,"value":765},{"type":73,"tag":206,"props":842,"children":843},{"style":219},[844],{"type":79,"value":175},{"type":73,"tag":206,"props":846,"children":847},{"style":344},[848],{"type":79,"value":849},"start",{"type":73,"tag":206,"props":851,"children":852},{"style":225},[853],{"type":79,"value":365},{"type":73,"tag":206,"props":855,"children":856},{"style":219},[857],{"type":79,"value":858},"{\n",{"type":73,"tag":206,"props":860,"children":861},{"class":208,"line":319},[862,867,871,875,879,883],{"type":73,"tag":206,"props":863,"children":864},{"style":373},[865],{"type":79,"value":866},"  type",{"type":73,"tag":206,"props":868,"children":869},{"style":219},[870],{"type":79,"value":381},{"type":73,"tag":206,"props":872,"children":873},{"style":219},[874],{"type":79,"value":243},{"type":73,"tag":206,"props":876,"children":877},{"style":246},[878],{"type":79,"value":91},{"type":73,"tag":206,"props":880,"children":881},{"style":219},[882],{"type":79,"value":254},{"type":73,"tag":206,"props":884,"children":885},{"style":219},[886],{"type":79,"value":666},{"type":73,"tag":206,"props":888,"children":889},{"class":208,"line":454},[890,895,899,904],{"type":73,"tag":206,"props":891,"children":892},{"style":373},[893],{"type":79,"value":894},"  externalId",{"type":73,"tag":206,"props":896,"children":897},{"style":219},[898],{"type":79,"value":381},{"type":73,"tag":206,"props":900,"children":901},{"style":225},[902],{"type":79,"value":903}," chatId",{"type":73,"tag":206,"props":905,"children":906},{"style":219},[907],{"type":79,"value":666},{"type":73,"tag":206,"props":909,"children":910},{"class":208,"line":515},[911,916,920,924,928,932],{"type":73,"tag":206,"props":912,"children":913},{"style":373},[914],{"type":79,"value":915},"  taskIdentifier",{"type":73,"tag":206,"props":917,"children":918},{"style":219},[919],{"type":79,"value":381},{"type":73,"tag":206,"props":921,"children":922},{"style":219},[923],{"type":79,"value":243},{"type":73,"tag":206,"props":925,"children":926},{"style":246},[927],{"type":79,"value":390},{"type":73,"tag":206,"props":929,"children":930},{"style":219},[931],{"type":79,"value":254},{"type":73,"tag":206,"props":933,"children":934},{"style":219},[935],{"type":79,"value":666},{"type":73,"tag":206,"props":937,"children":938},{"class":208,"line":558},[939,944,948,952,957,961,966,971,976,981,985,990,995,999,1004,1008,1012,1016,1020,1025,1029,1033,1038,1042,1046],{"type":73,"tag":206,"props":940,"children":941},{"style":373},[942],{"type":79,"value":943},"  triggerConfig",{"type":73,"tag":206,"props":945,"children":946},{"style":219},[947],{"type":79,"value":381},{"type":73,"tag":206,"props":949,"children":950},{"style":219},[951],{"type":79,"value":222},{"type":73,"tag":206,"props":953,"children":954},{"style":373},[955],{"type":79,"value":956}," tags",{"type":73,"tag":206,"props":958,"children":959},{"style":219},[960],{"type":79,"value":381},{"type":73,"tag":206,"props":962,"children":963},{"style":225},[964],{"type":79,"value":965}," [",{"type":73,"tag":206,"props":967,"children":968},{"style":219},[969],{"type":79,"value":970},"`",{"type":73,"tag":206,"props":972,"children":973},{"style":246},[974],{"type":79,"value":975},"chat:",{"type":73,"tag":206,"props":977,"children":978},{"style":219},[979],{"type":79,"value":980},"${",{"type":73,"tag":206,"props":982,"children":983},{"style":225},[984],{"type":79,"value":115},{"type":73,"tag":206,"props":986,"children":987},{"style":219},[988],{"type":79,"value":989},"}`",{"type":73,"tag":206,"props":991,"children":992},{"style":225},[993],{"type":79,"value":994},"]",{"type":73,"tag":206,"props":996,"children":997},{"style":219},[998],{"type":79,"value":399},{"type":73,"tag":206,"props":1000,"children":1001},{"style":373},[1002],{"type":79,"value":1003}," basePayload",{"type":73,"tag":206,"props":1005,"children":1006},{"style":219},[1007],{"type":79,"value":381},{"type":73,"tag":206,"props":1009,"children":1010},{"style":219},[1011],{"type":79,"value":222},{"type":73,"tag":206,"props":1013,"children":1014},{"style":225},[1015],{"type":79,"value":903},{"type":73,"tag":206,"props":1017,"children":1018},{"style":219},[1019],{"type":79,"value":399},{"type":73,"tag":206,"props":1021,"children":1022},{"style":373},[1023],{"type":79,"value":1024}," trigger",{"type":73,"tag":206,"props":1026,"children":1027},{"style":219},[1028],{"type":79,"value":381},{"type":73,"tag":206,"props":1030,"children":1031},{"style":219},[1032],{"type":79,"value":243},{"type":73,"tag":206,"props":1034,"children":1035},{"style":246},[1036],{"type":79,"value":1037},"preload",{"type":73,"tag":206,"props":1039,"children":1040},{"style":219},[1041],{"type":79,"value":254},{"type":73,"tag":206,"props":1043,"children":1044},{"style":219},[1045],{"type":79,"value":233},{"type":73,"tag":206,"props":1047,"children":1048},{"style":219},[1049],{"type":79,"value":1050}," },\n",{"type":73,"tag":206,"props":1052,"children":1054},{"class":208,"line":1053},8,[1055,1059,1063],{"type":73,"tag":206,"props":1056,"children":1057},{"style":219},[1058],{"type":79,"value":827},{"type":73,"tag":206,"props":1060,"children":1061},{"style":225},[1062],{"type":79,"value":447},{"type":73,"tag":206,"props":1064,"children":1065},{"style":219},[1066],{"type":79,"value":259},{"type":73,"tag":206,"props":1068,"children":1070},{"class":208,"line":1069},9,[1071],{"type":73,"tag":206,"props":1072,"children":1073},{"emptyLinePlaceholder":313},[1074],{"type":79,"value":316},{"type":73,"tag":206,"props":1076,"children":1078},{"class":208,"line":1077},10,[1079,1083,1088,1092,1096,1100,1105,1110,1115],{"type":73,"tag":206,"props":1080,"children":1081},{"style":323},[1082],{"type":79,"value":326},{"type":73,"tag":206,"props":1084,"children":1085},{"style":225},[1086],{"type":79,"value":1087}," session ",{"type":73,"tag":206,"props":1089,"children":1090},{"style":219},[1091],{"type":79,"value":336},{"type":73,"tag":206,"props":1093,"children":1094},{"style":225},[1095],{"type":79,"value":765},{"type":73,"tag":206,"props":1097,"children":1098},{"style":219},[1099],{"type":79,"value":175},{"type":73,"tag":206,"props":1101,"children":1102},{"style":344},[1103],{"type":79,"value":1104},"open",{"type":73,"tag":206,"props":1106,"children":1107},{"style":225},[1108],{"type":79,"value":1109},"(chatId)",{"type":73,"tag":206,"props":1111,"children":1112},{"style":219},[1113],{"type":79,"value":1114},";",{"type":73,"tag":206,"props":1116,"children":1118},{"style":1117},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[1119],{"type":79,"value":1120}," \u002F\u002F no network call; methods are lazy\n",{"type":73,"tag":206,"props":1122,"children":1124},{"class":208,"line":1123},11,[1125,1129,1134,1138,1143,1147,1152,1156,1160,1165,1169,1173,1178,1182,1186,1191,1195,1199,1204,1208,1212,1216],{"type":73,"tag":206,"props":1126,"children":1127},{"style":213},[1128],{"type":79,"value":564},{"type":73,"tag":206,"props":1130,"children":1131},{"style":225},[1132],{"type":79,"value":1133}," session",{"type":73,"tag":206,"props":1135,"children":1136},{"style":219},[1137],{"type":79,"value":175},{"type":73,"tag":206,"props":1139,"children":1140},{"style":225},[1141],{"type":79,"value":1142},"out",{"type":73,"tag":206,"props":1144,"children":1145},{"style":219},[1146],{"type":79,"value":175},{"type":73,"tag":206,"props":1148,"children":1149},{"style":344},[1150],{"type":79,"value":1151},"append",{"type":73,"tag":206,"props":1153,"children":1154},{"style":225},[1155],{"type":79,"value":365},{"type":73,"tag":206,"props":1157,"children":1158},{"style":219},[1159],{"type":79,"value":370},{"type":73,"tag":206,"props":1161,"children":1162},{"style":373},[1163],{"type":79,"value":1164}," kind",{"type":73,"tag":206,"props":1166,"children":1167},{"style":219},[1168],{"type":79,"value":381},{"type":73,"tag":206,"props":1170,"children":1171},{"style":219},[1172],{"type":79,"value":243},{"type":73,"tag":206,"props":1174,"children":1175},{"style":246},[1176],{"type":79,"value":1177},"message",{"type":73,"tag":206,"props":1179,"children":1180},{"style":219},[1181],{"type":79,"value":254},{"type":73,"tag":206,"props":1183,"children":1184},{"style":219},[1185],{"type":79,"value":399},{"type":73,"tag":206,"props":1187,"children":1188},{"style":373},[1189],{"type":79,"value":1190}," text",{"type":73,"tag":206,"props":1192,"children":1193},{"style":219},[1194],{"type":79,"value":381},{"type":73,"tag":206,"props":1196,"children":1197},{"style":219},[1198],{"type":79,"value":243},{"type":73,"tag":206,"props":1200,"children":1201},{"style":246},[1202],{"type":79,"value":1203},"hello",{"type":73,"tag":206,"props":1205,"children":1206},{"style":219},[1207],{"type":79,"value":254},{"type":73,"tag":206,"props":1209,"children":1210},{"style":219},[1211],{"type":79,"value":233},{"type":73,"tag":206,"props":1213,"children":1214},{"style":225},[1215],{"type":79,"value":447},{"type":73,"tag":206,"props":1217,"children":1218},{"style":219},[1219],{"type":79,"value":259},{"type":73,"tag":206,"props":1221,"children":1223},{"class":208,"line":1222},12,[1224,1228,1233,1237,1241,1245,1249,1254,1258,1263,1268,1274,1278,1282,1286,1291,1295,1301,1305,1309],{"type":73,"tag":206,"props":1225,"children":1226},{"style":323},[1227],{"type":79,"value":326},{"type":73,"tag":206,"props":1229,"children":1230},{"style":225},[1231],{"type":79,"value":1232}," next ",{"type":73,"tag":206,"props":1234,"children":1235},{"style":219},[1236],{"type":79,"value":336},{"type":73,"tag":206,"props":1238,"children":1239},{"style":213},[1240],{"type":79,"value":473},{"type":73,"tag":206,"props":1242,"children":1243},{"style":225},[1244],{"type":79,"value":1133},{"type":73,"tag":206,"props":1246,"children":1247},{"style":219},[1248],{"type":79,"value":175},{"type":73,"tag":206,"props":1250,"children":1251},{"style":225},[1252],{"type":79,"value":1253},"in",{"type":73,"tag":206,"props":1255,"children":1256},{"style":219},[1257],{"type":79,"value":175},{"type":73,"tag":206,"props":1259,"children":1260},{"style":344},[1261],{"type":79,"value":1262},"once",{"type":73,"tag":206,"props":1264,"children":1265},{"style":219},[1266],{"type":79,"value":1267},"\u003C",{"type":73,"tag":206,"props":1269,"children":1271},{"style":1270},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[1272],{"type":79,"value":1273},"MyEvent",{"type":73,"tag":206,"props":1275,"children":1276},{"style":219},[1277],{"type":79,"value":360},{"type":73,"tag":206,"props":1279,"children":1280},{"style":225},[1281],{"type":79,"value":365},{"type":73,"tag":206,"props":1283,"children":1284},{"style":219},[1285],{"type":79,"value":370},{"type":73,"tag":206,"props":1287,"children":1288},{"style":373},[1289],{"type":79,"value":1290}," timeoutMs",{"type":73,"tag":206,"props":1292,"children":1293},{"style":219},[1294],{"type":79,"value":381},{"type":73,"tag":206,"props":1296,"children":1298},{"style":1297},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[1299],{"type":79,"value":1300}," 30_000",{"type":73,"tag":206,"props":1302,"children":1303},{"style":219},[1304],{"type":79,"value":233},{"type":73,"tag":206,"props":1306,"children":1307},{"style":225},[1308],{"type":79,"value":447},{"type":73,"tag":206,"props":1310,"children":1311},{"style":219},[1312],{"type":79,"value":259},{"type":73,"tag":82,"props":1314,"children":1315},{},[1316,1322,1324,1330,1331,1337,1338,1344,1345,1351,1353,1359,1361,1367,1369,1375,1377,1382,1383,1389,1390,1396,1397,1403,1404,1410,1412,1418,1420,1426,1427,1433,1435,1441,1443,1449],{"type":73,"tag":86,"props":1317,"children":1319},{"className":1318},[],[1320],{"type":79,"value":1321},"sessions.open(id).in",{"type":79,"value":1323}," also has ",{"type":73,"tag":86,"props":1325,"children":1327},{"className":1326},[],[1328],{"type":79,"value":1329},"send",{"type":79,"value":612},{"type":73,"tag":86,"props":1332,"children":1334},{"className":1333},[],[1335],{"type":79,"value":1336},"on(handler)",{"type":79,"value":612},{"type":73,"tag":86,"props":1339,"children":1341},{"className":1340},[],[1342],{"type":79,"value":1343},"peek",{"type":79,"value":612},{"type":73,"tag":86,"props":1346,"children":1348},{"className":1347},[],[1349],{"type":79,"value":1350},"wait",{"type":79,"value":1352}," (suspends the run, only inside\n",{"type":73,"tag":86,"props":1354,"children":1356},{"className":1355},[],[1357],{"type":79,"value":1358},"task.run()",{"type":79,"value":1360},"), and ",{"type":73,"tag":86,"props":1362,"children":1364},{"className":1363},[],[1365],{"type":79,"value":1366},"waitWithIdleTimeout",{"type":79,"value":1368},". ",{"type":73,"tag":86,"props":1370,"children":1372},{"className":1371},[],[1373],{"type":79,"value":1374},".out",{"type":79,"value":1376}," has ",{"type":73,"tag":86,"props":1378,"children":1380},{"className":1379},[],[1381],{"type":79,"value":1151},{"type":79,"value":612},{"type":73,"tag":86,"props":1384,"children":1386},{"className":1385},[],[1387],{"type":79,"value":1388},"pipe",{"type":79,"value":612},{"type":73,"tag":86,"props":1391,"children":1393},{"className":1392},[],[1394],{"type":79,"value":1395},"writer",{"type":79,"value":612},{"type":73,"tag":86,"props":1398,"children":1400},{"className":1399},[],[1401],{"type":79,"value":1402},"read",{"type":79,"value":666},{"type":73,"tag":86,"props":1405,"children":1407},{"className":1406},[],[1408],{"type":79,"value":1409},"writeControl",{"type":79,"value":1411},", and ",{"type":73,"tag":86,"props":1413,"children":1415},{"className":1414},[],[1416],{"type":79,"value":1417},"trimTo",{"type":79,"value":1419},". List with ",{"type":73,"tag":86,"props":1421,"children":1423},{"className":1422},[],[1424],{"type":79,"value":1425},"sessions.list({ type, tag, status, ... })",{"type":79,"value":620},{"type":73,"tag":86,"props":1428,"children":1430},{"className":1429},[],[1431],{"type":79,"value":1432},"for await",{"type":79,"value":1434},"),\nmutate with ",{"type":73,"tag":86,"props":1436,"children":1438},{"className":1437},[],[1439],{"type":79,"value":1440},"sessions.update",{"type":79,"value":1442},", end with ",{"type":73,"tag":86,"props":1444,"children":1446},{"className":1445},[],[1447],{"type":79,"value":1448},"sessions.close",{"type":79,"value":1450}," (terminal, idempotent).",{"type":73,"tag":695,"props":1452,"children":1454},{"id":1453},"_2-durable-sub-agent-as-a-streaming-tool",[1455],{"type":79,"value":1456},"2. Durable sub-agent as a streaming tool",{"type":73,"tag":82,"props":1458,"children":1459},{},[1460,1465,1467,1473,1475,1481],{"type":73,"tag":86,"props":1461,"children":1463},{"className":1462},[],[1464],{"type":79,"value":131},{"type":79,"value":1466}," inside an AI SDK ",{"type":73,"tag":86,"props":1468,"children":1470},{"className":1469},[],[1471],{"type":79,"value":1472},"tool()",{"type":79,"value":1474}," delegates to a durable sub-agent; its response streams as\npreliminary tool results. Give the tool a ",{"type":73,"tag":86,"props":1476,"children":1478},{"className":1477},[],[1479],{"type":79,"value":1480},"toModelOutput",{"type":79,"value":1482}," so the model sees a compact summary.",{"type":73,"tag":195,"props":1484,"children":1486},{"className":197,"code":1485,"language":199,"meta":200,"style":200},"import { tool } from \"ai\";\nimport { AgentChat } from \"@trigger.dev\u002Fsdk\u002Fchat\";\nimport { z } from \"zod\";\n\nconst researchTool = tool({\n  description: \"Delegate research to a specialist agent.\",\n  inputSchema: z.object({ topic: z.string() }),\n  execute: async function* ({ topic }, { abortSignal }) {\n    const chat = new AgentChat({ agent: \"research-agent\" });\n    const stream = await chat.sendMessage(topic, { abortSignal });\n    yield* stream.messages(); \u002F\u002F UIMessage snapshots become preliminary tool results\n    await chat.close();\n  },\n  toModelOutput: ({ output: message }) => {\n    const lastText = message?.parts?.findLast((p: { type: string }) => p.type === \"text\") as\n      | { text?: string }\n      | undefined;\n    return { type: \"text\", value: lastText?.text ?? \"Done.\" };\n  },\n});\n",[1487],{"type":73,"tag":86,"props":1488,"children":1489},{"__ignoreMap":200},[1490,1530,1569,1610,1617,1645,1674,1746,1807,1872,1936,1974,2002,2011,2055,2177,2208,2221,2302,2310],{"type":73,"tag":206,"props":1491,"children":1492},{"class":208,"line":209},[1493,1497,1501,1506,1510,1514,1518,1522,1526],{"type":73,"tag":206,"props":1494,"children":1495},{"style":213},[1496],{"type":79,"value":216},{"type":73,"tag":206,"props":1498,"children":1499},{"style":219},[1500],{"type":79,"value":222},{"type":73,"tag":206,"props":1502,"children":1503},{"style":225},[1504],{"type":79,"value":1505}," tool",{"type":73,"tag":206,"props":1507,"children":1508},{"style":219},[1509],{"type":79,"value":233},{"type":73,"tag":206,"props":1511,"children":1512},{"style":213},[1513],{"type":79,"value":238},{"type":73,"tag":206,"props":1515,"children":1516},{"style":219},[1517],{"type":79,"value":243},{"type":73,"tag":206,"props":1519,"children":1520},{"style":246},[1521],{"type":79,"value":27},{"type":73,"tag":206,"props":1523,"children":1524},{"style":219},[1525],{"type":79,"value":254},{"type":73,"tag":206,"props":1527,"children":1528},{"style":219},[1529],{"type":79,"value":259},{"type":73,"tag":206,"props":1531,"children":1532},{"class":208,"line":262},[1533,1537,1541,1545,1549,1553,1557,1561,1565],{"type":73,"tag":206,"props":1534,"children":1535},{"style":213},[1536],{"type":79,"value":216},{"type":73,"tag":206,"props":1538,"children":1539},{"style":219},[1540],{"type":79,"value":222},{"type":73,"tag":206,"props":1542,"children":1543},{"style":225},[1544],{"type":79,"value":228},{"type":73,"tag":206,"props":1546,"children":1547},{"style":219},[1548],{"type":79,"value":233},{"type":73,"tag":206,"props":1550,"children":1551},{"style":213},[1552],{"type":79,"value":238},{"type":73,"tag":206,"props":1554,"children":1555},{"style":219},[1556],{"type":79,"value":243},{"type":73,"tag":206,"props":1558,"children":1559},{"style":246},[1560],{"type":79,"value":249},{"type":73,"tag":206,"props":1562,"children":1563},{"style":219},[1564],{"type":79,"value":254},{"type":73,"tag":206,"props":1566,"children":1567},{"style":219},[1568],{"type":79,"value":259},{"type":73,"tag":206,"props":1570,"children":1571},{"class":208,"line":309},[1572,1576,1580,1585,1589,1593,1597,1602,1606],{"type":73,"tag":206,"props":1573,"children":1574},{"style":213},[1575],{"type":79,"value":216},{"type":73,"tag":206,"props":1577,"children":1578},{"style":219},[1579],{"type":79,"value":222},{"type":73,"tag":206,"props":1581,"children":1582},{"style":225},[1583],{"type":79,"value":1584}," z",{"type":73,"tag":206,"props":1586,"children":1587},{"style":219},[1588],{"type":79,"value":233},{"type":73,"tag":206,"props":1590,"children":1591},{"style":213},[1592],{"type":79,"value":238},{"type":73,"tag":206,"props":1594,"children":1595},{"style":219},[1596],{"type":79,"value":243},{"type":73,"tag":206,"props":1598,"children":1599},{"style":246},[1600],{"type":79,"value":1601},"zod",{"type":73,"tag":206,"props":1603,"children":1604},{"style":219},[1605],{"type":79,"value":254},{"type":73,"tag":206,"props":1607,"children":1608},{"style":219},[1609],{"type":79,"value":259},{"type":73,"tag":206,"props":1611,"children":1612},{"class":208,"line":319},[1613],{"type":73,"tag":206,"props":1614,"children":1615},{"emptyLinePlaceholder":313},[1616],{"type":79,"value":316},{"type":73,"tag":206,"props":1618,"children":1619},{"class":208,"line":454},[1620,1624,1629,1633,1637,1641],{"type":73,"tag":206,"props":1621,"children":1622},{"style":323},[1623],{"type":79,"value":326},{"type":73,"tag":206,"props":1625,"children":1626},{"style":225},[1627],{"type":79,"value":1628}," researchTool ",{"type":73,"tag":206,"props":1630,"children":1631},{"style":219},[1632],{"type":79,"value":336},{"type":73,"tag":206,"props":1634,"children":1635},{"style":344},[1636],{"type":79,"value":1505},{"type":73,"tag":206,"props":1638,"children":1639},{"style":225},[1640],{"type":79,"value":365},{"type":73,"tag":206,"props":1642,"children":1643},{"style":219},[1644],{"type":79,"value":858},{"type":73,"tag":206,"props":1646,"children":1647},{"class":208,"line":515},[1648,1653,1657,1661,1666,1670],{"type":73,"tag":206,"props":1649,"children":1650},{"style":373},[1651],{"type":79,"value":1652},"  description",{"type":73,"tag":206,"props":1654,"children":1655},{"style":219},[1656],{"type":79,"value":381},{"type":73,"tag":206,"props":1658,"children":1659},{"style":219},[1660],{"type":79,"value":243},{"type":73,"tag":206,"props":1662,"children":1663},{"style":246},[1664],{"type":79,"value":1665},"Delegate research to a specialist agent.",{"type":73,"tag":206,"props":1667,"children":1668},{"style":219},[1669],{"type":79,"value":254},{"type":73,"tag":206,"props":1671,"children":1672},{"style":219},[1673],{"type":79,"value":666},{"type":73,"tag":206,"props":1675,"children":1676},{"class":208,"line":558},[1677,1682,1686,1690,1694,1699,1703,1707,1712,1716,1720,1724,1729,1734,1738,1742],{"type":73,"tag":206,"props":1678,"children":1679},{"style":373},[1680],{"type":79,"value":1681},"  inputSchema",{"type":73,"tag":206,"props":1683,"children":1684},{"style":219},[1685],{"type":79,"value":381},{"type":73,"tag":206,"props":1687,"children":1688},{"style":225},[1689],{"type":79,"value":1584},{"type":73,"tag":206,"props":1691,"children":1692},{"style":219},[1693],{"type":79,"value":175},{"type":73,"tag":206,"props":1695,"children":1696},{"style":344},[1697],{"type":79,"value":1698},"object",{"type":73,"tag":206,"props":1700,"children":1701},{"style":225},[1702],{"type":79,"value":365},{"type":73,"tag":206,"props":1704,"children":1705},{"style":219},[1706],{"type":79,"value":370},{"type":73,"tag":206,"props":1708,"children":1709},{"style":373},[1710],{"type":79,"value":1711}," topic",{"type":73,"tag":206,"props":1713,"children":1714},{"style":219},[1715],{"type":79,"value":381},{"type":73,"tag":206,"props":1717,"children":1718},{"style":225},[1719],{"type":79,"value":1584},{"type":73,"tag":206,"props":1721,"children":1722},{"style":219},[1723],{"type":79,"value":175},{"type":73,"tag":206,"props":1725,"children":1726},{"style":344},[1727],{"type":79,"value":1728},"string",{"type":73,"tag":206,"props":1730,"children":1731},{"style":225},[1732],{"type":79,"value":1733},"() ",{"type":73,"tag":206,"props":1735,"children":1736},{"style":219},[1737],{"type":79,"value":827},{"type":73,"tag":206,"props":1739,"children":1740},{"style":225},[1741],{"type":79,"value":447},{"type":73,"tag":206,"props":1743,"children":1744},{"style":219},[1745],{"type":79,"value":666},{"type":73,"tag":206,"props":1747,"children":1748},{"class":208,"line":1053},[1749,1754,1758,1763,1768,1773,1778,1783,1788,1792,1797,1802],{"type":73,"tag":206,"props":1750,"children":1751},{"style":344},[1752],{"type":79,"value":1753},"  execute",{"type":73,"tag":206,"props":1755,"children":1756},{"style":219},[1757],{"type":79,"value":381},{"type":73,"tag":206,"props":1759,"children":1760},{"style":323},[1761],{"type":79,"value":1762}," async",{"type":73,"tag":206,"props":1764,"children":1765},{"style":323},[1766],{"type":79,"value":1767}," function",{"type":73,"tag":206,"props":1769,"children":1770},{"style":219},[1771],{"type":79,"value":1772},"*",{"type":73,"tag":206,"props":1774,"children":1775},{"style":219},[1776],{"type":79,"value":1777}," ({",{"type":73,"tag":206,"props":1779,"children":1781},{"style":1780},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[1782],{"type":79,"value":1711},{"type":73,"tag":206,"props":1784,"children":1785},{"style":219},[1786],{"type":79,"value":1787}," },",{"type":73,"tag":206,"props":1789,"children":1790},{"style":219},[1791],{"type":79,"value":222},{"type":73,"tag":206,"props":1793,"children":1794},{"style":1780},[1795],{"type":79,"value":1796}," abortSignal",{"type":73,"tag":206,"props":1798,"children":1799},{"style":219},[1800],{"type":79,"value":1801}," })",{"type":73,"tag":206,"props":1803,"children":1804},{"style":219},[1805],{"type":79,"value":1806}," {\n",{"type":73,"tag":206,"props":1808,"children":1809},{"class":208,"line":1069},[1810,1815,1819,1823,1827,1831,1835,1839,1843,1847,1851,1856,1860,1864,1868],{"type":73,"tag":206,"props":1811,"children":1812},{"style":323},[1813],{"type":79,"value":1814},"    const",{"type":73,"tag":206,"props":1816,"children":1817},{"style":225},[1818],{"type":79,"value":478},{"type":73,"tag":206,"props":1820,"children":1821},{"style":219},[1822],{"type":79,"value":832},{"type":73,"tag":206,"props":1824,"children":1825},{"style":219},[1826],{"type":79,"value":341},{"type":73,"tag":206,"props":1828,"children":1829},{"style":344},[1830],{"type":79,"value":228},{"type":73,"tag":206,"props":1832,"children":1833},{"style":373},[1834],{"type":79,"value":365},{"type":73,"tag":206,"props":1836,"children":1837},{"style":219},[1838],{"type":79,"value":370},{"type":73,"tag":206,"props":1840,"children":1841},{"style":373},[1842],{"type":79,"value":376},{"type":73,"tag":206,"props":1844,"children":1845},{"style":219},[1846],{"type":79,"value":381},{"type":73,"tag":206,"props":1848,"children":1849},{"style":219},[1850],{"type":79,"value":243},{"type":73,"tag":206,"props":1852,"children":1853},{"style":246},[1854],{"type":79,"value":1855},"research-agent",{"type":73,"tag":206,"props":1857,"children":1858},{"style":219},[1859],{"type":79,"value":254},{"type":73,"tag":206,"props":1861,"children":1862},{"style":219},[1863],{"type":79,"value":233},{"type":73,"tag":206,"props":1865,"children":1866},{"style":373},[1867],{"type":79,"value":447},{"type":73,"tag":206,"props":1869,"children":1870},{"style":219},[1871],{"type":79,"value":259},{"type":73,"tag":206,"props":1873,"children":1874},{"class":208,"line":1077},[1875,1879,1883,1887,1891,1895,1899,1903,1907,1912,1916,1920,1924,1928,1932],{"type":73,"tag":206,"props":1876,"children":1877},{"style":323},[1878],{"type":79,"value":1814},{"type":73,"tag":206,"props":1880,"children":1881},{"style":225},[1882],{"type":79,"value":538},{"type":73,"tag":206,"props":1884,"children":1885},{"style":219},[1886],{"type":79,"value":832},{"type":73,"tag":206,"props":1888,"children":1889},{"style":213},[1890],{"type":79,"value":473},{"type":73,"tag":206,"props":1892,"children":1893},{"style":225},[1894],{"type":79,"value":478},{"type":73,"tag":206,"props":1896,"children":1897},{"style":219},[1898],{"type":79,"value":175},{"type":73,"tag":206,"props":1900,"children":1901},{"style":344},[1902],{"type":79,"value":487},{"type":73,"tag":206,"props":1904,"children":1905},{"style":373},[1906],{"type":79,"value":365},{"type":73,"tag":206,"props":1908,"children":1909},{"style":225},[1910],{"type":79,"value":1911},"topic",{"type":73,"tag":206,"props":1913,"children":1914},{"style":219},[1915],{"type":79,"value":399},{"type":73,"tag":206,"props":1917,"children":1918},{"style":219},[1919],{"type":79,"value":222},{"type":73,"tag":206,"props":1921,"children":1922},{"style":225},[1923],{"type":79,"value":1796},{"type":73,"tag":206,"props":1925,"children":1926},{"style":219},[1927],{"type":79,"value":233},{"type":73,"tag":206,"props":1929,"children":1930},{"style":373},[1931],{"type":79,"value":447},{"type":73,"tag":206,"props":1933,"children":1934},{"style":219},[1935],{"type":79,"value":259},{"type":73,"tag":206,"props":1937,"children":1938},{"class":208,"line":1123},[1939,1944,1948,1952,1956,1961,1965,1969],{"type":73,"tag":206,"props":1940,"children":1941},{"style":213},[1942],{"type":79,"value":1943},"    yield",{"type":73,"tag":206,"props":1945,"children":1946},{"style":219},[1947],{"type":79,"value":1772},{"type":73,"tag":206,"props":1949,"children":1950},{"style":225},[1951],{"type":79,"value":538},{"type":73,"tag":206,"props":1953,"children":1954},{"style":219},[1955],{"type":79,"value":175},{"type":73,"tag":206,"props":1957,"children":1958},{"style":344},[1959],{"type":79,"value":1960},"messages",{"type":73,"tag":206,"props":1962,"children":1963},{"style":373},[1964],{"type":79,"value":551},{"type":73,"tag":206,"props":1966,"children":1967},{"style":219},[1968],{"type":79,"value":1114},{"type":73,"tag":206,"props":1970,"children":1971},{"style":1117},[1972],{"type":79,"value":1973}," \u002F\u002F UIMessage snapshots become preliminary tool results\n",{"type":73,"tag":206,"props":1975,"children":1976},{"class":208,"line":1222},[1977,1982,1986,1990,1994,1998],{"type":73,"tag":206,"props":1978,"children":1979},{"style":213},[1980],{"type":79,"value":1981},"    await",{"type":73,"tag":206,"props":1983,"children":1984},{"style":225},[1985],{"type":79,"value":478},{"type":73,"tag":206,"props":1987,"children":1988},{"style":219},[1989],{"type":79,"value":175},{"type":73,"tag":206,"props":1991,"children":1992},{"style":344},[1993],{"type":79,"value":577},{"type":73,"tag":206,"props":1995,"children":1996},{"style":373},[1997],{"type":79,"value":551},{"type":73,"tag":206,"props":1999,"children":2000},{"style":219},[2001],{"type":79,"value":259},{"type":73,"tag":206,"props":2003,"children":2005},{"class":208,"line":2004},13,[2006],{"type":73,"tag":206,"props":2007,"children":2008},{"style":219},[2009],{"type":79,"value":2010},"  },\n",{"type":73,"tag":206,"props":2012,"children":2014},{"class":208,"line":2013},14,[2015,2020,2024,2028,2033,2037,2042,2046,2051],{"type":73,"tag":206,"props":2016,"children":2017},{"style":344},[2018],{"type":79,"value":2019},"  toModelOutput",{"type":73,"tag":206,"props":2021,"children":2022},{"style":219},[2023],{"type":79,"value":381},{"type":73,"tag":206,"props":2025,"children":2026},{"style":219},[2027],{"type":79,"value":1777},{"type":73,"tag":206,"props":2029,"children":2030},{"style":373},[2031],{"type":79,"value":2032}," output",{"type":73,"tag":206,"props":2034,"children":2035},{"style":219},[2036],{"type":79,"value":381},{"type":73,"tag":206,"props":2038,"children":2039},{"style":1780},[2040],{"type":79,"value":2041}," message",{"type":73,"tag":206,"props":2043,"children":2044},{"style":219},[2045],{"type":79,"value":1801},{"type":73,"tag":206,"props":2047,"children":2048},{"style":323},[2049],{"type":79,"value":2050}," =>",{"type":73,"tag":206,"props":2052,"children":2053},{"style":219},[2054],{"type":79,"value":1806},{"type":73,"tag":206,"props":2056,"children":2058},{"class":208,"line":2057},15,[2059,2063,2068,2072,2076,2081,2086,2090,2095,2099,2103,2107,2111,2115,2119,2123,2128,2132,2136,2141,2145,2150,2155,2159,2163,2167,2172],{"type":73,"tag":206,"props":2060,"children":2061},{"style":323},[2062],{"type":79,"value":1814},{"type":73,"tag":206,"props":2064,"children":2065},{"style":225},[2066],{"type":79,"value":2067}," lastText",{"type":73,"tag":206,"props":2069,"children":2070},{"style":219},[2071],{"type":79,"value":832},{"type":73,"tag":206,"props":2073,"children":2074},{"style":225},[2075],{"type":79,"value":2041},{"type":73,"tag":206,"props":2077,"children":2078},{"style":219},[2079],{"type":79,"value":2080},"?.",{"type":73,"tag":206,"props":2082,"children":2083},{"style":225},[2084],{"type":79,"value":2085},"parts",{"type":73,"tag":206,"props":2087,"children":2088},{"style":219},[2089],{"type":79,"value":2080},{"type":73,"tag":206,"props":2091,"children":2092},{"style":344},[2093],{"type":79,"value":2094},"findLast",{"type":73,"tag":206,"props":2096,"children":2097},{"style":373},[2098],{"type":79,"value":365},{"type":73,"tag":206,"props":2100,"children":2101},{"style":219},[2102],{"type":79,"value":365},{"type":73,"tag":206,"props":2104,"children":2105},{"style":1780},[2106],{"type":79,"value":82},{"type":73,"tag":206,"props":2108,"children":2109},{"style":219},[2110],{"type":79,"value":381},{"type":73,"tag":206,"props":2112,"children":2113},{"style":219},[2114],{"type":79,"value":222},{"type":73,"tag":206,"props":2116,"children":2117},{"style":373},[2118],{"type":79,"value":272},{"type":73,"tag":206,"props":2120,"children":2121},{"style":219},[2122],{"type":79,"value":381},{"type":73,"tag":206,"props":2124,"children":2125},{"style":1270},[2126],{"type":79,"value":2127}," string",{"type":73,"tag":206,"props":2129,"children":2130},{"style":219},[2131],{"type":79,"value":1801},{"type":73,"tag":206,"props":2133,"children":2134},{"style":323},[2135],{"type":79,"value":2050},{"type":73,"tag":206,"props":2137,"children":2138},{"style":225},[2139],{"type":79,"value":2140}," p",{"type":73,"tag":206,"props":2142,"children":2143},{"style":219},[2144],{"type":79,"value":175},{"type":73,"tag":206,"props":2146,"children":2147},{"style":225},[2148],{"type":79,"value":2149},"type",{"type":73,"tag":206,"props":2151,"children":2152},{"style":219},[2153],{"type":79,"value":2154}," ===",{"type":73,"tag":206,"props":2156,"children":2157},{"style":219},[2158],{"type":79,"value":243},{"type":73,"tag":206,"props":2160,"children":2161},{"style":246},[2162],{"type":79,"value":79},{"type":73,"tag":206,"props":2164,"children":2165},{"style":219},[2166],{"type":79,"value":254},{"type":73,"tag":206,"props":2168,"children":2169},{"style":373},[2170],{"type":79,"value":2171},") ",{"type":73,"tag":206,"props":2173,"children":2174},{"style":213},[2175],{"type":79,"value":2176},"as\n",{"type":73,"tag":206,"props":2178,"children":2180},{"class":208,"line":2179},16,[2181,2186,2190,2194,2199,2203],{"type":73,"tag":206,"props":2182,"children":2183},{"style":219},[2184],{"type":79,"value":2185},"      |",{"type":73,"tag":206,"props":2187,"children":2188},{"style":219},[2189],{"type":79,"value":222},{"type":73,"tag":206,"props":2191,"children":2192},{"style":225},[2193],{"type":79,"value":1190},{"type":73,"tag":206,"props":2195,"children":2196},{"style":219},[2197],{"type":79,"value":2198},"?:",{"type":73,"tag":206,"props":2200,"children":2201},{"style":225},[2202],{"type":79,"value":2127},{"type":73,"tag":206,"props":2204,"children":2205},{"style":219},[2206],{"type":79,"value":2207}," }\n",{"type":73,"tag":206,"props":2209,"children":2211},{"class":208,"line":2210},17,[2212,2216],{"type":73,"tag":206,"props":2213,"children":2214},{"style":219},[2215],{"type":79,"value":2185},{"type":73,"tag":206,"props":2217,"children":2218},{"style":219},[2219],{"type":79,"value":2220}," undefined;\n",{"type":73,"tag":206,"props":2222,"children":2224},{"class":208,"line":2223},18,[2225,2230,2234,2238,2242,2246,2250,2254,2258,2263,2267,2271,2275,2279,2284,2288,2293,2297],{"type":73,"tag":206,"props":2226,"children":2227},{"style":213},[2228],{"type":79,"value":2229},"    return",{"type":73,"tag":206,"props":2231,"children":2232},{"style":219},[2233],{"type":79,"value":222},{"type":73,"tag":206,"props":2235,"children":2236},{"style":373},[2237],{"type":79,"value":272},{"type":73,"tag":206,"props":2239,"children":2240},{"style":219},[2241],{"type":79,"value":381},{"type":73,"tag":206,"props":2243,"children":2244},{"style":219},[2245],{"type":79,"value":243},{"type":73,"tag":206,"props":2247,"children":2248},{"style":246},[2249],{"type":79,"value":79},{"type":73,"tag":206,"props":2251,"children":2252},{"style":219},[2253],{"type":79,"value":254},{"type":73,"tag":206,"props":2255,"children":2256},{"style":219},[2257],{"type":79,"value":399},{"type":73,"tag":206,"props":2259,"children":2260},{"style":373},[2261],{"type":79,"value":2262}," value",{"type":73,"tag":206,"props":2264,"children":2265},{"style":219},[2266],{"type":79,"value":381},{"type":73,"tag":206,"props":2268,"children":2269},{"style":225},[2270],{"type":79,"value":2067},{"type":73,"tag":206,"props":2272,"children":2273},{"style":219},[2274],{"type":79,"value":2080},{"type":73,"tag":206,"props":2276,"children":2277},{"style":225},[2278],{"type":79,"value":79},{"type":73,"tag":206,"props":2280,"children":2281},{"style":219},[2282],{"type":79,"value":2283}," ??",{"type":73,"tag":206,"props":2285,"children":2286},{"style":219},[2287],{"type":79,"value":243},{"type":73,"tag":206,"props":2289,"children":2290},{"style":246},[2291],{"type":79,"value":2292},"Done.",{"type":73,"tag":206,"props":2294,"children":2295},{"style":219},[2296],{"type":79,"value":254},{"type":73,"tag":206,"props":2298,"children":2299},{"style":219},[2300],{"type":79,"value":2301}," };\n",{"type":73,"tag":206,"props":2303,"children":2305},{"class":208,"line":2304},19,[2306],{"type":73,"tag":206,"props":2307,"children":2308},{"style":219},[2309],{"type":79,"value":2010},{"type":73,"tag":206,"props":2311,"children":2313},{"class":208,"line":2312},20,[2314,2318,2322],{"type":73,"tag":206,"props":2315,"children":2316},{"style":219},[2317],{"type":79,"value":827},{"type":73,"tag":206,"props":2319,"children":2320},{"style":225},[2321],{"type":79,"value":447},{"type":73,"tag":206,"props":2323,"children":2324},{"style":219},[2325],{"type":79,"value":259},{"type":73,"tag":82,"props":2327,"children":2328},{},[2329,2331,2337,2339,2345,2346,2352,2354,2360,2362,2368,2370,2376,2378,2384],{"type":79,"value":2330},"For a subtask exposed via ",{"type":73,"tag":86,"props":2332,"children":2334},{"className":2333},[],[2335],{"type":79,"value":2336},"execute: ai.toolExecute(task)",{"type":79,"value":2338},", stream progress to the agent's run with\n",{"type":73,"tag":86,"props":2340,"children":2342},{"className":2341},[],[2343],{"type":79,"value":2344},"chat.stream.writer({ target: \"root\" })",{"type":79,"value":1368},{"type":73,"tag":86,"props":2347,"children":2349},{"className":2348},[],[2350],{"type":79,"value":2351},"target",{"type":79,"value":2353}," accepts ",{"type":73,"tag":86,"props":2355,"children":2357},{"className":2356},[],[2358],{"type":79,"value":2359},"\"self\" | \"parent\" | \"root\" | \u003CrunId>",{"type":79,"value":2361},".\nInside the subtask, read context with ",{"type":73,"tag":86,"props":2363,"children":2365},{"className":2364},[],[2366],{"type":79,"value":2367},"ai.toolCallId()",{"type":79,"value":2369}," and ",{"type":73,"tag":86,"props":2371,"children":2373},{"className":2372},[],[2374],{"type":79,"value":2375},"ai.chatContextOrThrow\u003Ctypeof myChat>()",{"type":79,"value":2377},"\n(",{"type":73,"tag":86,"props":2379,"children":2381},{"className":2380},[],[2382],{"type":79,"value":2383},"{ chatId, turn, continuation, clientData }",{"type":79,"value":2385},").",{"type":73,"tag":195,"props":2387,"children":2389},{"className":197,"code":2388,"language":199,"meta":200,"style":200},"import { chat, ai } from \"@trigger.dev\u002Fsdk\u002Fai\";\n\nconst { waitUntilComplete } = chat.stream.writer({\n  target: \"root\",\n  execute: ({ write }) =>\n    write({ type: \"data-research-status\", id: partId, data: { query, status: \"in-progress\" } }),\n});\nawait waitUntilComplete();\n",[2390],{"type":73,"tag":86,"props":2391,"children":2392},{"__ignoreMap":200},[2393,2441,2448,2501,2529,2558,2676,2691],{"type":73,"tag":206,"props":2394,"children":2395},{"class":208,"line":209},[2396,2400,2404,2408,2412,2417,2421,2425,2429,2433,2437],{"type":73,"tag":206,"props":2397,"children":2398},{"style":213},[2399],{"type":79,"value":216},{"type":73,"tag":206,"props":2401,"children":2402},{"style":219},[2403],{"type":79,"value":222},{"type":73,"tag":206,"props":2405,"children":2406},{"style":225},[2407],{"type":79,"value":478},{"type":73,"tag":206,"props":2409,"children":2410},{"style":219},[2411],{"type":79,"value":399},{"type":73,"tag":206,"props":2413,"children":2414},{"style":225},[2415],{"type":79,"value":2416}," ai",{"type":73,"tag":206,"props":2418,"children":2419},{"style":219},[2420],{"type":79,"value":233},{"type":73,"tag":206,"props":2422,"children":2423},{"style":213},[2424],{"type":79,"value":238},{"type":73,"tag":206,"props":2426,"children":2427},{"style":219},[2428],{"type":79,"value":243},{"type":73,"tag":206,"props":2430,"children":2431},{"style":246},[2432],{"type":79,"value":159},{"type":73,"tag":206,"props":2434,"children":2435},{"style":219},[2436],{"type":79,"value":254},{"type":73,"tag":206,"props":2438,"children":2439},{"style":219},[2440],{"type":79,"value":259},{"type":73,"tag":206,"props":2442,"children":2443},{"class":208,"line":262},[2444],{"type":73,"tag":206,"props":2445,"children":2446},{"emptyLinePlaceholder":313},[2447],{"type":79,"value":316},{"type":73,"tag":206,"props":2449,"children":2450},{"class":208,"line":309},[2451,2455,2459,2464,2468,2472,2476,2480,2485,2489,2493,2497],{"type":73,"tag":206,"props":2452,"children":2453},{"style":323},[2454],{"type":79,"value":326},{"type":73,"tag":206,"props":2456,"children":2457},{"style":219},[2458],{"type":79,"value":222},{"type":73,"tag":206,"props":2460,"children":2461},{"style":225},[2462],{"type":79,"value":2463}," waitUntilComplete ",{"type":73,"tag":206,"props":2465,"children":2466},{"style":219},[2467],{"type":79,"value":827},{"type":73,"tag":206,"props":2469,"children":2470},{"style":219},[2471],{"type":79,"value":832},{"type":73,"tag":206,"props":2473,"children":2474},{"style":225},[2475],{"type":79,"value":478},{"type":73,"tag":206,"props":2477,"children":2478},{"style":219},[2479],{"type":79,"value":175},{"type":73,"tag":206,"props":2481,"children":2482},{"style":225},[2483],{"type":79,"value":2484},"stream",{"type":73,"tag":206,"props":2486,"children":2487},{"style":219},[2488],{"type":79,"value":175},{"type":73,"tag":206,"props":2490,"children":2491},{"style":344},[2492],{"type":79,"value":1395},{"type":73,"tag":206,"props":2494,"children":2495},{"style":225},[2496],{"type":79,"value":365},{"type":73,"tag":206,"props":2498,"children":2499},{"style":219},[2500],{"type":79,"value":858},{"type":73,"tag":206,"props":2502,"children":2503},{"class":208,"line":319},[2504,2509,2513,2517,2521,2525],{"type":73,"tag":206,"props":2505,"children":2506},{"style":373},[2507],{"type":79,"value":2508},"  target",{"type":73,"tag":206,"props":2510,"children":2511},{"style":219},[2512],{"type":79,"value":381},{"type":73,"tag":206,"props":2514,"children":2515},{"style":219},[2516],{"type":79,"value":243},{"type":73,"tag":206,"props":2518,"children":2519},{"style":246},[2520],{"type":79,"value":70},{"type":73,"tag":206,"props":2522,"children":2523},{"style":219},[2524],{"type":79,"value":254},{"type":73,"tag":206,"props":2526,"children":2527},{"style":219},[2528],{"type":79,"value":666},{"type":73,"tag":206,"props":2530,"children":2531},{"class":208,"line":454},[2532,2536,2540,2544,2549,2553],{"type":73,"tag":206,"props":2533,"children":2534},{"style":344},[2535],{"type":79,"value":1753},{"type":73,"tag":206,"props":2537,"children":2538},{"style":219},[2539],{"type":79,"value":381},{"type":73,"tag":206,"props":2541,"children":2542},{"style":219},[2543],{"type":79,"value":1777},{"type":73,"tag":206,"props":2545,"children":2546},{"style":1780},[2547],{"type":79,"value":2548}," write",{"type":73,"tag":206,"props":2550,"children":2551},{"style":219},[2552],{"type":79,"value":1801},{"type":73,"tag":206,"props":2554,"children":2555},{"style":323},[2556],{"type":79,"value":2557}," =>\n",{"type":73,"tag":206,"props":2559,"children":2560},{"class":208,"line":515},[2561,2566,2570,2574,2578,2582,2586,2591,2595,2599,2603,2607,2612,2616,2621,2625,2629,2634,2638,2643,2647,2651,2656,2660,2664,2668,2672],{"type":73,"tag":206,"props":2562,"children":2563},{"style":344},[2564],{"type":79,"value":2565},"    write",{"type":73,"tag":206,"props":2567,"children":2568},{"style":225},[2569],{"type":79,"value":365},{"type":73,"tag":206,"props":2571,"children":2572},{"style":219},[2573],{"type":79,"value":370},{"type":73,"tag":206,"props":2575,"children":2576},{"style":373},[2577],{"type":79,"value":272},{"type":73,"tag":206,"props":2579,"children":2580},{"style":219},[2581],{"type":79,"value":381},{"type":73,"tag":206,"props":2583,"children":2584},{"style":219},[2585],{"type":79,"value":243},{"type":73,"tag":206,"props":2587,"children":2588},{"style":246},[2589],{"type":79,"value":2590},"data-research-status",{"type":73,"tag":206,"props":2592,"children":2593},{"style":219},[2594],{"type":79,"value":254},{"type":73,"tag":206,"props":2596,"children":2597},{"style":219},[2598],{"type":79,"value":399},{"type":73,"tag":206,"props":2600,"children":2601},{"style":373},[2602],{"type":79,"value":813},{"type":73,"tag":206,"props":2604,"children":2605},{"style":219},[2606],{"type":79,"value":381},{"type":73,"tag":206,"props":2608,"children":2609},{"style":225},[2610],{"type":79,"value":2611}," partId",{"type":73,"tag":206,"props":2613,"children":2614},{"style":219},[2615],{"type":79,"value":399},{"type":73,"tag":206,"props":2617,"children":2618},{"style":373},[2619],{"type":79,"value":2620}," data",{"type":73,"tag":206,"props":2622,"children":2623},{"style":219},[2624],{"type":79,"value":381},{"type":73,"tag":206,"props":2626,"children":2627},{"style":219},[2628],{"type":79,"value":222},{"type":73,"tag":206,"props":2630,"children":2631},{"style":225},[2632],{"type":79,"value":2633}," query",{"type":73,"tag":206,"props":2635,"children":2636},{"style":219},[2637],{"type":79,"value":399},{"type":73,"tag":206,"props":2639,"children":2640},{"style":373},[2641],{"type":79,"value":2642}," status",{"type":73,"tag":206,"props":2644,"children":2645},{"style":219},[2646],{"type":79,"value":381},{"type":73,"tag":206,"props":2648,"children":2649},{"style":219},[2650],{"type":79,"value":243},{"type":73,"tag":206,"props":2652,"children":2653},{"style":246},[2654],{"type":79,"value":2655},"in-progress",{"type":73,"tag":206,"props":2657,"children":2658},{"style":219},[2659],{"type":79,"value":254},{"type":73,"tag":206,"props":2661,"children":2662},{"style":219},[2663],{"type":79,"value":233},{"type":73,"tag":206,"props":2665,"children":2666},{"style":219},[2667],{"type":79,"value":233},{"type":73,"tag":206,"props":2669,"children":2670},{"style":225},[2671],{"type":79,"value":447},{"type":73,"tag":206,"props":2673,"children":2674},{"style":219},[2675],{"type":79,"value":666},{"type":73,"tag":206,"props":2677,"children":2678},{"class":208,"line":558},[2679,2683,2687],{"type":73,"tag":206,"props":2680,"children":2681},{"style":219},[2682],{"type":79,"value":827},{"type":73,"tag":206,"props":2684,"children":2685},{"style":225},[2686],{"type":79,"value":447},{"type":73,"tag":206,"props":2688,"children":2689},{"style":219},[2690],{"type":79,"value":259},{"type":73,"tag":206,"props":2692,"children":2693},{"class":208,"line":1053},[2694,2698,2703,2707],{"type":73,"tag":206,"props":2695,"children":2696},{"style":213},[2697],{"type":79,"value":564},{"type":73,"tag":206,"props":2699,"children":2700},{"style":344},[2701],{"type":79,"value":2702}," waitUntilComplete",{"type":73,"tag":206,"props":2704,"children":2705},{"style":225},[2706],{"type":79,"value":551},{"type":73,"tag":206,"props":2708,"children":2709},{"style":219},[2710],{"type":79,"value":259},{"type":73,"tag":695,"props":2712,"children":2714},{"id":2713},"_3-background-injection-defer-inject",[2715],{"type":79,"value":2716},"3. Background injection: defer + inject",{"type":73,"tag":82,"props":2718,"children":2719},{},[2720,2726,2728,2734,2736,2742,2744,2750,2752,2758],{"type":73,"tag":86,"props":2721,"children":2723},{"className":2722},[],[2724],{"type":79,"value":2725},"chat.defer(promise)",{"type":79,"value":2727}," runs work in parallel with streaming (all deferred promises are awaited, with a\n5s timeout, before ",{"type":73,"tag":86,"props":2729,"children":2731},{"className":2730},[],[2732],{"type":79,"value":2733},"onTurnComplete",{"type":79,"value":2735},"). ",{"type":73,"tag":86,"props":2737,"children":2739},{"className":2738},[],[2740],{"type":79,"value":2741},"chat.inject(messages)",{"type":79,"value":2743}," queues ",{"type":73,"tag":86,"props":2745,"children":2747},{"className":2746},[],[2748],{"type":79,"value":2749},"ModelMessage[]",{"type":79,"value":2751}," that drain at\nthe next turn start or ",{"type":73,"tag":86,"props":2753,"children":2755},{"className":2754},[],[2756],{"type":79,"value":2757},"prepareStep",{"type":79,"value":2759}," boundary.",{"type":73,"tag":195,"props":2761,"children":2763},{"className":197,"code":2762,"language":199,"meta":200,"style":200},"export const myChat = chat.agent({\n  id: \"my-chat\",\n  onTurnComplete: async ({ messages }) => {\n    chat.defer(\n      (async () => {\n        const analysis = await analyzeConversation(messages);\n        chat.inject([{ role: \"system\", content: `[Analysis]\\n\\n${analysis}` }]);\n      })()\n    );\n  },\n  run: async ({ messages, signal }) =>\n    streamText({ ...chat.toStreamTextOptions({ registry }), messages, abortSignal: signal, stopWhen: stepCountIs(15) }),\n});\n",[2764],{"type":73,"tag":86,"props":2765,"children":2766},{"__ignoreMap":200},[2767,2810,2838,2875,2897,2923,2965,3067,3080,3092,3099,3140,3262],{"type":73,"tag":206,"props":2768,"children":2769},{"class":208,"line":209},[2770,2775,2780,2785,2789,2793,2797,2802,2806],{"type":73,"tag":206,"props":2771,"children":2772},{"style":213},[2773],{"type":79,"value":2774},"export",{"type":73,"tag":206,"props":2776,"children":2777},{"style":323},[2778],{"type":79,"value":2779}," const",{"type":73,"tag":206,"props":2781,"children":2782},{"style":225},[2783],{"type":79,"value":2784}," myChat ",{"type":73,"tag":206,"props":2786,"children":2787},{"style":219},[2788],{"type":79,"value":336},{"type":73,"tag":206,"props":2790,"children":2791},{"style":225},[2792],{"type":79,"value":478},{"type":73,"tag":206,"props":2794,"children":2795},{"style":219},[2796],{"type":79,"value":175},{"type":73,"tag":206,"props":2798,"children":2799},{"style":344},[2800],{"type":79,"value":2801},"agent",{"type":73,"tag":206,"props":2803,"children":2804},{"style":225},[2805],{"type":79,"value":365},{"type":73,"tag":206,"props":2807,"children":2808},{"style":219},[2809],{"type":79,"value":858},{"type":73,"tag":206,"props":2811,"children":2812},{"class":208,"line":262},[2813,2818,2822,2826,2830,2834],{"type":73,"tag":206,"props":2814,"children":2815},{"style":373},[2816],{"type":79,"value":2817},"  id",{"type":73,"tag":206,"props":2819,"children":2820},{"style":219},[2821],{"type":79,"value":381},{"type":73,"tag":206,"props":2823,"children":2824},{"style":219},[2825],{"type":79,"value":243},{"type":73,"tag":206,"props":2827,"children":2828},{"style":246},[2829],{"type":79,"value":390},{"type":73,"tag":206,"props":2831,"children":2832},{"style":219},[2833],{"type":79,"value":254},{"type":73,"tag":206,"props":2835,"children":2836},{"style":219},[2837],{"type":79,"value":666},{"type":73,"tag":206,"props":2839,"children":2840},{"class":208,"line":309},[2841,2846,2850,2854,2858,2863,2867,2871],{"type":73,"tag":206,"props":2842,"children":2843},{"style":344},[2844],{"type":79,"value":2845},"  onTurnComplete",{"type":73,"tag":206,"props":2847,"children":2848},{"style":219},[2849],{"type":79,"value":381},{"type":73,"tag":206,"props":2851,"children":2852},{"style":323},[2853],{"type":79,"value":1762},{"type":73,"tag":206,"props":2855,"children":2856},{"style":219},[2857],{"type":79,"value":1777},{"type":73,"tag":206,"props":2859,"children":2860},{"style":1780},[2861],{"type":79,"value":2862}," messages",{"type":73,"tag":206,"props":2864,"children":2865},{"style":219},[2866],{"type":79,"value":1801},{"type":73,"tag":206,"props":2868,"children":2869},{"style":323},[2870],{"type":79,"value":2050},{"type":73,"tag":206,"props":2872,"children":2873},{"style":219},[2874],{"type":79,"value":1806},{"type":73,"tag":206,"props":2876,"children":2877},{"class":208,"line":319},[2878,2883,2887,2892],{"type":73,"tag":206,"props":2879,"children":2880},{"style":225},[2881],{"type":79,"value":2882},"    chat",{"type":73,"tag":206,"props":2884,"children":2885},{"style":219},[2886],{"type":79,"value":175},{"type":73,"tag":206,"props":2888,"children":2889},{"style":344},[2890],{"type":79,"value":2891},"defer",{"type":73,"tag":206,"props":2893,"children":2894},{"style":373},[2895],{"type":79,"value":2896},"(\n",{"type":73,"tag":206,"props":2898,"children":2899},{"class":208,"line":454},[2900,2905,2910,2915,2919],{"type":73,"tag":206,"props":2901,"children":2902},{"style":373},[2903],{"type":79,"value":2904},"      (",{"type":73,"tag":206,"props":2906,"children":2907},{"style":323},[2908],{"type":79,"value":2909},"async",{"type":73,"tag":206,"props":2911,"children":2912},{"style":219},[2913],{"type":79,"value":2914}," ()",{"type":73,"tag":206,"props":2916,"children":2917},{"style":323},[2918],{"type":79,"value":2050},{"type":73,"tag":206,"props":2920,"children":2921},{"style":219},[2922],{"type":79,"value":1806},{"type":73,"tag":206,"props":2924,"children":2925},{"class":208,"line":515},[2926,2931,2936,2940,2944,2949,2953,2957,2961],{"type":73,"tag":206,"props":2927,"children":2928},{"style":323},[2929],{"type":79,"value":2930},"        const",{"type":73,"tag":206,"props":2932,"children":2933},{"style":225},[2934],{"type":79,"value":2935}," analysis",{"type":73,"tag":206,"props":2937,"children":2938},{"style":219},[2939],{"type":79,"value":832},{"type":73,"tag":206,"props":2941,"children":2942},{"style":213},[2943],{"type":79,"value":473},{"type":73,"tag":206,"props":2945,"children":2946},{"style":344},[2947],{"type":79,"value":2948}," analyzeConversation",{"type":73,"tag":206,"props":2950,"children":2951},{"style":373},[2952],{"type":79,"value":365},{"type":73,"tag":206,"props":2954,"children":2955},{"style":225},[2956],{"type":79,"value":1960},{"type":73,"tag":206,"props":2958,"children":2959},{"style":373},[2960],{"type":79,"value":447},{"type":73,"tag":206,"props":2962,"children":2963},{"style":219},[2964],{"type":79,"value":259},{"type":73,"tag":206,"props":2966,"children":2967},{"class":208,"line":558},[2968,2973,2977,2982,2987,2991,2996,3000,3004,3009,3013,3017,3022,3026,3031,3036,3041,3045,3050,3054,3058,3063],{"type":73,"tag":206,"props":2969,"children":2970},{"style":225},[2971],{"type":79,"value":2972},"        chat",{"type":73,"tag":206,"props":2974,"children":2975},{"style":219},[2976],{"type":79,"value":175},{"type":73,"tag":206,"props":2978,"children":2979},{"style":344},[2980],{"type":79,"value":2981},"inject",{"type":73,"tag":206,"props":2983,"children":2984},{"style":373},[2985],{"type":79,"value":2986},"([",{"type":73,"tag":206,"props":2988,"children":2989},{"style":219},[2990],{"type":79,"value":370},{"type":73,"tag":206,"props":2992,"children":2993},{"style":373},[2994],{"type":79,"value":2995}," role",{"type":73,"tag":206,"props":2997,"children":2998},{"style":219},[2999],{"type":79,"value":381},{"type":73,"tag":206,"props":3001,"children":3002},{"style":219},[3003],{"type":79,"value":243},{"type":73,"tag":206,"props":3005,"children":3006},{"style":246},[3007],{"type":79,"value":3008},"system",{"type":73,"tag":206,"props":3010,"children":3011},{"style":219},[3012],{"type":79,"value":254},{"type":73,"tag":206,"props":3014,"children":3015},{"style":219},[3016],{"type":79,"value":399},{"type":73,"tag":206,"props":3018,"children":3019},{"style":373},[3020],{"type":79,"value":3021}," content",{"type":73,"tag":206,"props":3023,"children":3024},{"style":219},[3025],{"type":79,"value":381},{"type":73,"tag":206,"props":3027,"children":3028},{"style":219},[3029],{"type":79,"value":3030}," `",{"type":73,"tag":206,"props":3032,"children":3033},{"style":246},[3034],{"type":79,"value":3035},"[Analysis]",{"type":73,"tag":206,"props":3037,"children":3038},{"style":225},[3039],{"type":79,"value":3040},"\\n\\n",{"type":73,"tag":206,"props":3042,"children":3043},{"style":219},[3044],{"type":79,"value":980},{"type":73,"tag":206,"props":3046,"children":3047},{"style":225},[3048],{"type":79,"value":3049},"analysis",{"type":73,"tag":206,"props":3051,"children":3052},{"style":219},[3053],{"type":79,"value":989},{"type":73,"tag":206,"props":3055,"children":3056},{"style":219},[3057],{"type":79,"value":233},{"type":73,"tag":206,"props":3059,"children":3060},{"style":373},[3061],{"type":79,"value":3062},"])",{"type":73,"tag":206,"props":3064,"children":3065},{"style":219},[3066],{"type":79,"value":259},{"type":73,"tag":206,"props":3068,"children":3069},{"class":208,"line":1053},[3070,3075],{"type":73,"tag":206,"props":3071,"children":3072},{"style":219},[3073],{"type":79,"value":3074},"      }",{"type":73,"tag":206,"props":3076,"children":3077},{"style":373},[3078],{"type":79,"value":3079},")()\n",{"type":73,"tag":206,"props":3081,"children":3082},{"class":208,"line":1069},[3083,3088],{"type":73,"tag":206,"props":3084,"children":3085},{"style":373},[3086],{"type":79,"value":3087},"    )",{"type":73,"tag":206,"props":3089,"children":3090},{"style":219},[3091],{"type":79,"value":259},{"type":73,"tag":206,"props":3093,"children":3094},{"class":208,"line":1077},[3095],{"type":73,"tag":206,"props":3096,"children":3097},{"style":219},[3098],{"type":79,"value":2010},{"type":73,"tag":206,"props":3100,"children":3101},{"class":208,"line":1123},[3102,3107,3111,3115,3119,3123,3127,3132,3136],{"type":73,"tag":206,"props":3103,"children":3104},{"style":344},[3105],{"type":79,"value":3106},"  run",{"type":73,"tag":206,"props":3108,"children":3109},{"style":219},[3110],{"type":79,"value":381},{"type":73,"tag":206,"props":3112,"children":3113},{"style":323},[3114],{"type":79,"value":1762},{"type":73,"tag":206,"props":3116,"children":3117},{"style":219},[3118],{"type":79,"value":1777},{"type":73,"tag":206,"props":3120,"children":3121},{"style":1780},[3122],{"type":79,"value":2862},{"type":73,"tag":206,"props":3124,"children":3125},{"style":219},[3126],{"type":79,"value":399},{"type":73,"tag":206,"props":3128,"children":3129},{"style":1780},[3130],{"type":79,"value":3131}," signal",{"type":73,"tag":206,"props":3133,"children":3134},{"style":219},[3135],{"type":79,"value":1801},{"type":73,"tag":206,"props":3137,"children":3138},{"style":323},[3139],{"type":79,"value":2557},{"type":73,"tag":206,"props":3141,"children":3142},{"class":208,"line":1222},[3143,3148,3152,3156,3161,3165,3169,3174,3178,3182,3187,3191,3195,3199,3203,3207,3211,3215,3219,3223,3228,3232,3237,3241,3246,3250,3254,3258],{"type":73,"tag":206,"props":3144,"children":3145},{"style":344},[3146],{"type":79,"value":3147},"    streamText",{"type":73,"tag":206,"props":3149,"children":3150},{"style":225},[3151],{"type":79,"value":365},{"type":73,"tag":206,"props":3153,"children":3154},{"style":219},[3155],{"type":79,"value":370},{"type":73,"tag":206,"props":3157,"children":3158},{"style":219},[3159],{"type":79,"value":3160}," ...",{"type":73,"tag":206,"props":3162,"children":3163},{"style":225},[3164],{"type":79,"value":144},{"type":73,"tag":206,"props":3166,"children":3167},{"style":219},[3168],{"type":79,"value":175},{"type":73,"tag":206,"props":3170,"children":3171},{"style":344},[3172],{"type":79,"value":3173},"toStreamTextOptions",{"type":73,"tag":206,"props":3175,"children":3176},{"style":225},[3177],{"type":79,"value":365},{"type":73,"tag":206,"props":3179,"children":3180},{"style":219},[3181],{"type":79,"value":370},{"type":73,"tag":206,"props":3183,"children":3184},{"style":225},[3185],{"type":79,"value":3186}," registry ",{"type":73,"tag":206,"props":3188,"children":3189},{"style":219},[3190],{"type":79,"value":827},{"type":73,"tag":206,"props":3192,"children":3193},{"style":225},[3194],{"type":79,"value":447},{"type":73,"tag":206,"props":3196,"children":3197},{"style":219},[3198],{"type":79,"value":399},{"type":73,"tag":206,"props":3200,"children":3201},{"style":225},[3202],{"type":79,"value":2862},{"type":73,"tag":206,"props":3204,"children":3205},{"style":219},[3206],{"type":79,"value":399},{"type":73,"tag":206,"props":3208,"children":3209},{"style":373},[3210],{"type":79,"value":1796},{"type":73,"tag":206,"props":3212,"children":3213},{"style":219},[3214],{"type":79,"value":381},{"type":73,"tag":206,"props":3216,"children":3217},{"style":225},[3218],{"type":79,"value":3131},{"type":73,"tag":206,"props":3220,"children":3221},{"style":219},[3222],{"type":79,"value":399},{"type":73,"tag":206,"props":3224,"children":3225},{"style":373},[3226],{"type":79,"value":3227}," stopWhen",{"type":73,"tag":206,"props":3229,"children":3230},{"style":219},[3231],{"type":79,"value":381},{"type":73,"tag":206,"props":3233,"children":3234},{"style":344},[3235],{"type":79,"value":3236}," stepCountIs",{"type":73,"tag":206,"props":3238,"children":3239},{"style":225},[3240],{"type":79,"value":365},{"type":73,"tag":206,"props":3242,"children":3243},{"style":1297},[3244],{"type":79,"value":3245},"15",{"type":73,"tag":206,"props":3247,"children":3248},{"style":225},[3249],{"type":79,"value":2171},{"type":73,"tag":206,"props":3251,"children":3252},{"style":219},[3253],{"type":79,"value":827},{"type":73,"tag":206,"props":3255,"children":3256},{"style":225},[3257],{"type":79,"value":447},{"type":73,"tag":206,"props":3259,"children":3260},{"style":219},[3261],{"type":79,"value":666},{"type":73,"tag":206,"props":3263,"children":3264},{"class":208,"line":2004},[3265,3269,3273],{"type":73,"tag":206,"props":3266,"children":3267},{"style":219},[3268],{"type":79,"value":827},{"type":73,"tag":206,"props":3270,"children":3271},{"style":225},[3272],{"type":79,"value":447},{"type":73,"tag":206,"props":3274,"children":3275},{"style":219},[3276],{"type":79,"value":259},{"type":73,"tag":695,"props":3278,"children":3280},{"id":3279},"_4-compaction-threshold-based",[3281],{"type":79,"value":3282},"4. Compaction (threshold-based)",{"type":73,"tag":82,"props":3284,"children":3285},{},[3286,3292,3294,3300,3302,3308,3310,3315,3317,3323,3325,3330],{"type":73,"tag":86,"props":3287,"children":3289},{"className":3288},[],[3290],{"type":79,"value":3291},"compaction.shouldCompact",{"type":79,"value":3293}," decides when, ",{"type":73,"tag":86,"props":3295,"children":3297},{"className":3296},[],[3298],{"type":79,"value":3299},"summarize",{"type":79,"value":3301}," produces the summary that replaces the model\nmessages. UI messages are preserved by default (customize via ",{"type":73,"tag":86,"props":3303,"children":3305},{"className":3304},[],[3306],{"type":79,"value":3307},"compactUIMessages",{"type":79,"value":3309},"). The ",{"type":73,"tag":86,"props":3311,"children":3313},{"className":3312},[],[3314],{"type":79,"value":2757},{"type":79,"value":3316},"\nthat performs inner-loop compaction is auto-injected by ",{"type":73,"tag":86,"props":3318,"children":3320},{"className":3319},[],[3321],{"type":79,"value":3322},"chat.toStreamTextOptions()",{"type":79,"value":3324},"; a ",{"type":73,"tag":86,"props":3326,"children":3328},{"className":3327},[],[3329],{"type":79,"value":2757},{"type":79,"value":3331},"\nyou pass after the spread wins.",{"type":73,"tag":195,"props":3333,"children":3335},{"className":197,"code":3334,"language":199,"meta":200,"style":200},"compaction: {\n  shouldCompact: ({ totalTokens }) => (totalTokens ?? 0) > 80_000,\n  summarize: async ({ messages }) =>\n    (await generateText({\n      model: anthropic(\"claude-haiku-4-5\"),\n      messages: [...messages, { role: \"user\", content: \"Summarize concisely.\" }],\n    })).text,\n},\n",[3336],{"type":73,"tag":86,"props":3337,"children":3338},{"__ignoreMap":200},[3339,3355,3419,3451,3476,3518,3609,3634],{"type":73,"tag":206,"props":3340,"children":3341},{"class":208,"line":209},[3342,3347,3351],{"type":73,"tag":206,"props":3343,"children":3344},{"style":1270},[3345],{"type":79,"value":3346},"compaction",{"type":73,"tag":206,"props":3348,"children":3349},{"style":219},[3350],{"type":79,"value":381},{"type":73,"tag":206,"props":3352,"children":3353},{"style":219},[3354],{"type":79,"value":1806},{"type":73,"tag":206,"props":3356,"children":3357},{"class":208,"line":262},[3358,3363,3367,3371,3376,3380,3384,3388,3393,3397,3402,3406,3410,3415],{"type":73,"tag":206,"props":3359,"children":3360},{"style":1270},[3361],{"type":79,"value":3362},"  shouldCompact",{"type":73,"tag":206,"props":3364,"children":3365},{"style":219},[3366],{"type":79,"value":381},{"type":73,"tag":206,"props":3368,"children":3369},{"style":219},[3370],{"type":79,"value":1777},{"type":73,"tag":206,"props":3372,"children":3373},{"style":1780},[3374],{"type":79,"value":3375}," totalTokens",{"type":73,"tag":206,"props":3377,"children":3378},{"style":219},[3379],{"type":79,"value":1801},{"type":73,"tag":206,"props":3381,"children":3382},{"style":323},[3383],{"type":79,"value":2050},{"type":73,"tag":206,"props":3385,"children":3386},{"style":373},[3387],{"type":79,"value":620},{"type":73,"tag":206,"props":3389,"children":3390},{"style":225},[3391],{"type":79,"value":3392},"totalTokens",{"type":73,"tag":206,"props":3394,"children":3395},{"style":219},[3396],{"type":79,"value":2283},{"type":73,"tag":206,"props":3398,"children":3399},{"style":1297},[3400],{"type":79,"value":3401}," 0",{"type":73,"tag":206,"props":3403,"children":3404},{"style":373},[3405],{"type":79,"value":2171},{"type":73,"tag":206,"props":3407,"children":3408},{"style":219},[3409],{"type":79,"value":360},{"type":73,"tag":206,"props":3411,"children":3412},{"style":1297},[3413],{"type":79,"value":3414}," 80_000",{"type":73,"tag":206,"props":3416,"children":3417},{"style":219},[3418],{"type":79,"value":666},{"type":73,"tag":206,"props":3420,"children":3421},{"class":208,"line":309},[3422,3427,3431,3435,3439,3443,3447],{"type":73,"tag":206,"props":3423,"children":3424},{"style":1270},[3425],{"type":79,"value":3426},"  summarize",{"type":73,"tag":206,"props":3428,"children":3429},{"style":219},[3430],{"type":79,"value":381},{"type":73,"tag":206,"props":3432,"children":3433},{"style":323},[3434],{"type":79,"value":1762},{"type":73,"tag":206,"props":3436,"children":3437},{"style":219},[3438],{"type":79,"value":1777},{"type":73,"tag":206,"props":3440,"children":3441},{"style":1780},[3442],{"type":79,"value":2862},{"type":73,"tag":206,"props":3444,"children":3445},{"style":219},[3446],{"type":79,"value":1801},{"type":73,"tag":206,"props":3448,"children":3449},{"style":323},[3450],{"type":79,"value":2557},{"type":73,"tag":206,"props":3452,"children":3453},{"class":208,"line":319},[3454,3459,3463,3468,3472],{"type":73,"tag":206,"props":3455,"children":3456},{"style":373},[3457],{"type":79,"value":3458},"    (",{"type":73,"tag":206,"props":3460,"children":3461},{"style":213},[3462],{"type":79,"value":564},{"type":73,"tag":206,"props":3464,"children":3465},{"style":344},[3466],{"type":79,"value":3467}," generateText",{"type":73,"tag":206,"props":3469,"children":3470},{"style":373},[3471],{"type":79,"value":365},{"type":73,"tag":206,"props":3473,"children":3474},{"style":219},[3475],{"type":79,"value":858},{"type":73,"tag":206,"props":3477,"children":3478},{"class":208,"line":454},[3479,3484,3488,3493,3497,3501,3506,3510,3514],{"type":73,"tag":206,"props":3480,"children":3481},{"style":373},[3482],{"type":79,"value":3483},"      model",{"type":73,"tag":206,"props":3485,"children":3486},{"style":219},[3487],{"type":79,"value":381},{"type":73,"tag":206,"props":3489,"children":3490},{"style":344},[3491],{"type":79,"value":3492}," anthropic",{"type":73,"tag":206,"props":3494,"children":3495},{"style":373},[3496],{"type":79,"value":365},{"type":73,"tag":206,"props":3498,"children":3499},{"style":219},[3500],{"type":79,"value":254},{"type":73,"tag":206,"props":3502,"children":3503},{"style":246},[3504],{"type":79,"value":3505},"claude-haiku-4-5",{"type":73,"tag":206,"props":3507,"children":3508},{"style":219},[3509],{"type":79,"value":254},{"type":73,"tag":206,"props":3511,"children":3512},{"style":373},[3513],{"type":79,"value":447},{"type":73,"tag":206,"props":3515,"children":3516},{"style":219},[3517],{"type":79,"value":666},{"type":73,"tag":206,"props":3519,"children":3520},{"class":208,"line":515},[3521,3526,3530,3534,3539,3543,3547,3551,3555,3559,3563,3568,3572,3576,3580,3584,3588,3593,3597,3601,3605],{"type":73,"tag":206,"props":3522,"children":3523},{"style":373},[3524],{"type":79,"value":3525},"      messages",{"type":73,"tag":206,"props":3527,"children":3528},{"style":219},[3529],{"type":79,"value":381},{"type":73,"tag":206,"props":3531,"children":3532},{"style":373},[3533],{"type":79,"value":965},{"type":73,"tag":206,"props":3535,"children":3536},{"style":219},[3537],{"type":79,"value":3538},"...",{"type":73,"tag":206,"props":3540,"children":3541},{"style":225},[3542],{"type":79,"value":1960},{"type":73,"tag":206,"props":3544,"children":3545},{"style":219},[3546],{"type":79,"value":399},{"type":73,"tag":206,"props":3548,"children":3549},{"style":219},[3550],{"type":79,"value":222},{"type":73,"tag":206,"props":3552,"children":3553},{"style":373},[3554],{"type":79,"value":2995},{"type":73,"tag":206,"props":3556,"children":3557},{"style":219},[3558],{"type":79,"value":381},{"type":73,"tag":206,"props":3560,"children":3561},{"style":219},[3562],{"type":79,"value":243},{"type":73,"tag":206,"props":3564,"children":3565},{"style":246},[3566],{"type":79,"value":3567},"user",{"type":73,"tag":206,"props":3569,"children":3570},{"style":219},[3571],{"type":79,"value":254},{"type":73,"tag":206,"props":3573,"children":3574},{"style":219},[3575],{"type":79,"value":399},{"type":73,"tag":206,"props":3577,"children":3578},{"style":373},[3579],{"type":79,"value":3021},{"type":73,"tag":206,"props":3581,"children":3582},{"style":219},[3583],{"type":79,"value":381},{"type":73,"tag":206,"props":3585,"children":3586},{"style":219},[3587],{"type":79,"value":243},{"type":73,"tag":206,"props":3589,"children":3590},{"style":246},[3591],{"type":79,"value":3592},"Summarize concisely.",{"type":73,"tag":206,"props":3594,"children":3595},{"style":219},[3596],{"type":79,"value":254},{"type":73,"tag":206,"props":3598,"children":3599},{"style":219},[3600],{"type":79,"value":233},{"type":73,"tag":206,"props":3602,"children":3603},{"style":373},[3604],{"type":79,"value":994},{"type":73,"tag":206,"props":3606,"children":3607},{"style":219},[3608],{"type":79,"value":666},{"type":73,"tag":206,"props":3610,"children":3611},{"class":208,"line":558},[3612,3617,3622,3626,3630],{"type":73,"tag":206,"props":3613,"children":3614},{"style":219},[3615],{"type":79,"value":3616},"    }",{"type":73,"tag":206,"props":3618,"children":3619},{"style":373},[3620],{"type":79,"value":3621},"))",{"type":73,"tag":206,"props":3623,"children":3624},{"style":219},[3625],{"type":79,"value":175},{"type":73,"tag":206,"props":3627,"children":3628},{"style":225},[3629],{"type":79,"value":79},{"type":73,"tag":206,"props":3631,"children":3632},{"style":219},[3633],{"type":79,"value":666},{"type":73,"tag":206,"props":3635,"children":3636},{"class":208,"line":1053},[3637],{"type":73,"tag":206,"props":3638,"children":3639},{"style":219},[3640],{"type":79,"value":3641},"},\n",{"type":73,"tag":695,"props":3643,"children":3645},{"id":3644},"_5-actions-mutate-state-without-a-turn",[3646],{"type":79,"value":3647},"5. Actions: mutate state without a turn",{"type":73,"tag":82,"props":3649,"children":3650},{},[3651,3657,3659,3665,3667,3673,3674,3680,3681,3687,3688,3694,3695,3701,3702,3708,3709,3715,3717,3723,3725,3730,3732,3738,3740,3746,3748,3754],{"type":73,"tag":86,"props":3652,"children":3654},{"className":3653},[],[3655],{"type":79,"value":3656},"actionSchema",{"type":79,"value":3658}," validates; ",{"type":73,"tag":86,"props":3660,"children":3662},{"className":3661},[],[3663],{"type":79,"value":3664},"onAction",{"type":79,"value":3666}," mutates via ",{"type":73,"tag":86,"props":3668,"children":3670},{"className":3669},[],[3671],{"type":79,"value":3672},"chat.history",{"type":79,"value":620},{"type":73,"tag":86,"props":3675,"children":3677},{"className":3676},[],[3678],{"type":79,"value":3679},"slice",{"type":79,"value":612},{"type":73,"tag":86,"props":3682,"children":3684},{"className":3683},[],[3685],{"type":79,"value":3686},"replace",{"type":79,"value":612},{"type":73,"tag":86,"props":3689,"children":3691},{"className":3690},[],[3692],{"type":79,"value":3693},"rollbackTo",{"type":79,"value":666},{"type":73,"tag":86,"props":3696,"children":3698},{"className":3697},[],[3699],{"type":79,"value":3700},"remove",{"type":79,"value":612},{"type":73,"tag":86,"props":3703,"children":3705},{"className":3704},[],[3706],{"type":79,"value":3707},"getPendingToolCalls",{"type":79,"value":612},{"type":73,"tag":86,"props":3710,"children":3712},{"className":3711},[],[3713],{"type":79,"value":3714},"extractNewToolResults",{"type":79,"value":3716},"). Actions fire ",{"type":73,"tag":86,"props":3718,"children":3720},{"className":3719},[],[3721],{"type":79,"value":3722},"hydrateMessages",{"type":79,"value":3724}," and\n",{"type":73,"tag":86,"props":3726,"children":3728},{"className":3727},[],[3729],{"type":79,"value":3664},{"type":79,"value":3731}," only, never ",{"type":73,"tag":86,"props":3733,"children":3735},{"className":3734},[],[3736],{"type":79,"value":3737},"run()",{"type":79,"value":3739}," or the turn hooks. Return a ",{"type":73,"tag":86,"props":3741,"children":3743},{"className":3742},[],[3744],{"type":79,"value":3745},"StreamTextResult",{"type":79,"value":3747},", string, or ",{"type":73,"tag":86,"props":3749,"children":3751},{"className":3750},[],[3752],{"type":79,"value":3753},"UIMessage",{"type":79,"value":3755},"\nto also emit a model response.",{"type":73,"tag":195,"props":3757,"children":3759},{"className":197,"code":3758,"language":199,"meta":200,"style":200},"export const myChat = chat.agent({\n  id: \"my-chat\",\n  actionSchema: z.discriminatedUnion(\"type\", [\n    z.object({ type: z.literal(\"undo\") }),\n    z.object({ type: z.literal(\"rollback\"), targetMessageId: z.string() }),\n  ]),\n  onAction: async ({ action }) => {\n    if (action.type === \"undo\") chat.history.slice(0, -2);\n    if (action.type === \"rollback\") chat.history.rollbackTo(action.targetMessageId);\n  },\n  run: async ({ messages, signal }) => streamText({ model: anthropic(\"claude-sonnet-4-5\"), messages, abortSignal: signal }),\n});\n",[3760],{"type":73,"tag":86,"props":3761,"children":3762},{"__ignoreMap":200},[3763,3802,3829,3879,3957,4062,4074,4111,4208,4296,4303,4426],{"type":73,"tag":206,"props":3764,"children":3765},{"class":208,"line":209},[3766,3770,3774,3778,3782,3786,3790,3794,3798],{"type":73,"tag":206,"props":3767,"children":3768},{"style":213},[3769],{"type":79,"value":2774},{"type":73,"tag":206,"props":3771,"children":3772},{"style":323},[3773],{"type":79,"value":2779},{"type":73,"tag":206,"props":3775,"children":3776},{"style":225},[3777],{"type":79,"value":2784},{"type":73,"tag":206,"props":3779,"children":3780},{"style":219},[3781],{"type":79,"value":336},{"type":73,"tag":206,"props":3783,"children":3784},{"style":225},[3785],{"type":79,"value":478},{"type":73,"tag":206,"props":3787,"children":3788},{"style":219},[3789],{"type":79,"value":175},{"type":73,"tag":206,"props":3791,"children":3792},{"style":344},[3793],{"type":79,"value":2801},{"type":73,"tag":206,"props":3795,"children":3796},{"style":225},[3797],{"type":79,"value":365},{"type":73,"tag":206,"props":3799,"children":3800},{"style":219},[3801],{"type":79,"value":858},{"type":73,"tag":206,"props":3803,"children":3804},{"class":208,"line":262},[3805,3809,3813,3817,3821,3825],{"type":73,"tag":206,"props":3806,"children":3807},{"style":373},[3808],{"type":79,"value":2817},{"type":73,"tag":206,"props":3810,"children":3811},{"style":219},[3812],{"type":79,"value":381},{"type":73,"tag":206,"props":3814,"children":3815},{"style":219},[3816],{"type":79,"value":243},{"type":73,"tag":206,"props":3818,"children":3819},{"style":246},[3820],{"type":79,"value":390},{"type":73,"tag":206,"props":3822,"children":3823},{"style":219},[3824],{"type":79,"value":254},{"type":73,"tag":206,"props":3826,"children":3827},{"style":219},[3828],{"type":79,"value":666},{"type":73,"tag":206,"props":3830,"children":3831},{"class":208,"line":309},[3832,3837,3841,3845,3849,3854,3858,3862,3866,3870,3874],{"type":73,"tag":206,"props":3833,"children":3834},{"style":373},[3835],{"type":79,"value":3836},"  actionSchema",{"type":73,"tag":206,"props":3838,"children":3839},{"style":219},[3840],{"type":79,"value":381},{"type":73,"tag":206,"props":3842,"children":3843},{"style":225},[3844],{"type":79,"value":1584},{"type":73,"tag":206,"props":3846,"children":3847},{"style":219},[3848],{"type":79,"value":175},{"type":73,"tag":206,"props":3850,"children":3851},{"style":344},[3852],{"type":79,"value":3853},"discriminatedUnion",{"type":73,"tag":206,"props":3855,"children":3856},{"style":225},[3857],{"type":79,"value":365},{"type":73,"tag":206,"props":3859,"children":3860},{"style":219},[3861],{"type":79,"value":254},{"type":73,"tag":206,"props":3863,"children":3864},{"style":246},[3865],{"type":79,"value":2149},{"type":73,"tag":206,"props":3867,"children":3868},{"style":219},[3869],{"type":79,"value":254},{"type":73,"tag":206,"props":3871,"children":3872},{"style":219},[3873],{"type":79,"value":399},{"type":73,"tag":206,"props":3875,"children":3876},{"style":225},[3877],{"type":79,"value":3878}," [\n",{"type":73,"tag":206,"props":3880,"children":3881},{"class":208,"line":319},[3882,3887,3891,3895,3899,3903,3907,3911,3915,3919,3924,3928,3932,3937,3941,3945,3949,3953],{"type":73,"tag":206,"props":3883,"children":3884},{"style":225},[3885],{"type":79,"value":3886},"    z",{"type":73,"tag":206,"props":3888,"children":3889},{"style":219},[3890],{"type":79,"value":175},{"type":73,"tag":206,"props":3892,"children":3893},{"style":344},[3894],{"type":79,"value":1698},{"type":73,"tag":206,"props":3896,"children":3897},{"style":225},[3898],{"type":79,"value":365},{"type":73,"tag":206,"props":3900,"children":3901},{"style":219},[3902],{"type":79,"value":370},{"type":73,"tag":206,"props":3904,"children":3905},{"style":373},[3906],{"type":79,"value":272},{"type":73,"tag":206,"props":3908,"children":3909},{"style":219},[3910],{"type":79,"value":381},{"type":73,"tag":206,"props":3912,"children":3913},{"style":225},[3914],{"type":79,"value":1584},{"type":73,"tag":206,"props":3916,"children":3917},{"style":219},[3918],{"type":79,"value":175},{"type":73,"tag":206,"props":3920,"children":3921},{"style":344},[3922],{"type":79,"value":3923},"literal",{"type":73,"tag":206,"props":3925,"children":3926},{"style":225},[3927],{"type":79,"value":365},{"type":73,"tag":206,"props":3929,"children":3930},{"style":219},[3931],{"type":79,"value":254},{"type":73,"tag":206,"props":3933,"children":3934},{"style":246},[3935],{"type":79,"value":3936},"undo",{"type":73,"tag":206,"props":3938,"children":3939},{"style":219},[3940],{"type":79,"value":254},{"type":73,"tag":206,"props":3942,"children":3943},{"style":225},[3944],{"type":79,"value":2171},{"type":73,"tag":206,"props":3946,"children":3947},{"style":219},[3948],{"type":79,"value":827},{"type":73,"tag":206,"props":3950,"children":3951},{"style":225},[3952],{"type":79,"value":447},{"type":73,"tag":206,"props":3954,"children":3955},{"style":219},[3956],{"type":79,"value":666},{"type":73,"tag":206,"props":3958,"children":3959},{"class":208,"line":454},[3960,3964,3968,3972,3976,3980,3984,3988,3992,3996,4000,4004,4008,4013,4017,4021,4025,4030,4034,4038,4042,4046,4050,4054,4058],{"type":73,"tag":206,"props":3961,"children":3962},{"style":225},[3963],{"type":79,"value":3886},{"type":73,"tag":206,"props":3965,"children":3966},{"style":219},[3967],{"type":79,"value":175},{"type":73,"tag":206,"props":3969,"children":3970},{"style":344},[3971],{"type":79,"value":1698},{"type":73,"tag":206,"props":3973,"children":3974},{"style":225},[3975],{"type":79,"value":365},{"type":73,"tag":206,"props":3977,"children":3978},{"style":219},[3979],{"type":79,"value":370},{"type":73,"tag":206,"props":3981,"children":3982},{"style":373},[3983],{"type":79,"value":272},{"type":73,"tag":206,"props":3985,"children":3986},{"style":219},[3987],{"type":79,"value":381},{"type":73,"tag":206,"props":3989,"children":3990},{"style":225},[3991],{"type":79,"value":1584},{"type":73,"tag":206,"props":3993,"children":3994},{"style":219},[3995],{"type":79,"value":175},{"type":73,"tag":206,"props":3997,"children":3998},{"style":344},[3999],{"type":79,"value":3923},{"type":73,"tag":206,"props":4001,"children":4002},{"style":225},[4003],{"type":79,"value":365},{"type":73,"tag":206,"props":4005,"children":4006},{"style":219},[4007],{"type":79,"value":254},{"type":73,"tag":206,"props":4009,"children":4010},{"style":246},[4011],{"type":79,"value":4012},"rollback",{"type":73,"tag":206,"props":4014,"children":4015},{"style":219},[4016],{"type":79,"value":254},{"type":73,"tag":206,"props":4018,"children":4019},{"style":225},[4020],{"type":79,"value":447},{"type":73,"tag":206,"props":4022,"children":4023},{"style":219},[4024],{"type":79,"value":399},{"type":73,"tag":206,"props":4026,"children":4027},{"style":373},[4028],{"type":79,"value":4029}," targetMessageId",{"type":73,"tag":206,"props":4031,"children":4032},{"style":219},[4033],{"type":79,"value":381},{"type":73,"tag":206,"props":4035,"children":4036},{"style":225},[4037],{"type":79,"value":1584},{"type":73,"tag":206,"props":4039,"children":4040},{"style":219},[4041],{"type":79,"value":175},{"type":73,"tag":206,"props":4043,"children":4044},{"style":344},[4045],{"type":79,"value":1728},{"type":73,"tag":206,"props":4047,"children":4048},{"style":225},[4049],{"type":79,"value":1733},{"type":73,"tag":206,"props":4051,"children":4052},{"style":219},[4053],{"type":79,"value":827},{"type":73,"tag":206,"props":4055,"children":4056},{"style":225},[4057],{"type":79,"value":447},{"type":73,"tag":206,"props":4059,"children":4060},{"style":219},[4061],{"type":79,"value":666},{"type":73,"tag":206,"props":4063,"children":4064},{"class":208,"line":515},[4065,4070],{"type":73,"tag":206,"props":4066,"children":4067},{"style":225},[4068],{"type":79,"value":4069},"  ])",{"type":73,"tag":206,"props":4071,"children":4072},{"style":219},[4073],{"type":79,"value":666},{"type":73,"tag":206,"props":4075,"children":4076},{"class":208,"line":558},[4077,4082,4086,4090,4094,4099,4103,4107],{"type":73,"tag":206,"props":4078,"children":4079},{"style":344},[4080],{"type":79,"value":4081},"  onAction",{"type":73,"tag":206,"props":4083,"children":4084},{"style":219},[4085],{"type":79,"value":381},{"type":73,"tag":206,"props":4087,"children":4088},{"style":323},[4089],{"type":79,"value":1762},{"type":73,"tag":206,"props":4091,"children":4092},{"style":219},[4093],{"type":79,"value":1777},{"type":73,"tag":206,"props":4095,"children":4096},{"style":1780},[4097],{"type":79,"value":4098}," action",{"type":73,"tag":206,"props":4100,"children":4101},{"style":219},[4102],{"type":79,"value":1801},{"type":73,"tag":206,"props":4104,"children":4105},{"style":323},[4106],{"type":79,"value":2050},{"type":73,"tag":206,"props":4108,"children":4109},{"style":219},[4110],{"type":79,"value":1806},{"type":73,"tag":206,"props":4112,"children":4113},{"class":208,"line":1053},[4114,4119,4123,4128,4132,4136,4140,4144,4148,4152,4156,4160,4164,4169,4173,4177,4181,4186,4190,4195,4200,4204],{"type":73,"tag":206,"props":4115,"children":4116},{"style":213},[4117],{"type":79,"value":4118},"    if",{"type":73,"tag":206,"props":4120,"children":4121},{"style":373},[4122],{"type":79,"value":620},{"type":73,"tag":206,"props":4124,"children":4125},{"style":225},[4126],{"type":79,"value":4127},"action",{"type":73,"tag":206,"props":4129,"children":4130},{"style":219},[4131],{"type":79,"value":175},{"type":73,"tag":206,"props":4133,"children":4134},{"style":225},[4135],{"type":79,"value":2149},{"type":73,"tag":206,"props":4137,"children":4138},{"style":219},[4139],{"type":79,"value":2154},{"type":73,"tag":206,"props":4141,"children":4142},{"style":219},[4143],{"type":79,"value":243},{"type":73,"tag":206,"props":4145,"children":4146},{"style":246},[4147],{"type":79,"value":3936},{"type":73,"tag":206,"props":4149,"children":4150},{"style":219},[4151],{"type":79,"value":254},{"type":73,"tag":206,"props":4153,"children":4154},{"style":373},[4155],{"type":79,"value":2171},{"type":73,"tag":206,"props":4157,"children":4158},{"style":225},[4159],{"type":79,"value":144},{"type":73,"tag":206,"props":4161,"children":4162},{"style":219},[4163],{"type":79,"value":175},{"type":73,"tag":206,"props":4165,"children":4166},{"style":225},[4167],{"type":79,"value":4168},"history",{"type":73,"tag":206,"props":4170,"children":4171},{"style":219},[4172],{"type":79,"value":175},{"type":73,"tag":206,"props":4174,"children":4175},{"style":344},[4176],{"type":79,"value":3679},{"type":73,"tag":206,"props":4178,"children":4179},{"style":373},[4180],{"type":79,"value":365},{"type":73,"tag":206,"props":4182,"children":4183},{"style":1297},[4184],{"type":79,"value":4185},"0",{"type":73,"tag":206,"props":4187,"children":4188},{"style":219},[4189],{"type":79,"value":399},{"type":73,"tag":206,"props":4191,"children":4192},{"style":219},[4193],{"type":79,"value":4194}," -",{"type":73,"tag":206,"props":4196,"children":4197},{"style":1297},[4198],{"type":79,"value":4199},"2",{"type":73,"tag":206,"props":4201,"children":4202},{"style":373},[4203],{"type":79,"value":447},{"type":73,"tag":206,"props":4205,"children":4206},{"style":219},[4207],{"type":79,"value":259},{"type":73,"tag":206,"props":4209,"children":4210},{"class":208,"line":1069},[4211,4215,4219,4223,4227,4231,4235,4239,4243,4247,4251,4255,4259,4263,4267,4271,4275,4279,4283,4288,4292],{"type":73,"tag":206,"props":4212,"children":4213},{"style":213},[4214],{"type":79,"value":4118},{"type":73,"tag":206,"props":4216,"children":4217},{"style":373},[4218],{"type":79,"value":620},{"type":73,"tag":206,"props":4220,"children":4221},{"style":225},[4222],{"type":79,"value":4127},{"type":73,"tag":206,"props":4224,"children":4225},{"style":219},[4226],{"type":79,"value":175},{"type":73,"tag":206,"props":4228,"children":4229},{"style":225},[4230],{"type":79,"value":2149},{"type":73,"tag":206,"props":4232,"children":4233},{"style":219},[4234],{"type":79,"value":2154},{"type":73,"tag":206,"props":4236,"children":4237},{"style":219},[4238],{"type":79,"value":243},{"type":73,"tag":206,"props":4240,"children":4241},{"style":246},[4242],{"type":79,"value":4012},{"type":73,"tag":206,"props":4244,"children":4245},{"style":219},[4246],{"type":79,"value":254},{"type":73,"tag":206,"props":4248,"children":4249},{"style":373},[4250],{"type":79,"value":2171},{"type":73,"tag":206,"props":4252,"children":4253},{"style":225},[4254],{"type":79,"value":144},{"type":73,"tag":206,"props":4256,"children":4257},{"style":219},[4258],{"type":79,"value":175},{"type":73,"tag":206,"props":4260,"children":4261},{"style":225},[4262],{"type":79,"value":4168},{"type":73,"tag":206,"props":4264,"children":4265},{"style":219},[4266],{"type":79,"value":175},{"type":73,"tag":206,"props":4268,"children":4269},{"style":344},[4270],{"type":79,"value":3693},{"type":73,"tag":206,"props":4272,"children":4273},{"style":373},[4274],{"type":79,"value":365},{"type":73,"tag":206,"props":4276,"children":4277},{"style":225},[4278],{"type":79,"value":4127},{"type":73,"tag":206,"props":4280,"children":4281},{"style":219},[4282],{"type":79,"value":175},{"type":73,"tag":206,"props":4284,"children":4285},{"style":225},[4286],{"type":79,"value":4287},"targetMessageId",{"type":73,"tag":206,"props":4289,"children":4290},{"style":373},[4291],{"type":79,"value":447},{"type":73,"tag":206,"props":4293,"children":4294},{"style":219},[4295],{"type":79,"value":259},{"type":73,"tag":206,"props":4297,"children":4298},{"class":208,"line":1077},[4299],{"type":73,"tag":206,"props":4300,"children":4301},{"style":219},[4302],{"type":79,"value":2010},{"type":73,"tag":206,"props":4304,"children":4305},{"class":208,"line":1123},[4306,4310,4314,4318,4322,4326,4330,4334,4338,4342,4347,4351,4355,4360,4364,4368,4372,4376,4381,4385,4389,4393,4397,4401,4405,4409,4414,4418,4422],{"type":73,"tag":206,"props":4307,"children":4308},{"style":344},[4309],{"type":79,"value":3106},{"type":73,"tag":206,"props":4311,"children":4312},{"style":219},[4313],{"type":79,"value":381},{"type":73,"tag":206,"props":4315,"children":4316},{"style":323},[4317],{"type":79,"value":1762},{"type":73,"tag":206,"props":4319,"children":4320},{"style":219},[4321],{"type":79,"value":1777},{"type":73,"tag":206,"props":4323,"children":4324},{"style":1780},[4325],{"type":79,"value":2862},{"type":73,"tag":206,"props":4327,"children":4328},{"style":219},[4329],{"type":79,"value":399},{"type":73,"tag":206,"props":4331,"children":4332},{"style":1780},[4333],{"type":79,"value":3131},{"type":73,"tag":206,"props":4335,"children":4336},{"style":219},[4337],{"type":79,"value":1801},{"type":73,"tag":206,"props":4339,"children":4340},{"style":323},[4341],{"type":79,"value":2050},{"type":73,"tag":206,"props":4343,"children":4344},{"style":344},[4345],{"type":79,"value":4346}," streamText",{"type":73,"tag":206,"props":4348,"children":4349},{"style":225},[4350],{"type":79,"value":365},{"type":73,"tag":206,"props":4352,"children":4353},{"style":219},[4354],{"type":79,"value":370},{"type":73,"tag":206,"props":4356,"children":4357},{"style":373},[4358],{"type":79,"value":4359}," model",{"type":73,"tag":206,"props":4361,"children":4362},{"style":219},[4363],{"type":79,"value":381},{"type":73,"tag":206,"props":4365,"children":4366},{"style":344},[4367],{"type":79,"value":3492},{"type":73,"tag":206,"props":4369,"children":4370},{"style":225},[4371],{"type":79,"value":365},{"type":73,"tag":206,"props":4373,"children":4374},{"style":219},[4375],{"type":79,"value":254},{"type":73,"tag":206,"props":4377,"children":4378},{"style":246},[4379],{"type":79,"value":4380},"claude-sonnet-4-5",{"type":73,"tag":206,"props":4382,"children":4383},{"style":219},[4384],{"type":79,"value":254},{"type":73,"tag":206,"props":4386,"children":4387},{"style":225},[4388],{"type":79,"value":447},{"type":73,"tag":206,"props":4390,"children":4391},{"style":219},[4392],{"type":79,"value":399},{"type":73,"tag":206,"props":4394,"children":4395},{"style":225},[4396],{"type":79,"value":2862},{"type":73,"tag":206,"props":4398,"children":4399},{"style":219},[4400],{"type":79,"value":399},{"type":73,"tag":206,"props":4402,"children":4403},{"style":373},[4404],{"type":79,"value":1796},{"type":73,"tag":206,"props":4406,"children":4407},{"style":219},[4408],{"type":79,"value":381},{"type":73,"tag":206,"props":4410,"children":4411},{"style":225},[4412],{"type":79,"value":4413}," signal ",{"type":73,"tag":206,"props":4415,"children":4416},{"style":219},[4417],{"type":79,"value":827},{"type":73,"tag":206,"props":4419,"children":4420},{"style":225},[4421],{"type":79,"value":447},{"type":73,"tag":206,"props":4423,"children":4424},{"style":219},[4425],{"type":79,"value":666},{"type":73,"tag":206,"props":4427,"children":4428},{"class":208,"line":1222},[4429,4433,4437],{"type":73,"tag":206,"props":4430,"children":4431},{"style":219},[4432],{"type":79,"value":827},{"type":73,"tag":206,"props":4434,"children":4435},{"style":225},[4436],{"type":79,"value":447},{"type":73,"tag":206,"props":4438,"children":4439},{"style":219},[4440],{"type":79,"value":259},{"type":73,"tag":82,"props":4442,"children":4443},{},[4444,4446,4452,4454,4460],{"type":79,"value":4445},"Send from the browser with ",{"type":73,"tag":86,"props":4447,"children":4449},{"className":4448},[],[4450],{"type":79,"value":4451},"transport.sendAction(chatId, { type: \"undo\" })",{"type":79,"value":4453},", or server-side with\n",{"type":73,"tag":86,"props":4455,"children":4457},{"className":4456},[],[4458],{"type":79,"value":4459},"agentChat.sendAction({ type: \"rollback\", targetMessageId: \"msg-3\" })",{"type":79,"value":175},{"type":73,"tag":695,"props":4462,"children":4464},{"id":4463},"_6-fast-starts-head-start",[4465],{"type":79,"value":4466},"6. Fast starts: Head Start",{"type":73,"tag":82,"props":4468,"children":4469},{},[4470,4476,4478,4483,4485,4491,4493,4498,4500,4505,4507,4512],{"type":73,"tag":86,"props":4471,"children":4473},{"className":4472},[],[4474],{"type":79,"value":4475},"chat.headStart",{"type":79,"value":4477}," (from ",{"type":73,"tag":86,"props":4479,"children":4481},{"className":4480},[],[4482],{"type":79,"value":173},{"type":79,"value":4484},", NOT ",{"type":73,"tag":86,"props":4486,"children":4488},{"className":4487},[],[4489],{"type":79,"value":4490},"\u002Fai",{"type":79,"value":4492},") returns a Web Fetch handler that\nserves turn 1 from your own warm process, then hands off to the agent on turn 2+. Tools passed here\nmust be ",{"type":73,"tag":95,"props":4494,"children":4495},{},[4496],{"type":79,"value":4497},"schema-only",{"type":79,"value":4499}," (a module importing ",{"type":73,"tag":86,"props":4501,"children":4503},{"className":4502},[],[4504],{"type":79,"value":27},{"type":79,"value":4506}," + ",{"type":73,"tag":86,"props":4508,"children":4510},{"className":4509},[],[4511],{"type":79,"value":1601},{"type":79,"value":4513}," only); heavy executes stay in the task.",{"type":73,"tag":195,"props":4515,"children":4517},{"className":197,"code":4516,"language":199,"meta":200,"style":200},"import { chat } from \"@trigger.dev\u002Fsdk\u002Fchat-server\";\nimport { streamText, stepCountIs } from \"ai\";\nimport { anthropic } from \"@ai-sdk\u002Fanthropic\";\nimport { headStartTools } from \"@\u002Flib\u002Fchat-tools\u002Fschemas\";\n\nexport const chatHandler = chat.headStart({\n  agentId: \"my-chat\",\n  run: async ({ chat: helper }) =>\n    streamText({\n      ...helper.toStreamTextOptions({ tools: headStartTools }),\n      model: anthropic(\"claude-sonnet-4-6\"),\n      system: \"You are helpful.\",\n      stopWhen: stepCountIs(15),\n    }),\n});\n\u002F\u002F Next.js: export const POST = chatHandler;  Transport: headStart: \"\u002Fapi\u002Fchat\"\n",[4518],{"type":73,"tag":86,"props":4519,"children":4520},{"__ignoreMap":200},[4521,4560,4607,4647,4688,4695,4736,4764,4804,4819,4874,4914,4943,4975,4990,5005],{"type":73,"tag":206,"props":4522,"children":4523},{"class":208,"line":209},[4524,4528,4532,4536,4540,4544,4548,4552,4556],{"type":73,"tag":206,"props":4525,"children":4526},{"style":213},[4527],{"type":79,"value":216},{"type":73,"tag":206,"props":4529,"children":4530},{"style":219},[4531],{"type":79,"value":222},{"type":73,"tag":206,"props":4533,"children":4534},{"style":225},[4535],{"type":79,"value":478},{"type":73,"tag":206,"props":4537,"children":4538},{"style":219},[4539],{"type":79,"value":233},{"type":73,"tag":206,"props":4541,"children":4542},{"style":213},[4543],{"type":79,"value":238},{"type":73,"tag":206,"props":4545,"children":4546},{"style":219},[4547],{"type":79,"value":243},{"type":73,"tag":206,"props":4549,"children":4550},{"style":246},[4551],{"type":79,"value":173},{"type":73,"tag":206,"props":4553,"children":4554},{"style":219},[4555],{"type":79,"value":254},{"type":73,"tag":206,"props":4557,"children":4558},{"style":219},[4559],{"type":79,"value":259},{"type":73,"tag":206,"props":4561,"children":4562},{"class":208,"line":262},[4563,4567,4571,4575,4579,4583,4587,4591,4595,4599,4603],{"type":73,"tag":206,"props":4564,"children":4565},{"style":213},[4566],{"type":79,"value":216},{"type":73,"tag":206,"props":4568,"children":4569},{"style":219},[4570],{"type":79,"value":222},{"type":73,"tag":206,"props":4572,"children":4573},{"style":225},[4574],{"type":79,"value":4346},{"type":73,"tag":206,"props":4576,"children":4577},{"style":219},[4578],{"type":79,"value":399},{"type":73,"tag":206,"props":4580,"children":4581},{"style":225},[4582],{"type":79,"value":3236},{"type":73,"tag":206,"props":4584,"children":4585},{"style":219},[4586],{"type":79,"value":233},{"type":73,"tag":206,"props":4588,"children":4589},{"style":213},[4590],{"type":79,"value":238},{"type":73,"tag":206,"props":4592,"children":4593},{"style":219},[4594],{"type":79,"value":243},{"type":73,"tag":206,"props":4596,"children":4597},{"style":246},[4598],{"type":79,"value":27},{"type":73,"tag":206,"props":4600,"children":4601},{"style":219},[4602],{"type":79,"value":254},{"type":73,"tag":206,"props":4604,"children":4605},{"style":219},[4606],{"type":79,"value":259},{"type":73,"tag":206,"props":4608,"children":4609},{"class":208,"line":309},[4610,4614,4618,4622,4626,4630,4634,4639,4643],{"type":73,"tag":206,"props":4611,"children":4612},{"style":213},[4613],{"type":79,"value":216},{"type":73,"tag":206,"props":4615,"children":4616},{"style":219},[4617],{"type":79,"value":222},{"type":73,"tag":206,"props":4619,"children":4620},{"style":225},[4621],{"type":79,"value":3492},{"type":73,"tag":206,"props":4623,"children":4624},{"style":219},[4625],{"type":79,"value":233},{"type":73,"tag":206,"props":4627,"children":4628},{"style":213},[4629],{"type":79,"value":238},{"type":73,"tag":206,"props":4631,"children":4632},{"style":219},[4633],{"type":79,"value":243},{"type":73,"tag":206,"props":4635,"children":4636},{"style":246},[4637],{"type":79,"value":4638},"@ai-sdk\u002Fanthropic",{"type":73,"tag":206,"props":4640,"children":4641},{"style":219},[4642],{"type":79,"value":254},{"type":73,"tag":206,"props":4644,"children":4645},{"style":219},[4646],{"type":79,"value":259},{"type":73,"tag":206,"props":4648,"children":4649},{"class":208,"line":319},[4650,4654,4658,4663,4667,4671,4675,4680,4684],{"type":73,"tag":206,"props":4651,"children":4652},{"style":213},[4653],{"type":79,"value":216},{"type":73,"tag":206,"props":4655,"children":4656},{"style":219},[4657],{"type":79,"value":222},{"type":73,"tag":206,"props":4659,"children":4660},{"style":225},[4661],{"type":79,"value":4662}," headStartTools",{"type":73,"tag":206,"props":4664,"children":4665},{"style":219},[4666],{"type":79,"value":233},{"type":73,"tag":206,"props":4668,"children":4669},{"style":213},[4670],{"type":79,"value":238},{"type":73,"tag":206,"props":4672,"children":4673},{"style":219},[4674],{"type":79,"value":243},{"type":73,"tag":206,"props":4676,"children":4677},{"style":246},[4678],{"type":79,"value":4679},"@\u002Flib\u002Fchat-tools\u002Fschemas",{"type":73,"tag":206,"props":4681,"children":4682},{"style":219},[4683],{"type":79,"value":254},{"type":73,"tag":206,"props":4685,"children":4686},{"style":219},[4687],{"type":79,"value":259},{"type":73,"tag":206,"props":4689,"children":4690},{"class":208,"line":454},[4691],{"type":73,"tag":206,"props":4692,"children":4693},{"emptyLinePlaceholder":313},[4694],{"type":79,"value":316},{"type":73,"tag":206,"props":4696,"children":4697},{"class":208,"line":515},[4698,4702,4706,4711,4715,4719,4723,4728,4732],{"type":73,"tag":206,"props":4699,"children":4700},{"style":213},[4701],{"type":79,"value":2774},{"type":73,"tag":206,"props":4703,"children":4704},{"style":323},[4705],{"type":79,"value":2779},{"type":73,"tag":206,"props":4707,"children":4708},{"style":225},[4709],{"type":79,"value":4710}," chatHandler ",{"type":73,"tag":206,"props":4712,"children":4713},{"style":219},[4714],{"type":79,"value":336},{"type":73,"tag":206,"props":4716,"children":4717},{"style":225},[4718],{"type":79,"value":478},{"type":73,"tag":206,"props":4720,"children":4721},{"style":219},[4722],{"type":79,"value":175},{"type":73,"tag":206,"props":4724,"children":4725},{"style":344},[4726],{"type":79,"value":4727},"headStart",{"type":73,"tag":206,"props":4729,"children":4730},{"style":225},[4731],{"type":79,"value":365},{"type":73,"tag":206,"props":4733,"children":4734},{"style":219},[4735],{"type":79,"value":858},{"type":73,"tag":206,"props":4737,"children":4738},{"class":208,"line":558},[4739,4744,4748,4752,4756,4760],{"type":73,"tag":206,"props":4740,"children":4741},{"style":373},[4742],{"type":79,"value":4743},"  agentId",{"type":73,"tag":206,"props":4745,"children":4746},{"style":219},[4747],{"type":79,"value":381},{"type":73,"tag":206,"props":4749,"children":4750},{"style":219},[4751],{"type":79,"value":243},{"type":73,"tag":206,"props":4753,"children":4754},{"style":246},[4755],{"type":79,"value":390},{"type":73,"tag":206,"props":4757,"children":4758},{"style":219},[4759],{"type":79,"value":254},{"type":73,"tag":206,"props":4761,"children":4762},{"style":219},[4763],{"type":79,"value":666},{"type":73,"tag":206,"props":4765,"children":4766},{"class":208,"line":1053},[4767,4771,4775,4779,4783,4787,4791,4796,4800],{"type":73,"tag":206,"props":4768,"children":4769},{"style":344},[4770],{"type":79,"value":3106},{"type":73,"tag":206,"props":4772,"children":4773},{"style":219},[4774],{"type":79,"value":381},{"type":73,"tag":206,"props":4776,"children":4777},{"style":323},[4778],{"type":79,"value":1762},{"type":73,"tag":206,"props":4780,"children":4781},{"style":219},[4782],{"type":79,"value":1777},{"type":73,"tag":206,"props":4784,"children":4785},{"style":373},[4786],{"type":79,"value":478},{"type":73,"tag":206,"props":4788,"children":4789},{"style":219},[4790],{"type":79,"value":381},{"type":73,"tag":206,"props":4792,"children":4793},{"style":1780},[4794],{"type":79,"value":4795}," helper",{"type":73,"tag":206,"props":4797,"children":4798},{"style":219},[4799],{"type":79,"value":1801},{"type":73,"tag":206,"props":4801,"children":4802},{"style":323},[4803],{"type":79,"value":2557},{"type":73,"tag":206,"props":4805,"children":4806},{"class":208,"line":1069},[4807,4811,4815],{"type":73,"tag":206,"props":4808,"children":4809},{"style":344},[4810],{"type":79,"value":3147},{"type":73,"tag":206,"props":4812,"children":4813},{"style":225},[4814],{"type":79,"value":365},{"type":73,"tag":206,"props":4816,"children":4817},{"style":219},[4818],{"type":79,"value":858},{"type":73,"tag":206,"props":4820,"children":4821},{"class":208,"line":1077},[4822,4827,4832,4836,4840,4844,4848,4853,4857,4862,4866,4870],{"type":73,"tag":206,"props":4823,"children":4824},{"style":219},[4825],{"type":79,"value":4826},"      ...",{"type":73,"tag":206,"props":4828,"children":4829},{"style":225},[4830],{"type":79,"value":4831},"helper",{"type":73,"tag":206,"props":4833,"children":4834},{"style":219},[4835],{"type":79,"value":175},{"type":73,"tag":206,"props":4837,"children":4838},{"style":344},[4839],{"type":79,"value":3173},{"type":73,"tag":206,"props":4841,"children":4842},{"style":225},[4843],{"type":79,"value":365},{"type":73,"tag":206,"props":4845,"children":4846},{"style":219},[4847],{"type":79,"value":370},{"type":73,"tag":206,"props":4849,"children":4850},{"style":373},[4851],{"type":79,"value":4852}," tools",{"type":73,"tag":206,"props":4854,"children":4855},{"style":219},[4856],{"type":79,"value":381},{"type":73,"tag":206,"props":4858,"children":4859},{"style":225},[4860],{"type":79,"value":4861}," headStartTools ",{"type":73,"tag":206,"props":4863,"children":4864},{"style":219},[4865],{"type":79,"value":827},{"type":73,"tag":206,"props":4867,"children":4868},{"style":225},[4869],{"type":79,"value":447},{"type":73,"tag":206,"props":4871,"children":4872},{"style":219},[4873],{"type":79,"value":666},{"type":73,"tag":206,"props":4875,"children":4876},{"class":208,"line":1123},[4877,4881,4885,4889,4893,4897,4902,4906,4910],{"type":73,"tag":206,"props":4878,"children":4879},{"style":373},[4880],{"type":79,"value":3483},{"type":73,"tag":206,"props":4882,"children":4883},{"style":219},[4884],{"type":79,"value":381},{"type":73,"tag":206,"props":4886,"children":4887},{"style":344},[4888],{"type":79,"value":3492},{"type":73,"tag":206,"props":4890,"children":4891},{"style":225},[4892],{"type":79,"value":365},{"type":73,"tag":206,"props":4894,"children":4895},{"style":219},[4896],{"type":79,"value":254},{"type":73,"tag":206,"props":4898,"children":4899},{"style":246},[4900],{"type":79,"value":4901},"claude-sonnet-4-6",{"type":73,"tag":206,"props":4903,"children":4904},{"style":219},[4905],{"type":79,"value":254},{"type":73,"tag":206,"props":4907,"children":4908},{"style":225},[4909],{"type":79,"value":447},{"type":73,"tag":206,"props":4911,"children":4912},{"style":219},[4913],{"type":79,"value":666},{"type":73,"tag":206,"props":4915,"children":4916},{"class":208,"line":1222},[4917,4922,4926,4930,4935,4939],{"type":73,"tag":206,"props":4918,"children":4919},{"style":373},[4920],{"type":79,"value":4921},"      system",{"type":73,"tag":206,"props":4923,"children":4924},{"style":219},[4925],{"type":79,"value":381},{"type":73,"tag":206,"props":4927,"children":4928},{"style":219},[4929],{"type":79,"value":243},{"type":73,"tag":206,"props":4931,"children":4932},{"style":246},[4933],{"type":79,"value":4934},"You are helpful.",{"type":73,"tag":206,"props":4936,"children":4937},{"style":219},[4938],{"type":79,"value":254},{"type":73,"tag":206,"props":4940,"children":4941},{"style":219},[4942],{"type":79,"value":666},{"type":73,"tag":206,"props":4944,"children":4945},{"class":208,"line":2004},[4946,4951,4955,4959,4963,4967,4971],{"type":73,"tag":206,"props":4947,"children":4948},{"style":373},[4949],{"type":79,"value":4950},"      stopWhen",{"type":73,"tag":206,"props":4952,"children":4953},{"style":219},[4954],{"type":79,"value":381},{"type":73,"tag":206,"props":4956,"children":4957},{"style":344},[4958],{"type":79,"value":3236},{"type":73,"tag":206,"props":4960,"children":4961},{"style":225},[4962],{"type":79,"value":365},{"type":73,"tag":206,"props":4964,"children":4965},{"style":1297},[4966],{"type":79,"value":3245},{"type":73,"tag":206,"props":4968,"children":4969},{"style":225},[4970],{"type":79,"value":447},{"type":73,"tag":206,"props":4972,"children":4973},{"style":219},[4974],{"type":79,"value":666},{"type":73,"tag":206,"props":4976,"children":4977},{"class":208,"line":2013},[4978,4982,4986],{"type":73,"tag":206,"props":4979,"children":4980},{"style":219},[4981],{"type":79,"value":3616},{"type":73,"tag":206,"props":4983,"children":4984},{"style":225},[4985],{"type":79,"value":447},{"type":73,"tag":206,"props":4987,"children":4988},{"style":219},[4989],{"type":79,"value":666},{"type":73,"tag":206,"props":4991,"children":4992},{"class":208,"line":2057},[4993,4997,5001],{"type":73,"tag":206,"props":4994,"children":4995},{"style":219},[4996],{"type":79,"value":827},{"type":73,"tag":206,"props":4998,"children":4999},{"style":225},[5000],{"type":79,"value":447},{"type":73,"tag":206,"props":5002,"children":5003},{"style":219},[5004],{"type":79,"value":259},{"type":73,"tag":206,"props":5006,"children":5007},{"class":208,"line":2179},[5008],{"type":73,"tag":206,"props":5009,"children":5010},{"style":1117},[5011],{"type":79,"value":5012},"\u002F\u002F Next.js: export const POST = chatHandler;  Transport: headStart: \"\u002Fapi\u002Fchat\"\n",{"type":73,"tag":82,"props":5014,"children":5015},{},[5016,5018,5024,5026,5031],{"type":79,"value":5017},"Node-only frameworks wrap a Web Fetch handler with ",{"type":73,"tag":86,"props":5019,"children":5021},{"className":5020},[],[5022],{"type":79,"value":5023},"chat.toNodeListener(handler)",{"type":79,"value":5025},". Use the ",{"type":73,"tag":95,"props":5027,"children":5028},{},[5029],{"type":79,"value":5030},"same\nmodel",{"type":79,"value":5032}," on both sides to avoid a tone shift between turn 1 and turn 2+.",{"type":73,"tag":695,"props":5034,"children":5036},{"id":5035},"_7-chatlocal-init-in-onboot-not-onchatstart",[5037],{"type":79,"value":5038},"7. chat.local: init in onBoot, not onChatStart",{"type":73,"tag":82,"props":5040,"children":5041},{},[5042,5048,5050,5056,5058,5064],{"type":73,"tag":86,"props":5043,"children":5045},{"className":5044},[],[5046],{"type":79,"value":5047},"chat.local\u003CT>({ id })",{"type":79,"value":5049}," is module-level, shallow-proxy, run-scoped state. Initialize it in ",{"type":73,"tag":86,"props":5051,"children":5053},{"className":5052},[],[5054],{"type":79,"value":5055},"onBoot",{"type":79,"value":5057},"\n(fires on every fresh worker, including continuation runs), never ",{"type":73,"tag":86,"props":5059,"children":5061},{"className":5060},[],[5062],{"type":79,"value":5063},"onChatStart",{"type":79,"value":175},{"type":73,"tag":195,"props":5066,"children":5068},{"className":197,"code":5067,"language":199,"meta":200,"style":200},"const userContext = chat.local\u003C{ name: string; plan: \"free\" | \"pro\" }>({ id: \"userContext\" });\n\nexport const myChat = chat.agent({\n  id: \"my-chat\",\n  onBoot: async ({ clientData }) => userContext.init({ name: \"Alice\", plan: \"pro\" }),\n  run: async ({ messages, signal }) => streamText({ \u002F* ... *\u002F }),\n});\n",[5069],{"type":73,"tag":86,"props":5070,"children":5071},{"__ignoreMap":200},[5072,5209,5216,5255,5282,5393,5461],{"type":73,"tag":206,"props":5073,"children":5074},{"class":208,"line":209},[5075,5079,5084,5088,5092,5096,5101,5106,5111,5115,5119,5123,5128,5132,5136,5141,5145,5150,5154,5159,5163,5168,5172,5176,5180,5184,5188,5193,5197,5201,5205],{"type":73,"tag":206,"props":5076,"children":5077},{"style":323},[5078],{"type":79,"value":326},{"type":73,"tag":206,"props":5080,"children":5081},{"style":225},[5082],{"type":79,"value":5083}," userContext ",{"type":73,"tag":206,"props":5085,"children":5086},{"style":219},[5087],{"type":79,"value":336},{"type":73,"tag":206,"props":5089,"children":5090},{"style":225},[5091],{"type":79,"value":478},{"type":73,"tag":206,"props":5093,"children":5094},{"style":219},[5095],{"type":79,"value":175},{"type":73,"tag":206,"props":5097,"children":5098},{"style":344},[5099],{"type":79,"value":5100},"local",{"type":73,"tag":206,"props":5102,"children":5103},{"style":219},[5104],{"type":79,"value":5105},"\u003C{",{"type":73,"tag":206,"props":5107,"children":5108},{"style":373},[5109],{"type":79,"value":5110}," name",{"type":73,"tag":206,"props":5112,"children":5113},{"style":219},[5114],{"type":79,"value":381},{"type":73,"tag":206,"props":5116,"children":5117},{"style":1270},[5118],{"type":79,"value":2127},{"type":73,"tag":206,"props":5120,"children":5121},{"style":219},[5122],{"type":79,"value":1114},{"type":73,"tag":206,"props":5124,"children":5125},{"style":373},[5126],{"type":79,"value":5127}," plan",{"type":73,"tag":206,"props":5129,"children":5130},{"style":219},[5131],{"type":79,"value":381},{"type":73,"tag":206,"props":5133,"children":5134},{"style":219},[5135],{"type":79,"value":243},{"type":73,"tag":206,"props":5137,"children":5138},{"style":246},[5139],{"type":79,"value":5140},"free",{"type":73,"tag":206,"props":5142,"children":5143},{"style":219},[5144],{"type":79,"value":254},{"type":73,"tag":206,"props":5146,"children":5147},{"style":219},[5148],{"type":79,"value":5149}," |",{"type":73,"tag":206,"props":5151,"children":5152},{"style":219},[5153],{"type":79,"value":243},{"type":73,"tag":206,"props":5155,"children":5156},{"style":246},[5157],{"type":79,"value":5158},"pro",{"type":73,"tag":206,"props":5160,"children":5161},{"style":219},[5162],{"type":79,"value":254},{"type":73,"tag":206,"props":5164,"children":5165},{"style":219},[5166],{"type":79,"value":5167}," }>",{"type":73,"tag":206,"props":5169,"children":5170},{"style":225},[5171],{"type":79,"value":365},{"type":73,"tag":206,"props":5173,"children":5174},{"style":219},[5175],{"type":79,"value":370},{"type":73,"tag":206,"props":5177,"children":5178},{"style":373},[5179],{"type":79,"value":813},{"type":73,"tag":206,"props":5181,"children":5182},{"style":219},[5183],{"type":79,"value":381},{"type":73,"tag":206,"props":5185,"children":5186},{"style":219},[5187],{"type":79,"value":243},{"type":73,"tag":206,"props":5189,"children":5190},{"style":246},[5191],{"type":79,"value":5192},"userContext",{"type":73,"tag":206,"props":5194,"children":5195},{"style":219},[5196],{"type":79,"value":254},{"type":73,"tag":206,"props":5198,"children":5199},{"style":219},[5200],{"type":79,"value":233},{"type":73,"tag":206,"props":5202,"children":5203},{"style":225},[5204],{"type":79,"value":447},{"type":73,"tag":206,"props":5206,"children":5207},{"style":219},[5208],{"type":79,"value":259},{"type":73,"tag":206,"props":5210,"children":5211},{"class":208,"line":262},[5212],{"type":73,"tag":206,"props":5213,"children":5214},{"emptyLinePlaceholder":313},[5215],{"type":79,"value":316},{"type":73,"tag":206,"props":5217,"children":5218},{"class":208,"line":309},[5219,5223,5227,5231,5235,5239,5243,5247,5251],{"type":73,"tag":206,"props":5220,"children":5221},{"style":213},[5222],{"type":79,"value":2774},{"type":73,"tag":206,"props":5224,"children":5225},{"style":323},[5226],{"type":79,"value":2779},{"type":73,"tag":206,"props":5228,"children":5229},{"style":225},[5230],{"type":79,"value":2784},{"type":73,"tag":206,"props":5232,"children":5233},{"style":219},[5234],{"type":79,"value":336},{"type":73,"tag":206,"props":5236,"children":5237},{"style":225},[5238],{"type":79,"value":478},{"type":73,"tag":206,"props":5240,"children":5241},{"style":219},[5242],{"type":79,"value":175},{"type":73,"tag":206,"props":5244,"children":5245},{"style":344},[5246],{"type":79,"value":2801},{"type":73,"tag":206,"props":5248,"children":5249},{"style":225},[5250],{"type":79,"value":365},{"type":73,"tag":206,"props":5252,"children":5253},{"style":219},[5254],{"type":79,"value":858},{"type":73,"tag":206,"props":5256,"children":5257},{"class":208,"line":319},[5258,5262,5266,5270,5274,5278],{"type":73,"tag":206,"props":5259,"children":5260},{"style":373},[5261],{"type":79,"value":2817},{"type":73,"tag":206,"props":5263,"children":5264},{"style":219},[5265],{"type":79,"value":381},{"type":73,"tag":206,"props":5267,"children":5268},{"style":219},[5269],{"type":79,"value":243},{"type":73,"tag":206,"props":5271,"children":5272},{"style":246},[5273],{"type":79,"value":390},{"type":73,"tag":206,"props":5275,"children":5276},{"style":219},[5277],{"type":79,"value":254},{"type":73,"tag":206,"props":5279,"children":5280},{"style":219},[5281],{"type":79,"value":666},{"type":73,"tag":206,"props":5283,"children":5284},{"class":208,"line":454},[5285,5290,5294,5298,5302,5306,5310,5314,5319,5323,5328,5332,5336,5340,5344,5348,5353,5357,5361,5365,5369,5373,5377,5381,5385,5389],{"type":73,"tag":206,"props":5286,"children":5287},{"style":344},[5288],{"type":79,"value":5289},"  onBoot",{"type":73,"tag":206,"props":5291,"children":5292},{"style":219},[5293],{"type":79,"value":381},{"type":73,"tag":206,"props":5295,"children":5296},{"style":323},[5297],{"type":79,"value":1762},{"type":73,"tag":206,"props":5299,"children":5300},{"style":219},[5301],{"type":79,"value":1777},{"type":73,"tag":206,"props":5303,"children":5304},{"style":1780},[5305],{"type":79,"value":404},{"type":73,"tag":206,"props":5307,"children":5308},{"style":219},[5309],{"type":79,"value":1801},{"type":73,"tag":206,"props":5311,"children":5312},{"style":323},[5313],{"type":79,"value":2050},{"type":73,"tag":206,"props":5315,"children":5316},{"style":225},[5317],{"type":79,"value":5318}," userContext",{"type":73,"tag":206,"props":5320,"children":5321},{"style":219},[5322],{"type":79,"value":175},{"type":73,"tag":206,"props":5324,"children":5325},{"style":344},[5326],{"type":79,"value":5327},"init",{"type":73,"tag":206,"props":5329,"children":5330},{"style":225},[5331],{"type":79,"value":365},{"type":73,"tag":206,"props":5333,"children":5334},{"style":219},[5335],{"type":79,"value":370},{"type":73,"tag":206,"props":5337,"children":5338},{"style":373},[5339],{"type":79,"value":5110},{"type":73,"tag":206,"props":5341,"children":5342},{"style":219},[5343],{"type":79,"value":381},{"type":73,"tag":206,"props":5345,"children":5346},{"style":219},[5347],{"type":79,"value":243},{"type":73,"tag":206,"props":5349,"children":5350},{"style":246},[5351],{"type":79,"value":5352},"Alice",{"type":73,"tag":206,"props":5354,"children":5355},{"style":219},[5356],{"type":79,"value":254},{"type":73,"tag":206,"props":5358,"children":5359},{"style":219},[5360],{"type":79,"value":399},{"type":73,"tag":206,"props":5362,"children":5363},{"style":373},[5364],{"type":79,"value":5127},{"type":73,"tag":206,"props":5366,"children":5367},{"style":219},[5368],{"type":79,"value":381},{"type":73,"tag":206,"props":5370,"children":5371},{"style":219},[5372],{"type":79,"value":243},{"type":73,"tag":206,"props":5374,"children":5375},{"style":246},[5376],{"type":79,"value":5158},{"type":73,"tag":206,"props":5378,"children":5379},{"style":219},[5380],{"type":79,"value":254},{"type":73,"tag":206,"props":5382,"children":5383},{"style":219},[5384],{"type":79,"value":233},{"type":73,"tag":206,"props":5386,"children":5387},{"style":225},[5388],{"type":79,"value":447},{"type":73,"tag":206,"props":5390,"children":5391},{"style":219},[5392],{"type":79,"value":666},{"type":73,"tag":206,"props":5394,"children":5395},{"class":208,"line":515},[5396,5400,5404,5408,5412,5416,5420,5424,5428,5432,5436,5440,5444,5449,5453,5457],{"type":73,"tag":206,"props":5397,"children":5398},{"style":344},[5399],{"type":79,"value":3106},{"type":73,"tag":206,"props":5401,"children":5402},{"style":219},[5403],{"type":79,"value":381},{"type":73,"tag":206,"props":5405,"children":5406},{"style":323},[5407],{"type":79,"value":1762},{"type":73,"tag":206,"props":5409,"children":5410},{"style":219},[5411],{"type":79,"value":1777},{"type":73,"tag":206,"props":5413,"children":5414},{"style":1780},[5415],{"type":79,"value":2862},{"type":73,"tag":206,"props":5417,"children":5418},{"style":219},[5419],{"type":79,"value":399},{"type":73,"tag":206,"props":5421,"children":5422},{"style":1780},[5423],{"type":79,"value":3131},{"type":73,"tag":206,"props":5425,"children":5426},{"style":219},[5427],{"type":79,"value":1801},{"type":73,"tag":206,"props":5429,"children":5430},{"style":323},[5431],{"type":79,"value":2050},{"type":73,"tag":206,"props":5433,"children":5434},{"style":344},[5435],{"type":79,"value":4346},{"type":73,"tag":206,"props":5437,"children":5438},{"style":225},[5439],{"type":79,"value":365},{"type":73,"tag":206,"props":5441,"children":5442},{"style":219},[5443],{"type":79,"value":370},{"type":73,"tag":206,"props":5445,"children":5446},{"style":1117},[5447],{"type":79,"value":5448}," \u002F* ... *\u002F",{"type":73,"tag":206,"props":5450,"children":5451},{"style":219},[5452],{"type":79,"value":233},{"type":73,"tag":206,"props":5454,"children":5455},{"style":225},[5456],{"type":79,"value":447},{"type":73,"tag":206,"props":5458,"children":5459},{"style":219},[5460],{"type":79,"value":666},{"type":73,"tag":206,"props":5462,"children":5463},{"class":208,"line":558},[5464,5468,5472],{"type":73,"tag":206,"props":5465,"children":5466},{"style":219},[5467],{"type":79,"value":827},{"type":73,"tag":206,"props":5469,"children":5470},{"style":225},[5471],{"type":79,"value":447},{"type":73,"tag":206,"props":5473,"children":5474},{"style":219},[5475],{"type":79,"value":259},{"type":73,"tag":695,"props":5477,"children":5479},{"id":5478},"_8-pending-messages-mid-stream-user-input",[5480],{"type":79,"value":5481},"8. Pending messages (mid-stream user input)",{"type":73,"tag":82,"props":5483,"children":5484},{},[5485,5487,5493,5494,5500,5501,5507,5508,5514,5515,5521,5523,5528,5530,5536,5538,5544,5545,5550,5551,5557,5558,5564,5566,5572],{"type":79,"value":5486},"A message sent while a turn is streaming should NOT cancel the stream. Configure\n",{"type":73,"tag":86,"props":5488,"children":5490},{"className":5489},[],[5491],{"type":79,"value":5492},"pendingMessages",{"type":79,"value":620},{"type":73,"tag":86,"props":5495,"children":5497},{"className":5496},[],[5498],{"type":79,"value":5499},"shouldInject",{"type":79,"value":612},{"type":73,"tag":86,"props":5502,"children":5504},{"className":5503},[],[5505],{"type":79,"value":5506},"prepare",{"type":79,"value":612},{"type":73,"tag":86,"props":5509,"children":5511},{"className":5510},[],[5512],{"type":79,"value":5513},"onReceived",{"type":79,"value":612},{"type":73,"tag":86,"props":5516,"children":5518},{"className":5517},[],[5519],{"type":79,"value":5520},"onInjected",{"type":79,"value":5522},") on the agent so the SDK's\nauto-injected ",{"type":73,"tag":86,"props":5524,"children":5526},{"className":5525},[],[5527],{"type":79,"value":2757},{"type":79,"value":5529}," folds them in at the next boundary. On the frontend, ",{"type":73,"tag":86,"props":5531,"children":5533},{"className":5532},[],[5534],{"type":79,"value":5535},"usePendingMessages",{"type":79,"value":5537},"\nreturns ",{"type":73,"tag":86,"props":5539,"children":5541},{"className":5540},[],[5542],{"type":79,"value":5543},"pending",{"type":79,"value":612},{"type":73,"tag":86,"props":5546,"children":5548},{"className":5547},[],[5549],{"type":79,"value":650},{"type":79,"value":612},{"type":73,"tag":86,"props":5552,"children":5554},{"className":5553},[],[5555],{"type":79,"value":5556},"queue(text)",{"type":79,"value":1411},{"type":73,"tag":86,"props":5559,"children":5561},{"className":5560},[],[5562],{"type":79,"value":5563},"promoteToSteering(id)",{"type":79,"value":5565},"; send via\n",{"type":73,"tag":86,"props":5567,"children":5569},{"className":5568},[],[5570],{"type":79,"value":5571},"transport.sendPendingMessage(chatId, uiMessage, metadata?)",{"type":79,"value":175},{"type":73,"tag":695,"props":5574,"children":5576},{"id":5575},"_9-recovery-and-version-upgrades",[5577],{"type":79,"value":5578},"9. Recovery and version upgrades",{"type":73,"tag":82,"props":5580,"children":5581},{},[5582,5588,5590,5595,5597,5603,5605,5610,5612,5618,5620,5626,5628,5633,5635,5640,5641,5647,5649,5655,5657,5663],{"type":73,"tag":86,"props":5583,"children":5585},{"className":5584},[],[5586],{"type":79,"value":5587},"onRecoveryBoot",{"type":79,"value":5589}," fires only when a ",{"type":73,"tag":95,"props":5591,"children":5592},{},[5593],{"type":79,"value":5594},"partial assistant message exists on the tail",{"type":79,"value":5596}," (interrupted\ndeploy, crash, OOM retry). It does NOT fire on ",{"type":73,"tag":86,"props":5598,"children":5600},{"className":5599},[],[5601],{"type":79,"value":5602},"chat.requestUpgrade()",{"type":79,"value":5604},", which is a graceful exit with\nno partial. ",{"type":73,"tag":86,"props":5606,"children":5608},{"className":5607},[],[5609],{"type":79,"value":5602},{"type":79,"value":5611}," (called in ",{"type":73,"tag":86,"props":5613,"children":5615},{"className":5614},[],[5616],{"type":79,"value":5617},"onTurnStart",{"type":79,"value":5619}," \u002F ",{"type":73,"tag":86,"props":5621,"children":5623},{"className":5622},[],[5624],{"type":79,"value":5625},"onValidateMessages",{"type":79,"value":5627}," to skip ",{"type":73,"tag":86,"props":5629,"children":5631},{"className":5630},[],[5632],{"type":79,"value":3737},{"type":79,"value":5634},",\nor in ",{"type":73,"tag":86,"props":5636,"children":5638},{"className":5637},[],[5639],{"type":79,"value":3737},{"type":79,"value":5619},{"type":73,"tag":86,"props":5642,"children":5644},{"className":5643},[],[5645],{"type":79,"value":5646},"chat.defer()",{"type":79,"value":5648}," to exit after the turn) rotates the Session's ",{"type":73,"tag":86,"props":5650,"children":5652},{"className":5651},[],[5653],{"type":79,"value":5654},"currentRunId",{"type":79,"value":5656}," to a run\non the latest deployment without a client reconnect. Pair it with a contract version on ",{"type":73,"tag":86,"props":5658,"children":5660},{"className":5659},[],[5661],{"type":79,"value":5662},"clientData",{"type":79,"value":175},{"type":73,"tag":195,"props":5665,"children":5667},{"className":197,"code":5666,"language":199,"meta":200,"style":200},"const SUPPORTED_VERSIONS = new Set([\"v2\", \"v3\"]);\nonTurnStart: async ({ clientData }) => {\n  if (clientData?.protocolVersion && !SUPPORTED_VERSIONS.has(clientData.protocolVersion)) {\n    chat.requestUpgrade();\n  }\n},\n",[5668],{"type":73,"tag":86,"props":5669,"children":5670},{"__ignoreMap":200},[5671,5738,5773,5847,5871,5879],{"type":73,"tag":206,"props":5672,"children":5673},{"class":208,"line":209},[5674,5678,5683,5687,5691,5696,5700,5704,5709,5713,5717,5721,5726,5730,5734],{"type":73,"tag":206,"props":5675,"children":5676},{"style":323},[5677],{"type":79,"value":326},{"type":73,"tag":206,"props":5679,"children":5680},{"style":225},[5681],{"type":79,"value":5682}," SUPPORTED_VERSIONS ",{"type":73,"tag":206,"props":5684,"children":5685},{"style":219},[5686],{"type":79,"value":336},{"type":73,"tag":206,"props":5688,"children":5689},{"style":219},[5690],{"type":79,"value":341},{"type":73,"tag":206,"props":5692,"children":5693},{"style":344},[5694],{"type":79,"value":5695}," Set",{"type":73,"tag":206,"props":5697,"children":5698},{"style":225},[5699],{"type":79,"value":2986},{"type":73,"tag":206,"props":5701,"children":5702},{"style":219},[5703],{"type":79,"value":254},{"type":73,"tag":206,"props":5705,"children":5706},{"style":246},[5707],{"type":79,"value":5708},"v2",{"type":73,"tag":206,"props":5710,"children":5711},{"style":219},[5712],{"type":79,"value":254},{"type":73,"tag":206,"props":5714,"children":5715},{"style":219},[5716],{"type":79,"value":399},{"type":73,"tag":206,"props":5718,"children":5719},{"style":219},[5720],{"type":79,"value":243},{"type":73,"tag":206,"props":5722,"children":5723},{"style":246},[5724],{"type":79,"value":5725},"v3",{"type":73,"tag":206,"props":5727,"children":5728},{"style":219},[5729],{"type":79,"value":254},{"type":73,"tag":206,"props":5731,"children":5732},{"style":225},[5733],{"type":79,"value":3062},{"type":73,"tag":206,"props":5735,"children":5736},{"style":219},[5737],{"type":79,"value":259},{"type":73,"tag":206,"props":5739,"children":5740},{"class":208,"line":262},[5741,5745,5749,5753,5757,5761,5765,5769],{"type":73,"tag":206,"props":5742,"children":5743},{"style":1270},[5744],{"type":79,"value":5617},{"type":73,"tag":206,"props":5746,"children":5747},{"style":219},[5748],{"type":79,"value":381},{"type":73,"tag":206,"props":5750,"children":5751},{"style":323},[5752],{"type":79,"value":1762},{"type":73,"tag":206,"props":5754,"children":5755},{"style":219},[5756],{"type":79,"value":1777},{"type":73,"tag":206,"props":5758,"children":5759},{"style":1780},[5760],{"type":79,"value":404},{"type":73,"tag":206,"props":5762,"children":5763},{"style":219},[5764],{"type":79,"value":1801},{"type":73,"tag":206,"props":5766,"children":5767},{"style":323},[5768],{"type":79,"value":2050},{"type":73,"tag":206,"props":5770,"children":5771},{"style":219},[5772],{"type":79,"value":1806},{"type":73,"tag":206,"props":5774,"children":5775},{"class":208,"line":309},[5776,5781,5785,5789,5793,5798,5803,5808,5813,5817,5822,5826,5830,5834,5838,5843],{"type":73,"tag":206,"props":5777,"children":5778},{"style":213},[5779],{"type":79,"value":5780},"  if",{"type":73,"tag":206,"props":5782,"children":5783},{"style":373},[5784],{"type":79,"value":620},{"type":73,"tag":206,"props":5786,"children":5787},{"style":225},[5788],{"type":79,"value":5662},{"type":73,"tag":206,"props":5790,"children":5791},{"style":219},[5792],{"type":79,"value":2080},{"type":73,"tag":206,"props":5794,"children":5795},{"style":225},[5796],{"type":79,"value":5797},"protocolVersion",{"type":73,"tag":206,"props":5799,"children":5800},{"style":219},[5801],{"type":79,"value":5802}," &&",{"type":73,"tag":206,"props":5804,"children":5805},{"style":219},[5806],{"type":79,"value":5807}," !",{"type":73,"tag":206,"props":5809,"children":5810},{"style":225},[5811],{"type":79,"value":5812},"SUPPORTED_VERSIONS",{"type":73,"tag":206,"props":5814,"children":5815},{"style":219},[5816],{"type":79,"value":175},{"type":73,"tag":206,"props":5818,"children":5819},{"style":344},[5820],{"type":79,"value":5821},"has",{"type":73,"tag":206,"props":5823,"children":5824},{"style":373},[5825],{"type":79,"value":365},{"type":73,"tag":206,"props":5827,"children":5828},{"style":225},[5829],{"type":79,"value":5662},{"type":73,"tag":206,"props":5831,"children":5832},{"style":219},[5833],{"type":79,"value":175},{"type":73,"tag":206,"props":5835,"children":5836},{"style":225},[5837],{"type":79,"value":5797},{"type":73,"tag":206,"props":5839,"children":5840},{"style":373},[5841],{"type":79,"value":5842},")) ",{"type":73,"tag":206,"props":5844,"children":5845},{"style":219},[5846],{"type":79,"value":858},{"type":73,"tag":206,"props":5848,"children":5849},{"class":208,"line":319},[5850,5854,5858,5863,5867],{"type":73,"tag":206,"props":5851,"children":5852},{"style":225},[5853],{"type":79,"value":2882},{"type":73,"tag":206,"props":5855,"children":5856},{"style":219},[5857],{"type":79,"value":175},{"type":73,"tag":206,"props":5859,"children":5860},{"style":344},[5861],{"type":79,"value":5862},"requestUpgrade",{"type":73,"tag":206,"props":5864,"children":5865},{"style":373},[5866],{"type":79,"value":551},{"type":73,"tag":206,"props":5868,"children":5869},{"style":219},[5870],{"type":79,"value":259},{"type":73,"tag":206,"props":5872,"children":5873},{"class":208,"line":454},[5874],{"type":73,"tag":206,"props":5875,"children":5876},{"style":219},[5877],{"type":79,"value":5878},"  }\n",{"type":73,"tag":206,"props":5880,"children":5881},{"class":208,"line":515},[5882],{"type":73,"tag":206,"props":5883,"children":5884},{"style":219},[5885],{"type":79,"value":3641},{"type":73,"tag":82,"props":5887,"children":5888},{},[5889,5891,5897,5899,5905],{"type":79,"value":5890},"For OOM resilience, set ",{"type":73,"tag":86,"props":5892,"children":5894},{"className":5893},[],[5895],{"type":79,"value":5896},"oomMachine",{"type":79,"value":5898}," (and ",{"type":73,"tag":86,"props":5900,"children":5902},{"className":5901},[],[5903],{"type":79,"value":5904},"machine",{"type":79,"value":5906},") on the agent so retries land on a larger preset.",{"type":73,"tag":695,"props":5908,"children":5910},{"id":5909},"_10-offline-testing-with-mockchatagent",[5911],{"type":79,"value":5912},"10. Offline testing with mockChatAgent",{"type":73,"tag":82,"props":5914,"children":5915},{},[5916,5922,5924,5929,5931,5936,5937,5943,5944,5950,5951,5957,5958,5964,5965,5971,5973,5979,5980,5986,5988,5994,5995,6001,6003,6009,6010,6016],{"type":73,"tag":86,"props":5917,"children":5919},{"className":5918},[],[5920],{"type":79,"value":5921},"@trigger.dev\u002Fsdk\u002Fai\u002Ftest",{"type":79,"value":5923}," runs the real turn loop in-memory. Import it ",{"type":73,"tag":95,"props":5925,"children":5926},{},[5927],{"type":79,"value":5928},"before",{"type":79,"value":5930}," the agent module\nso the resource catalog is installed. Drive with ",{"type":73,"tag":86,"props":5932,"children":5934},{"className":5933},[],[5935],{"type":79,"value":487},{"type":79,"value":612},{"type":73,"tag":86,"props":5938,"children":5940},{"className":5939},[],[5941],{"type":79,"value":5942},"sendRegenerate",{"type":79,"value":612},{"type":73,"tag":86,"props":5945,"children":5947},{"className":5946},[],[5948],{"type":79,"value":5949},"sendAction",{"type":79,"value":666},{"type":73,"tag":86,"props":5952,"children":5954},{"className":5953},[],[5955],{"type":79,"value":5956},"sendStop",{"type":79,"value":612},{"type":73,"tag":86,"props":5959,"children":5961},{"className":5960},[],[5962],{"type":79,"value":5963},"sendHeadStart",{"type":79,"value":612},{"type":73,"tag":86,"props":5966,"children":5968},{"className":5967},[],[5969],{"type":79,"value":5970},"sendHandover",{"type":79,"value":5972},"; seed state with ",{"type":73,"tag":86,"props":5974,"children":5976},{"className":5975},[],[5977],{"type":79,"value":5978},"seedSnapshot",{"type":79,"value":5619},{"type":73,"tag":86,"props":5981,"children":5983},{"className":5982},[],[5984],{"type":79,"value":5985},"seedSessionOutTail",{"type":79,"value":5987}," \u002F\n",{"type":73,"tag":86,"props":5989,"children":5991},{"className":5990},[],[5992],{"type":79,"value":5993},"seedSessionOutPartial",{"type":79,"value":5619},{"type":73,"tag":86,"props":5996,"children":5998},{"className":5997},[],[5999],{"type":79,"value":6000},"seedSessionInTail",{"type":79,"value":6002},"; assert against ",{"type":73,"tag":86,"props":6004,"children":6006},{"className":6005},[],[6007],{"type":79,"value":6008},"turn.chunks",{"type":79,"value":2369},{"type":73,"tag":86,"props":6011,"children":6013},{"className":6012},[],[6014],{"type":79,"value":6015},"harness.allChunks",{"type":79,"value":175},{"type":73,"tag":195,"props":6018,"children":6020},{"className":197,"code":6019,"language":199,"meta":200,"style":200},"import { mockChatAgent } from \"@trigger.dev\u002Fsdk\u002Fai\u002Ftest\"; \u002F\u002F BEFORE the agent module\nimport { myChatAgent } from \".\u002Fmy-chat.js\";\n\nconst harness = mockChatAgent(myChatAgent, { chatId: \"test-1\", clientData: { model } });\ntry {\n  const turn = await harness.sendMessage({ id: \"u1\", role: \"user\", parts: [{ type: \"text\", text: \"hi\" }] });\n  \u002F\u002F assert against turn.chunks\n} finally {\n  await harness.close();\n}\n",[6021],{"type":73,"tag":86,"props":6022,"children":6023},{"__ignoreMap":200},[6024,6069,6110,6117,6208,6220,6394,6402,6418,6446],{"type":73,"tag":206,"props":6025,"children":6026},{"class":208,"line":209},[6027,6031,6035,6040,6044,6048,6052,6056,6060,6064],{"type":73,"tag":206,"props":6028,"children":6029},{"style":213},[6030],{"type":79,"value":216},{"type":73,"tag":206,"props":6032,"children":6033},{"style":219},[6034],{"type":79,"value":222},{"type":73,"tag":206,"props":6036,"children":6037},{"style":225},[6038],{"type":79,"value":6039}," mockChatAgent",{"type":73,"tag":206,"props":6041,"children":6042},{"style":219},[6043],{"type":79,"value":233},{"type":73,"tag":206,"props":6045,"children":6046},{"style":213},[6047],{"type":79,"value":238},{"type":73,"tag":206,"props":6049,"children":6050},{"style":219},[6051],{"type":79,"value":243},{"type":73,"tag":206,"props":6053,"children":6054},{"style":246},[6055],{"type":79,"value":5921},{"type":73,"tag":206,"props":6057,"children":6058},{"style":219},[6059],{"type":79,"value":254},{"type":73,"tag":206,"props":6061,"children":6062},{"style":219},[6063],{"type":79,"value":1114},{"type":73,"tag":206,"props":6065,"children":6066},{"style":1117},[6067],{"type":79,"value":6068}," \u002F\u002F BEFORE the agent module\n",{"type":73,"tag":206,"props":6070,"children":6071},{"class":208,"line":262},[6072,6076,6080,6085,6089,6093,6097,6102,6106],{"type":73,"tag":206,"props":6073,"children":6074},{"style":213},[6075],{"type":79,"value":216},{"type":73,"tag":206,"props":6077,"children":6078},{"style":219},[6079],{"type":79,"value":222},{"type":73,"tag":206,"props":6081,"children":6082},{"style":225},[6083],{"type":79,"value":6084}," myChatAgent",{"type":73,"tag":206,"props":6086,"children":6087},{"style":219},[6088],{"type":79,"value":233},{"type":73,"tag":206,"props":6090,"children":6091},{"style":213},[6092],{"type":79,"value":238},{"type":73,"tag":206,"props":6094,"children":6095},{"style":219},[6096],{"type":79,"value":243},{"type":73,"tag":206,"props":6098,"children":6099},{"style":246},[6100],{"type":79,"value":6101},".\u002Fmy-chat.js",{"type":73,"tag":206,"props":6103,"children":6104},{"style":219},[6105],{"type":79,"value":254},{"type":73,"tag":206,"props":6107,"children":6108},{"style":219},[6109],{"type":79,"value":259},{"type":73,"tag":206,"props":6111,"children":6112},{"class":208,"line":309},[6113],{"type":73,"tag":206,"props":6114,"children":6115},{"emptyLinePlaceholder":313},[6116],{"type":79,"value":316},{"type":73,"tag":206,"props":6118,"children":6119},{"class":208,"line":319},[6120,6124,6129,6133,6137,6142,6146,6150,6154,6158,6162,6167,6171,6175,6179,6183,6187,6192,6196,6200,6204],{"type":73,"tag":206,"props":6121,"children":6122},{"style":323},[6123],{"type":79,"value":326},{"type":73,"tag":206,"props":6125,"children":6126},{"style":225},[6127],{"type":79,"value":6128}," harness ",{"type":73,"tag":206,"props":6130,"children":6131},{"style":219},[6132],{"type":79,"value":336},{"type":73,"tag":206,"props":6134,"children":6135},{"style":344},[6136],{"type":79,"value":6039},{"type":73,"tag":206,"props":6138,"children":6139},{"style":225},[6140],{"type":79,"value":6141},"(myChatAgent",{"type":73,"tag":206,"props":6143,"children":6144},{"style":219},[6145],{"type":79,"value":399},{"type":73,"tag":206,"props":6147,"children":6148},{"style":219},[6149],{"type":79,"value":222},{"type":73,"tag":206,"props":6151,"children":6152},{"style":373},[6153],{"type":79,"value":903},{"type":73,"tag":206,"props":6155,"children":6156},{"style":219},[6157],{"type":79,"value":381},{"type":73,"tag":206,"props":6159,"children":6160},{"style":219},[6161],{"type":79,"value":243},{"type":73,"tag":206,"props":6163,"children":6164},{"style":246},[6165],{"type":79,"value":6166},"test-1",{"type":73,"tag":206,"props":6168,"children":6169},{"style":219},[6170],{"type":79,"value":254},{"type":73,"tag":206,"props":6172,"children":6173},{"style":219},[6174],{"type":79,"value":399},{"type":73,"tag":206,"props":6176,"children":6177},{"style":373},[6178],{"type":79,"value":404},{"type":73,"tag":206,"props":6180,"children":6181},{"style":219},[6182],{"type":79,"value":381},{"type":73,"tag":206,"props":6184,"children":6185},{"style":219},[6186],{"type":79,"value":222},{"type":73,"tag":206,"props":6188,"children":6189},{"style":225},[6190],{"type":79,"value":6191}," model ",{"type":73,"tag":206,"props":6193,"children":6194},{"style":219},[6195],{"type":79,"value":827},{"type":73,"tag":206,"props":6197,"children":6198},{"style":219},[6199],{"type":79,"value":233},{"type":73,"tag":206,"props":6201,"children":6202},{"style":225},[6203],{"type":79,"value":447},{"type":73,"tag":206,"props":6205,"children":6206},{"style":219},[6207],{"type":79,"value":259},{"type":73,"tag":206,"props":6209,"children":6210},{"class":208,"line":454},[6211,6216],{"type":73,"tag":206,"props":6212,"children":6213},{"style":213},[6214],{"type":79,"value":6215},"try",{"type":73,"tag":206,"props":6217,"children":6218},{"style":219},[6219],{"type":79,"value":1806},{"type":73,"tag":206,"props":6221,"children":6222},{"class":208,"line":515},[6223,6228,6233,6237,6241,6246,6250,6254,6258,6262,6266,6270,6274,6279,6283,6287,6291,6295,6299,6303,6307,6311,6316,6320,6324,6328,6332,6336,6340,6344,6348,6352,6356,6360,6364,6369,6373,6377,6382,6386,6390],{"type":73,"tag":206,"props":6224,"children":6225},{"style":323},[6226],{"type":79,"value":6227},"  const",{"type":73,"tag":206,"props":6229,"children":6230},{"style":225},[6231],{"type":79,"value":6232}," turn",{"type":73,"tag":206,"props":6234,"children":6235},{"style":219},[6236],{"type":79,"value":832},{"type":73,"tag":206,"props":6238,"children":6239},{"style":213},[6240],{"type":79,"value":473},{"type":73,"tag":206,"props":6242,"children":6243},{"style":225},[6244],{"type":79,"value":6245}," harness",{"type":73,"tag":206,"props":6247,"children":6248},{"style":219},[6249],{"type":79,"value":175},{"type":73,"tag":206,"props":6251,"children":6252},{"style":344},[6253],{"type":79,"value":487},{"type":73,"tag":206,"props":6255,"children":6256},{"style":373},[6257],{"type":79,"value":365},{"type":73,"tag":206,"props":6259,"children":6260},{"style":219},[6261],{"type":79,"value":370},{"type":73,"tag":206,"props":6263,"children":6264},{"style":373},[6265],{"type":79,"value":813},{"type":73,"tag":206,"props":6267,"children":6268},{"style":219},[6269],{"type":79,"value":381},{"type":73,"tag":206,"props":6271,"children":6272},{"style":219},[6273],{"type":79,"value":243},{"type":73,"tag":206,"props":6275,"children":6276},{"style":246},[6277],{"type":79,"value":6278},"u1",{"type":73,"tag":206,"props":6280,"children":6281},{"style":219},[6282],{"type":79,"value":254},{"type":73,"tag":206,"props":6284,"children":6285},{"style":219},[6286],{"type":79,"value":399},{"type":73,"tag":206,"props":6288,"children":6289},{"style":373},[6290],{"type":79,"value":2995},{"type":73,"tag":206,"props":6292,"children":6293},{"style":219},[6294],{"type":79,"value":381},{"type":73,"tag":206,"props":6296,"children":6297},{"style":219},[6298],{"type":79,"value":243},{"type":73,"tag":206,"props":6300,"children":6301},{"style":246},[6302],{"type":79,"value":3567},{"type":73,"tag":206,"props":6304,"children":6305},{"style":219},[6306],{"type":79,"value":254},{"type":73,"tag":206,"props":6308,"children":6309},{"style":219},[6310],{"type":79,"value":399},{"type":73,"tag":206,"props":6312,"children":6313},{"style":373},[6314],{"type":79,"value":6315}," parts",{"type":73,"tag":206,"props":6317,"children":6318},{"style":219},[6319],{"type":79,"value":381},{"type":73,"tag":206,"props":6321,"children":6322},{"style":373},[6323],{"type":79,"value":965},{"type":73,"tag":206,"props":6325,"children":6326},{"style":219},[6327],{"type":79,"value":370},{"type":73,"tag":206,"props":6329,"children":6330},{"style":373},[6331],{"type":79,"value":272},{"type":73,"tag":206,"props":6333,"children":6334},{"style":219},[6335],{"type":79,"value":381},{"type":73,"tag":206,"props":6337,"children":6338},{"style":219},[6339],{"type":79,"value":243},{"type":73,"tag":206,"props":6341,"children":6342},{"style":246},[6343],{"type":79,"value":79},{"type":73,"tag":206,"props":6345,"children":6346},{"style":219},[6347],{"type":79,"value":254},{"type":73,"tag":206,"props":6349,"children":6350},{"style":219},[6351],{"type":79,"value":399},{"type":73,"tag":206,"props":6353,"children":6354},{"style":373},[6355],{"type":79,"value":1190},{"type":73,"tag":206,"props":6357,"children":6358},{"style":219},[6359],{"type":79,"value":381},{"type":73,"tag":206,"props":6361,"children":6362},{"style":219},[6363],{"type":79,"value":243},{"type":73,"tag":206,"props":6365,"children":6366},{"style":246},[6367],{"type":79,"value":6368},"hi",{"type":73,"tag":206,"props":6370,"children":6371},{"style":219},[6372],{"type":79,"value":254},{"type":73,"tag":206,"props":6374,"children":6375},{"style":219},[6376],{"type":79,"value":233},{"type":73,"tag":206,"props":6378,"children":6379},{"style":373},[6380],{"type":79,"value":6381},"] ",{"type":73,"tag":206,"props":6383,"children":6384},{"style":219},[6385],{"type":79,"value":827},{"type":73,"tag":206,"props":6387,"children":6388},{"style":373},[6389],{"type":79,"value":447},{"type":73,"tag":206,"props":6391,"children":6392},{"style":219},[6393],{"type":79,"value":259},{"type":73,"tag":206,"props":6395,"children":6396},{"class":208,"line":558},[6397],{"type":73,"tag":206,"props":6398,"children":6399},{"style":1117},[6400],{"type":79,"value":6401},"  \u002F\u002F assert against turn.chunks\n",{"type":73,"tag":206,"props":6403,"children":6404},{"class":208,"line":1053},[6405,6409,6414],{"type":73,"tag":206,"props":6406,"children":6407},{"style":219},[6408],{"type":79,"value":827},{"type":73,"tag":206,"props":6410,"children":6411},{"style":213},[6412],{"type":79,"value":6413}," finally",{"type":73,"tag":206,"props":6415,"children":6416},{"style":219},[6417],{"type":79,"value":1806},{"type":73,"tag":206,"props":6419,"children":6420},{"class":208,"line":1069},[6421,6426,6430,6434,6438,6442],{"type":73,"tag":206,"props":6422,"children":6423},{"style":213},[6424],{"type":79,"value":6425},"  await",{"type":73,"tag":206,"props":6427,"children":6428},{"style":225},[6429],{"type":79,"value":6245},{"type":73,"tag":206,"props":6431,"children":6432},{"style":219},[6433],{"type":79,"value":175},{"type":73,"tag":206,"props":6435,"children":6436},{"style":344},[6437],{"type":79,"value":577},{"type":73,"tag":206,"props":6439,"children":6440},{"style":373},[6441],{"type":79,"value":551},{"type":73,"tag":206,"props":6443,"children":6444},{"style":219},[6445],{"type":79,"value":259},{"type":73,"tag":206,"props":6447,"children":6448},{"class":208,"line":1077},[6449],{"type":73,"tag":206,"props":6450,"children":6451},{"style":219},[6452],{"type":79,"value":6453},"}\n",{"type":73,"tag":82,"props":6455,"children":6456},{},[6457,6459,6465,6466,6472,6474,6479,6480,6486,6487,6493,6494,6500,6501,6507,6508,6514,6516,6522,6524,6530],{"type":79,"value":6458},"Options include ",{"type":73,"tag":86,"props":6460,"children":6462},{"className":6461},[],[6463],{"type":79,"value":6464},"mode",{"type":79,"value":620},{"type":73,"tag":86,"props":6467,"children":6469},{"className":6468},[],[6470],{"type":79,"value":6471},"\"preload\" | \"submit-message\" | \"handover-prepare\" | \"continuation\"",{"type":79,"value":6473},"),\n",{"type":73,"tag":86,"props":6475,"children":6477},{"className":6476},[],[6478],{"type":79,"value":1037},{"type":79,"value":612},{"type":73,"tag":86,"props":6481,"children":6483},{"className":6482},[],[6484],{"type":79,"value":6485},"continuation",{"type":79,"value":612},{"type":73,"tag":86,"props":6488,"children":6490},{"className":6489},[],[6491],{"type":79,"value":6492},"previousRunId",{"type":79,"value":612},{"type":73,"tag":86,"props":6495,"children":6497},{"className":6496},[],[6498],{"type":79,"value":6499},"snapshot",{"type":79,"value":612},{"type":73,"tag":86,"props":6502,"children":6504},{"className":6503},[],[6505],{"type":79,"value":6506},"taskContext",{"type":79,"value":1411},{"type":73,"tag":86,"props":6509,"children":6511},{"className":6510},[],[6512],{"type":79,"value":6513},"setupLocals",{"type":79,"value":6515},". Set\n",{"type":73,"tag":86,"props":6517,"children":6519},{"className":6518},[],[6520],{"type":79,"value":6521},"taskContext.ctx.attempt.number > 1",{"type":79,"value":6523}," to simulate an OOM-retry attempt. ",{"type":73,"tag":86,"props":6525,"children":6527},{"className":6526},[],[6528],{"type":79,"value":6529},"runInMockTaskContext",{"type":79,"value":6531}," drives a\nnon-chat task offline.",{"type":73,"tag":695,"props":6533,"children":6535},{"id":6534},"_11-custom-transport-the-wire-protocol",[6536],{"type":79,"value":6537},"11. Custom transport: the wire protocol",{"type":73,"tag":82,"props":6539,"children":6540},{},[6541,6543,6549,6551,6557,6559,6565,6566,6572,6573,6579,6581,6587,6589,6595,6597,6602,6603,6609,6610,6616,6617,6623,6624,6630,6631,6637,6638,6644,6645,6651,6653,6659,6661,6667,6668,6674,6676,6682,6684,6690,6691,6697,6699,6704],{"type":79,"value":6542},"Endpoints: ",{"type":73,"tag":86,"props":6544,"children":6546},{"className":6545},[],[6547],{"type":79,"value":6548},"POST \u002Fapi\u002Fv1\u002Fsessions",{"type":79,"value":6550}," (create), ",{"type":73,"tag":86,"props":6552,"children":6554},{"className":6553},[],[6555],{"type":79,"value":6556},"GET \u002Frealtime\u002Fv1\u002Fsessions\u002F{id}\u002Fout",{"type":79,"value":6558}," (SSE),\n",{"type":73,"tag":86,"props":6560,"children":6562},{"className":6561},[],[6563],{"type":79,"value":6564},"POST \u002Frealtime\u002Fv1\u002Fsessions\u002F{id}\u002Fin\u002Fappend",{"type":79,"value":612},{"type":73,"tag":86,"props":6567,"children":6569},{"className":6568},[],[6570],{"type":79,"value":6571},"POST \u002Fapi\u002Fv1\u002Fsessions\u002F{id}\u002Fclose",{"type":79,"value":1368},{"type":73,"tag":86,"props":6574,"children":6576},{"className":6575},[],[6577],{"type":79,"value":6578},"ChatInputChunk",{"type":79,"value":6580}," is\n",{"type":73,"tag":86,"props":6582,"children":6584},{"className":6583},[],[6585],{"type":79,"value":6586},"{ kind: \"message\"; payload: ChatTaskWirePayload } | { kind: \"stop\"; message? }",{"type":79,"value":6588},". The\n",{"type":73,"tag":86,"props":6590,"children":6592},{"className":6591},[],[6593],{"type":79,"value":6594},"ChatTaskWirePayload",{"type":79,"value":6596}," carries ",{"type":73,"tag":86,"props":6598,"children":6600},{"className":6599},[],[6601],{"type":79,"value":115},{"type":79,"value":612},{"type":73,"tag":86,"props":6604,"children":6606},{"className":6605},[],[6607],{"type":79,"value":6608},"trigger",{"type":79,"value":620},{"type":73,"tag":86,"props":6611,"children":6613},{"className":6612},[],[6614],{"type":79,"value":6615},"submit-message | regenerate-message | preload | close | action | handover-prepare",{"type":79,"value":628},{"type":73,"tag":86,"props":6618,"children":6620},{"className":6619},[],[6621],{"type":79,"value":6622},"message?",{"type":79,"value":612},{"type":73,"tag":86,"props":6625,"children":6627},{"className":6626},[],[6628],{"type":79,"value":6629},"metadata?",{"type":79,"value":612},{"type":73,"tag":86,"props":6632,"children":6634},{"className":6633},[],[6635],{"type":79,"value":6636},"action?",{"type":79,"value":612},{"type":73,"tag":86,"props":6639,"children":6641},{"className":6640},[],[6642],{"type":79,"value":6643},"continuation?",{"type":79,"value":666},{"type":73,"tag":86,"props":6646,"children":6648},{"className":6647},[],[6649],{"type":79,"value":6650},"previousRunId?",{"type":79,"value":6652},", and more. Control records are header-form: ",{"type":73,"tag":86,"props":6654,"children":6656},{"className":6655},[],[6657],{"type":79,"value":6658},"trigger-control: turn-complete",{"type":79,"value":6660}," (with\noptional ",{"type":73,"tag":86,"props":6662,"children":6664},{"className":6663},[],[6665],{"type":79,"value":6666},"public-access-token",{"type":79,"value":612},{"type":73,"tag":86,"props":6669,"children":6671},{"className":6670},[],[6672],{"type":79,"value":6673},"session-in-event-id",{"type":79,"value":6675},") and ",{"type":73,"tag":86,"props":6677,"children":6679},{"className":6678},[],[6680],{"type":79,"value":6681},"trigger-control: upgrade-required",{"type":79,"value":6683},". The\nTS helpers ",{"type":73,"tag":86,"props":6685,"children":6687},{"className":6686},[],[6688],{"type":79,"value":6689},"SSEStreamSubscription",{"type":79,"value":2369},{"type":73,"tag":86,"props":6692,"children":6694},{"className":6693},[],[6695],{"type":79,"value":6696},"controlSubtype(headers)",{"type":79,"value":6698}," (documented in\n",{"type":73,"tag":86,"props":6700,"children":6702},{"className":6701},[],[6703],{"type":79,"value":51},{"type":79,"value":6705},") handle batch decoding and control-record filtering for you.",{"type":73,"tag":177,"props":6707,"children":6709},{"id":6708},"common-mistakes",[6710],{"type":79,"value":6711},"Common mistakes",{"type":73,"tag":6713,"props":6714,"children":6715},"ul",{},[6716,7032,7071,7116,7153,7192,7231,7254,7280],{"type":73,"tag":6717,"props":6718,"children":6719},"li",{},[6720,6731],{"type":73,"tag":95,"props":6721,"children":6722},{},[6723,6725,6730],{"type":79,"value":6724},"CRITICAL: sending a follow-up by re-POSTing ",{"type":73,"tag":86,"props":6726,"children":6728},{"className":6727},[],[6729],{"type":79,"value":6548},{"type":79,"value":175},{"type":73,"tag":195,"props":6732,"children":6734},{"className":197,"code":6733,"language":199,"meta":200,"style":200},"\u002F\u002F Wrong - a cached re-POST silently drops basePayload.message; basePayload is trigger config, not a channel\nawait fetch(\"\u002Fapi\u002Fv1\u002Fsessions\", { method: \"POST\", body: JSON.stringify({ ...createBody }) });\n\u002F\u002F Correct - append to the session's input channel\nawait fetch(`\u002Frealtime\u002Fv1\u002Fsessions\u002F${id}\u002Fin\u002Fappend`, { method: \"POST\", body: JSON.stringify({ kind: \"message\", payload }) });\n",[6735],{"type":73,"tag":86,"props":6736,"children":6737},{"__ignoreMap":200},[6738,6746,6869,6877],{"type":73,"tag":206,"props":6739,"children":6740},{"class":208,"line":209},[6741],{"type":73,"tag":206,"props":6742,"children":6743},{"style":1117},[6744],{"type":79,"value":6745},"\u002F\u002F Wrong - a cached re-POST silently drops basePayload.message; basePayload is trigger config, not a channel\n",{"type":73,"tag":206,"props":6747,"children":6748},{"class":208,"line":262},[6749,6753,6758,6762,6766,6771,6775,6779,6783,6788,6792,6796,6801,6805,6809,6814,6818,6823,6827,6832,6836,6840,6844,6849,6853,6857,6861,6865],{"type":73,"tag":206,"props":6750,"children":6751},{"style":213},[6752],{"type":79,"value":564},{"type":73,"tag":206,"props":6754,"children":6755},{"style":344},[6756],{"type":79,"value":6757}," fetch",{"type":73,"tag":206,"props":6759,"children":6760},{"style":225},[6761],{"type":79,"value":365},{"type":73,"tag":206,"props":6763,"children":6764},{"style":219},[6765],{"type":79,"value":254},{"type":73,"tag":206,"props":6767,"children":6768},{"style":246},[6769],{"type":79,"value":6770},"\u002Fapi\u002Fv1\u002Fsessions",{"type":73,"tag":206,"props":6772,"children":6773},{"style":219},[6774],{"type":79,"value":254},{"type":73,"tag":206,"props":6776,"children":6777},{"style":219},[6778],{"type":79,"value":399},{"type":73,"tag":206,"props":6780,"children":6781},{"style":219},[6782],{"type":79,"value":222},{"type":73,"tag":206,"props":6784,"children":6785},{"style":373},[6786],{"type":79,"value":6787}," method",{"type":73,"tag":206,"props":6789,"children":6790},{"style":219},[6791],{"type":79,"value":381},{"type":73,"tag":206,"props":6793,"children":6794},{"style":219},[6795],{"type":79,"value":243},{"type":73,"tag":206,"props":6797,"children":6798},{"style":246},[6799],{"type":79,"value":6800},"POST",{"type":73,"tag":206,"props":6802,"children":6803},{"style":219},[6804],{"type":79,"value":254},{"type":73,"tag":206,"props":6806,"children":6807},{"style":219},[6808],{"type":79,"value":399},{"type":73,"tag":206,"props":6810,"children":6811},{"style":373},[6812],{"type":79,"value":6813}," body",{"type":73,"tag":206,"props":6815,"children":6816},{"style":219},[6817],{"type":79,"value":381},{"type":73,"tag":206,"props":6819,"children":6820},{"style":225},[6821],{"type":79,"value":6822}," JSON",{"type":73,"tag":206,"props":6824,"children":6825},{"style":219},[6826],{"type":79,"value":175},{"type":73,"tag":206,"props":6828,"children":6829},{"style":344},[6830],{"type":79,"value":6831},"stringify",{"type":73,"tag":206,"props":6833,"children":6834},{"style":225},[6835],{"type":79,"value":365},{"type":73,"tag":206,"props":6837,"children":6838},{"style":219},[6839],{"type":79,"value":370},{"type":73,"tag":206,"props":6841,"children":6842},{"style":219},[6843],{"type":79,"value":3160},{"type":73,"tag":206,"props":6845,"children":6846},{"style":225},[6847],{"type":79,"value":6848},"createBody ",{"type":73,"tag":206,"props":6850,"children":6851},{"style":219},[6852],{"type":79,"value":827},{"type":73,"tag":206,"props":6854,"children":6855},{"style":225},[6856],{"type":79,"value":2171},{"type":73,"tag":206,"props":6858,"children":6859},{"style":219},[6860],{"type":79,"value":827},{"type":73,"tag":206,"props":6862,"children":6863},{"style":225},[6864],{"type":79,"value":447},{"type":73,"tag":206,"props":6866,"children":6867},{"style":219},[6868],{"type":79,"value":259},{"type":73,"tag":206,"props":6870,"children":6871},{"class":208,"line":309},[6872],{"type":73,"tag":206,"props":6873,"children":6874},{"style":1117},[6875],{"type":79,"value":6876},"\u002F\u002F Correct - append to the session's input channel\n",{"type":73,"tag":206,"props":6878,"children":6879},{"class":208,"line":319},[6880,6884,6888,6892,6896,6901,6905,6910,6914,6919,6923,6927,6931,6935,6939,6943,6947,6951,6955,6959,6963,6967,6971,6975,6979,6983,6987,6991,6995,6999,7003,7007,7012,7016,7020,7024,7028],{"type":73,"tag":206,"props":6881,"children":6882},{"style":213},[6883],{"type":79,"value":564},{"type":73,"tag":206,"props":6885,"children":6886},{"style":344},[6887],{"type":79,"value":6757},{"type":73,"tag":206,"props":6889,"children":6890},{"style":225},[6891],{"type":79,"value":365},{"type":73,"tag":206,"props":6893,"children":6894},{"style":219},[6895],{"type":79,"value":970},{"type":73,"tag":206,"props":6897,"children":6898},{"style":246},[6899],{"type":79,"value":6900},"\u002Frealtime\u002Fv1\u002Fsessions\u002F",{"type":73,"tag":206,"props":6902,"children":6903},{"style":219},[6904],{"type":79,"value":980},{"type":73,"tag":206,"props":6906,"children":6907},{"style":225},[6908],{"type":79,"value":6909},"id",{"type":73,"tag":206,"props":6911,"children":6912},{"style":219},[6913],{"type":79,"value":827},{"type":73,"tag":206,"props":6915,"children":6916},{"style":246},[6917],{"type":79,"value":6918},"\u002Fin\u002Fappend",{"type":73,"tag":206,"props":6920,"children":6921},{"style":219},[6922],{"type":79,"value":970},{"type":73,"tag":206,"props":6924,"children":6925},{"style":219},[6926],{"type":79,"value":399},{"type":73,"tag":206,"props":6928,"children":6929},{"style":219},[6930],{"type":79,"value":222},{"type":73,"tag":206,"props":6932,"children":6933},{"style":373},[6934],{"type":79,"value":6787},{"type":73,"tag":206,"props":6936,"children":6937},{"style":219},[6938],{"type":79,"value":381},{"type":73,"tag":206,"props":6940,"children":6941},{"style":219},[6942],{"type":79,"value":243},{"type":73,"tag":206,"props":6944,"children":6945},{"style":246},[6946],{"type":79,"value":6800},{"type":73,"tag":206,"props":6948,"children":6949},{"style":219},[6950],{"type":79,"value":254},{"type":73,"tag":206,"props":6952,"children":6953},{"style":219},[6954],{"type":79,"value":399},{"type":73,"tag":206,"props":6956,"children":6957},{"style":373},[6958],{"type":79,"value":6813},{"type":73,"tag":206,"props":6960,"children":6961},{"style":219},[6962],{"type":79,"value":381},{"type":73,"tag":206,"props":6964,"children":6965},{"style":225},[6966],{"type":79,"value":6822},{"type":73,"tag":206,"props":6968,"children":6969},{"style":219},[6970],{"type":79,"value":175},{"type":73,"tag":206,"props":6972,"children":6973},{"style":344},[6974],{"type":79,"value":6831},{"type":73,"tag":206,"props":6976,"children":6977},{"style":225},[6978],{"type":79,"value":365},{"type":73,"tag":206,"props":6980,"children":6981},{"style":219},[6982],{"type":79,"value":370},{"type":73,"tag":206,"props":6984,"children":6985},{"style":373},[6986],{"type":79,"value":1164},{"type":73,"tag":206,"props":6988,"children":6989},{"style":219},[6990],{"type":79,"value":381},{"type":73,"tag":206,"props":6992,"children":6993},{"style":219},[6994],{"type":79,"value":243},{"type":73,"tag":206,"props":6996,"children":6997},{"style":246},[6998],{"type":79,"value":1177},{"type":73,"tag":206,"props":7000,"children":7001},{"style":219},[7002],{"type":79,"value":254},{"type":73,"tag":206,"props":7004,"children":7005},{"style":219},[7006],{"type":79,"value":399},{"type":73,"tag":206,"props":7008,"children":7009},{"style":225},[7010],{"type":79,"value":7011}," payload ",{"type":73,"tag":206,"props":7013,"children":7014},{"style":219},[7015],{"type":79,"value":827},{"type":73,"tag":206,"props":7017,"children":7018},{"style":225},[7019],{"type":79,"value":2171},{"type":73,"tag":206,"props":7021,"children":7022},{"style":219},[7023],{"type":79,"value":827},{"type":73,"tag":206,"props":7025,"children":7026},{"style":225},[7027],{"type":79,"value":447},{"type":73,"tag":206,"props":7029,"children":7030},{"style":219},[7031],{"type":79,"value":259},{"type":73,"tag":6717,"props":7033,"children":7034},{},[7035,7053,7055,7061,7063,7069],{"type":73,"tag":95,"props":7036,"children":7037},{},[7038,7040,7046,7047,7052],{"type":79,"value":7039},"Using the wrong token for ",{"type":73,"tag":86,"props":7041,"children":7043},{"className":7042},[],[7044],{"type":79,"value":7045},".in",{"type":79,"value":5619},{"type":73,"tag":86,"props":7048,"children":7050},{"className":7049},[],[7051],{"type":79,"value":1374},{"type":79,"value":175},{"type":79,"value":7054}," Use ",{"type":73,"tag":86,"props":7056,"children":7058},{"className":7057},[],[7059],{"type":79,"value":7060},"publicAccessToken",{"type":79,"value":7062}," from the create response\nbody (session-scoped). The ",{"type":73,"tag":86,"props":7064,"children":7066},{"className":7065},[],[7067],{"type":79,"value":7068},"x-trigger-jwt",{"type":79,"value":7070}," response header is run-scoped and cannot subscribe.",{"type":73,"tag":6717,"props":7072,"children":7073},{},[7074,7093,7095,7100,7102,7108,7110,7115],{"type":73,"tag":95,"props":7075,"children":7076},{},[7077,7079,7085,7087,7092],{"type":79,"value":7078},"Initializing ",{"type":73,"tag":86,"props":7080,"children":7082},{"className":7081},[],[7083],{"type":79,"value":7084},"chat.local",{"type":79,"value":7086}," in ",{"type":73,"tag":86,"props":7088,"children":7090},{"className":7089},[],[7091],{"type":79,"value":5063},{"type":79,"value":175},{"type":79,"value":7094}," It is skipped on continuation runs, so ",{"type":73,"tag":86,"props":7096,"children":7098},{"className":7097},[],[7099],{"type":79,"value":3737},{"type":79,"value":7101},"\ncrashes with ",{"type":73,"tag":86,"props":7103,"children":7105},{"className":7104},[],[7106],{"type":79,"value":7107},"chat.local can only be modified after initialization",{"type":79,"value":7109},". Init in ",{"type":73,"tag":86,"props":7111,"children":7113},{"className":7112},[],[7114],{"type":79,"value":5055},{"type":79,"value":175},{"type":73,"tag":6717,"props":7117,"children":7118},{},[7119,7130,7132,7138,7139,7144,7146,7151],{"type":73,"tag":95,"props":7120,"children":7121},{},[7122,7128],{"type":73,"tag":86,"props":7123,"children":7125},{"className":7124},[],[7126],{"type":79,"value":7127},"chat.defer",{"type":79,"value":7129}," for the message-history write.",{"type":79,"value":7131}," A mid-stream refresh would read ",{"type":73,"tag":86,"props":7133,"children":7135},{"className":7134},[],[7136],{"type":79,"value":7137},"[]",{"type":79,"value":1368},{"type":73,"tag":86,"props":7140,"children":7142},{"className":7141},[],[7143],{"type":79,"value":564},{"type":79,"value":7145}," that\nwrite inline before the model streams; reserve ",{"type":73,"tag":86,"props":7147,"children":7149},{"className":7148},[],[7150],{"type":79,"value":7127},{"type":79,"value":7152}," for analytics, audit, cache warming.",{"type":73,"tag":6717,"props":7154,"children":7155},{},[7156,7168,7170,7176,7178,7184,7185,7191],{"type":73,"tag":95,"props":7157,"children":7158},{},[7159,7161,7167],{"type":79,"value":7160},"Giving the HITL tool an ",{"type":73,"tag":86,"props":7162,"children":7164},{"className":7163},[],[7165],{"type":79,"value":7166},"execute",{"type":79,"value":175},{"type":79,"value":7169}," ",{"type":73,"tag":86,"props":7171,"children":7173},{"className":7172},[],[7174],{"type":79,"value":7175},"streamText",{"type":79,"value":7177}," calls it immediately. Leave it execute-less;\nthe frontend supplies the answer via ",{"type":73,"tag":86,"props":7179,"children":7181},{"className":7180},[],[7182],{"type":79,"value":7183},"addToolOutput",{"type":79,"value":4506},{"type":73,"tag":86,"props":7186,"children":7188},{"className":7187},[],[7189],{"type":79,"value":7190},"sendAutomaticallyWhen",{"type":79,"value":175},{"type":73,"tag":6717,"props":7193,"children":7194},{},[7195,7206,7208,7214,7216,7222,7224,7229],{"type":73,"tag":95,"props":7196,"children":7197},{},[7198,7200,7205],{"type":79,"value":7199},"Declaring sub-agent \u002F heavy tools only on ",{"type":73,"tag":86,"props":7201,"children":7203},{"className":7202},[],[7204],{"type":79,"value":7175},{"type":79,"value":175},{"type":79,"value":7207}," Also declare them on\n",{"type":73,"tag":86,"props":7209,"children":7211},{"className":7210},[],[7212],{"type":79,"value":7213},"chat.agent({ tools })",{"type":79,"value":7215}," (or pass to ",{"type":73,"tag":86,"props":7217,"children":7219},{"className":7218},[],[7220],{"type":79,"value":7221},"convertToModelMessages(uiMessages, { tools })",{"type":79,"value":7223}," in a custom\nagent) so ",{"type":73,"tag":86,"props":7225,"children":7227},{"className":7226},[],[7228],{"type":79,"value":1480},{"type":79,"value":7230}," re-applies on every turn.",{"type":73,"tag":6717,"props":7232,"children":7233},{},[7234,7239,7241,7246,7247,7252],{"type":73,"tag":95,"props":7235,"children":7236},{},[7237],{"type":79,"value":7238},"Importing heavy-execute tools into the Head Start route module.",{"type":79,"value":7240}," This is a build-time import\nchain problem; runtime strip helpers do not fix it. Keep schemas in an ",{"type":73,"tag":86,"props":7242,"children":7244},{"className":7243},[],[7245],{"type":79,"value":27},{"type":79,"value":4506},{"type":73,"tag":86,"props":7248,"children":7250},{"className":7249},[],[7251],{"type":79,"value":1601},{"type":79,"value":7253},"-only module.",{"type":73,"tag":6717,"props":7255,"children":7256},{},[7257,7262,7264,7270,7272,7278],{"type":73,"tag":95,"props":7258,"children":7259},{},[7260],{"type":79,"value":7261},"Returning a megabyte tool output on the stream.",{"type":79,"value":7263}," One ",{"type":73,"tag":86,"props":7265,"children":7267},{"className":7266},[],[7268],{"type":79,"value":7269},"tool-output-available",{"type":79,"value":7271}," record over ~1 MiB\nthrows ",{"type":73,"tag":86,"props":7273,"children":7275},{"className":7274},[],[7276],{"type":79,"value":7277},"ChatChunkTooLargeError",{"type":79,"value":7279},". Persist to your store, write the row first, then emit only an id.",{"type":73,"tag":6717,"props":7281,"children":7282},{},[7283,7296],{"type":73,"tag":95,"props":7284,"children":7285},{},[7286,7288,7294],{"type":79,"value":7287},"Setting ",{"type":73,"tag":86,"props":7289,"children":7291},{"className":7290},[],[7292],{"type":79,"value":7293},"X-Peek-Settled: 1",{"type":79,"value":7295}," on the active-send path.",{"type":79,"value":7297}," It races the new turn's first chunk and\ncloses the stream early. Use it only on reconnect-on-reload paths.",{"type":73,"tag":7299,"props":7300,"children":7301},"blockquote",{},[7302,7337],{"type":73,"tag":82,"props":7303,"children":7304},{},[7305,7307,7313,7315,7320,7322,7328,7330,7336],{"type":79,"value":7306},"Note on docs vocabulary: agent-side examples in some docs still use the legacy\n",{"type":73,"tag":86,"props":7308,"children":7310},{"className":7309},[],[7311],{"type":79,"value":7312},"trigger:turn-complete",{"type":79,"value":7314}," chunk type. That is the agent-emit vocabulary. A custom ",{"type":73,"tag":95,"props":7316,"children":7317},{},[7318],{"type":79,"value":7319},"reader",{"type":79,"value":7321}," must\nfilter on the ",{"type":73,"tag":86,"props":7323,"children":7325},{"className":7324},[],[7326],{"type":79,"value":7327},"trigger-control",{"type":79,"value":7329}," header, not on ",{"type":73,"tag":86,"props":7331,"children":7333},{"className":7332},[],[7334],{"type":79,"value":7335},"chunk.type",{"type":79,"value":175},{"type":73,"tag":82,"props":7338,"children":7339},{},[7340,7342,7348,7349,7355,7356,7362,7363,7369,7371,7377],{"type":79,"value":7341},"MCP-driven agent chats (",{"type":73,"tag":86,"props":7343,"children":7345},{"className":7344},[],[7346],{"type":79,"value":7347},"list_agents",{"type":79,"value":612},{"type":73,"tag":86,"props":7350,"children":7352},{"className":7351},[],[7353],{"type":79,"value":7354},"start_agent_chat",{"type":79,"value":612},{"type":73,"tag":86,"props":7357,"children":7359},{"className":7358},[],[7360],{"type":79,"value":7361},"send_agent_message",{"type":79,"value":666},{"type":73,"tag":86,"props":7364,"children":7366},{"className":7365},[],[7367],{"type":79,"value":7368},"close_agent_chat",{"type":79,"value":7370},") are MCP server tools used from Claude Code \u002F Cursor, not importable SDK\nfunctions. See ",{"type":73,"tag":86,"props":7372,"children":7374},{"className":7373},[],[7375],{"type":79,"value":7376},"\u002Fmcp-tools#agent-chat-tools",{"type":79,"value":175},{"type":73,"tag":177,"props":7379,"children":7381},{"id":7380},"references",[7382],{"type":79,"value":7383},"References",{"type":73,"tag":6713,"props":7385,"children":7386},{},[7387,7414,7425],{"type":73,"tag":6717,"props":7388,"children":7389},{},[7390,7396,7398,7404,7406,7412],{"type":73,"tag":86,"props":7391,"children":7393},{"className":7392},[],[7394],{"type":79,"value":7395},"trigger-authoring-chat-agent",{"type":79,"value":7397}," skill - the everyday ",{"type":73,"tag":86,"props":7399,"children":7401},{"className":7400},[],[7402],{"type":79,"value":7403},"chat.agent({...})",{"type":79,"value":7405}," definition, lifecycle hooks, and\nthe ",{"type":73,"tag":86,"props":7407,"children":7409},{"className":7408},[],[7410],{"type":79,"value":7411},"useTriggerChatTransport",{"type":79,"value":7413}," happy path. Start there before reaching for this skill.",{"type":73,"tag":6717,"props":7415,"children":7416},{},[7417,7423],{"type":73,"tag":86,"props":7418,"children":7420},{"className":7419},[],[7421],{"type":79,"value":7422},"trigger-realtime-and-frontend",{"type":79,"value":7424}," skill - Realtime hooks and frontend streaming beyond the chat transport.",{"type":73,"tag":6717,"props":7426,"children":7427},{},[7428,7434,7436,7442,7444,7450],{"type":73,"tag":86,"props":7429,"children":7431},{"className":7430},[],[7432],{"type":79,"value":7433},"trigger-authoring-tasks",{"type":79,"value":7435}," skill - base ",{"type":73,"tag":86,"props":7437,"children":7439},{"className":7438},[],[7440],{"type":79,"value":7441},"task()",{"type":79,"value":7443}," semantics, ",{"type":73,"tag":86,"props":7445,"children":7447},{"className":7446},[],[7448],{"type":79,"value":7449},"ctx",{"type":79,"value":7451},", and standard lifecycle hooks.",{"type":73,"tag":82,"props":7453,"children":7454},{},[7455,7457,7463,7465,7471,7473,7479,7481,7487,7488,7494,7495,7501,7502,7508,7509,7515],{"type":79,"value":7456},"Reference docs ship beside this skill in the same package, read them locally (no network), pinned to your installed version. The ",{"type":73,"tag":86,"props":7458,"children":7460},{"className":7459},[],[7461],{"type":79,"value":7462},"sources:",{"type":79,"value":7464}," frontmatter above lists every doc this skill draws from, all under ",{"type":73,"tag":86,"props":7466,"children":7468},{"className":7467},[],[7469],{"type":79,"value":7470},"@trigger.dev\u002Fsdk\u002Fdocs\u002Fai-chat\u002F",{"type":79,"value":7472}," (including ",{"type":73,"tag":86,"props":7474,"children":7476},{"className":7475},[],[7477],{"type":79,"value":7478},"patterns\u002F",{"type":79,"value":7480},"). For HITL, sessions, and sub-agents start with ",{"type":73,"tag":86,"props":7482,"children":7484},{"className":7483},[],[7485],{"type":79,"value":7486},"sessions.mdx",{"type":79,"value":612},{"type":73,"tag":86,"props":7489,"children":7491},{"className":7490},[],[7492],{"type":79,"value":7493},"server-chat.mdx",{"type":79,"value":612},{"type":73,"tag":86,"props":7496,"children":7498},{"className":7497},[],[7499],{"type":79,"value":7500},"client-protocol.mdx",{"type":79,"value":612},{"type":73,"tag":86,"props":7503,"children":7505},{"className":7504},[],[7506],{"type":79,"value":7507},"patterns\u002Fhuman-in-the-loop.mdx",{"type":79,"value":612},{"type":73,"tag":86,"props":7510,"children":7512},{"className":7511},[],[7513],{"type":79,"value":7514},"patterns\u002Fsub-agents.mdx",{"type":79,"value":175},{"type":73,"tag":82,"props":7517,"children":7518},{},[7519,7521,7527,7529,7535,7536,7542],{"type":79,"value":7520},"For ",{"type":73,"tag":86,"props":7522,"children":7524},{"className":7523},[],[7525],{"type":79,"value":7526},"trigger.config.ts",{"type":79,"value":7528}," and build extensions a chat-agent task may need (Prisma, Playwright, Python, etc.), read the bundled config docs under ",{"type":73,"tag":86,"props":7530,"children":7532},{"className":7531},[],[7533],{"type":79,"value":7534},"@trigger.dev\u002Fsdk\u002Fdocs\u002Fconfig\u002F",{"type":79,"value":620},{"type":73,"tag":86,"props":7537,"children":7539},{"className":7538},[],[7540],{"type":79,"value":7541},"config\u002Fextensions\u002F",{"type":79,"value":7543}," for the per-extension setup).",{"type":73,"tag":177,"props":7545,"children":7547},{"id":7546},"version",[7548],{"type":79,"value":7549},"Version",{"type":73,"tag":82,"props":7551,"children":7552},{},[7553,7555,7560,7562,7568,7570,7576,7578,7584],{"type":79,"value":7554},"This skill is bundled inside ",{"type":73,"tag":86,"props":7556,"children":7558},{"className":7557},[],[7559],{"type":79,"value":782},{"type":79,"value":7561}," and read directly from ",{"type":73,"tag":86,"props":7563,"children":7565},{"className":7564},[],[7566],{"type":79,"value":7567},"node_modules",{"type":79,"value":7569},", so it always matches your installed SDK version (see the adjacent ",{"type":73,"tag":86,"props":7571,"children":7573},{"className":7572},[],[7574],{"type":79,"value":7575},"package.json",{"type":79,"value":7577},"). The full documentation for these APIs ships alongside it under ",{"type":73,"tag":86,"props":7579,"children":7581},{"className":7580},[],[7582],{"type":79,"value":7583},"@trigger.dev\u002Fsdk\u002Fdocs\u002F",{"type":79,"value":175},{"type":73,"tag":7586,"props":7587,"children":7588},"style",{},[7589],{"type":79,"value":7590},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":7592,"total":7750},[7593,7605,7617,7623,7639,7654,7668,7685,7698,7710,7721,7735],{"slug":7395,"name":7395,"fn":7594,"description":7595,"org":7596,"tags":7597,"stars":21,"repoUrl":22,"updatedAt":7604},"author durable AI chat agents with Trigger.dev","Author and run a durable AI chat agent with chat.agent from @trigger.dev\u002Fsdk\u002Fai: the per-turn run loop, why you MUST spread ...chat.toStreamTextOptions() first, returning a StreamTextResult vs calling chat.pipe(), the two server actions (chat.createStartSessionAction + auth.createPublicToken), and wiring useChat to useTriggerChatTransport. Load this when building, modifying, or debugging a chat backend (the agent task or its lifecycle hooks) or its React transport, when declaring typed tools or custom data parts, or when migrating a plain AI SDK streamText route to chat.agent.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7598,7599,7602,7603],{"name":16,"slug":17,"type":14},{"name":7600,"slug":7601,"type":14},"SDK","sdk",{"name":9,"slug":8,"type":14},{"name":19,"slug":20,"type":14},"2026-07-02T17:12:52.307135",{"slug":7433,"name":7433,"fn":7606,"description":7607,"org":7608,"tags":7609,"stars":21,"repoUrl":22,"updatedAt":7616},"author backend Trigger.dev tasks","Covers writing backend Trigger.dev tasks with @trigger.dev\u002Fsdk: defining task() and schemaTask(), the run function and its ctx, retries, waits, queues and concurrency, idempotency keys, run metadata, logging, triggering other tasks (and the Result shape), scheduled\u002Fcron tasks, and the essentials of trigger.config.ts. Load this whenever you are authoring or editing code inside a \u002Ftrigger directory, defining a task, or writing backend code that triggers tasks. Realtime\u002FReact hooks and AI chat are covered by separate skills.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7610,7613,7614,7615],{"name":7611,"slug":7612,"type":14},"Backend","backend",{"name":7600,"slug":7601,"type":14},{"name":9,"slug":8,"type":14},{"name":19,"slug":20,"type":14},"2026-07-02T17:12:48.396964",{"slug":4,"name":4,"fn":5,"description":6,"org":7618,"tags":7619,"stars":21,"repoUrl":22,"updatedAt":23},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7620,7621,7622],{"name":16,"slug":17,"type":14},{"name":9,"slug":8,"type":14},{"name":19,"slug":20,"type":14},{"slug":7422,"name":7422,"fn":7624,"description":7625,"org":7626,"tags":7627,"stars":21,"repoUrl":22,"updatedAt":7638},"subscribe to Trigger.dev runs in realtime","Trigger.dev client\u002Ffrontend surface: subscribe to runs in realtime (runs.subscribeToRun and the @trigger.dev\u002Freact-hooks hook useRealtimeRun), consume metadata and AI\u002Ftext streams in React (useRealtimeStream), trigger tasks from the browser (useTaskTrigger, useRealtimeTaskTrigger), and mint scoped frontend credentials with auth.createPublicToken \u002F auth.createTriggerPublicToken. Load when wiring a frontend (React\u002FNext.js\u002FRemix) or backend-for-frontend to show live run progress, status badges, token streams, trigger buttons, or wait-token approval UIs. NOT for writing the backend task itself (streams.define \u002F metadata.set is trigger-authoring-tasks territory); this is the consumer side.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7628,7631,7634,7637],{"name":7629,"slug":7630,"type":14},"Frontend","frontend",{"name":7632,"slug":7633,"type":14},"React","react",{"name":7635,"slug":7636,"type":14},"Real-time","real-time",{"name":9,"slug":8,"type":14},"2026-07-02T17:12:49.717706",{"slug":7640,"name":7640,"fn":7641,"description":7642,"org":7643,"tags":7644,"stars":7651,"repoUrl":7652,"updatedAt":7653},"trigger-agents","orchestrate AI agents with Trigger.dev","AI agent patterns with Trigger.dev - orchestration, parallelization, routing, evaluator-optimizer, and human-in-the-loop. Use when building LLM-powered tasks that need parallel workers, approval gates, tool calling, or multi-step agent workflows.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7645,7646,7649,7650],{"name":16,"slug":17,"type":14},{"name":7647,"slug":7648,"type":14},"Multi-Agent","multi-agent",{"name":9,"slug":8,"type":14},{"name":19,"slug":20,"type":14},30,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fskills","2026-04-06T18:54:46.023553",{"slug":7655,"name":7655,"fn":7656,"description":7657,"org":7658,"tags":7659,"stars":7651,"repoUrl":7652,"updatedAt":7667},"trigger-config","configure Trigger.dev project settings","Configure Trigger.dev projects with trigger.config.ts. Use when setting up build extensions for Prisma, Playwright, FFmpeg, Python, or customizing deployment settings.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7660,7663,7666],{"name":7661,"slug":7662,"type":14},"Configuration","configuration",{"name":7664,"slug":7665,"type":14},"Deployment","deployment",{"name":9,"slug":8,"type":14},"2026-04-06T18:54:44.764258",{"slug":7669,"name":7669,"fn":7670,"description":7671,"org":7672,"tags":7673,"stars":7651,"repoUrl":7652,"updatedAt":7684},"trigger-cost-savings","optimize Trigger.dev task costs","Analyze Trigger.dev tasks, schedules, and runs for cost optimization opportunities. Use when asked to reduce spend, optimize costs, audit usage, right-size machines, or review task efficiency. Requires Trigger.dev MCP tools for run analysis.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7674,7677,7680,7683],{"name":7675,"slug":7676,"type":14},"Analytics","analytics",{"name":7678,"slug":7679,"type":14},"Cost Optimization","cost-optimization",{"name":7681,"slug":7682,"type":14},"Operations","operations",{"name":9,"slug":8,"type":14},"2026-04-06T18:54:48.555552",{"slug":7686,"name":7686,"fn":7687,"description":7688,"org":7689,"tags":7690,"stars":7651,"repoUrl":7652,"updatedAt":7697},"trigger-realtime","monitor Trigger.dev tasks in real-time","Subscribe to Trigger.dev task runs in real-time from frontend and backend. Use when building progress indicators, live dashboards, streaming AI\u002FLLM responses, or React components that display task status.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7691,7692,7695,7696],{"name":7629,"slug":7630,"type":14},{"name":7693,"slug":7694,"type":14},"Observability","observability",{"name":7635,"slug":7636,"type":14},{"name":9,"slug":8,"type":14},"2026-04-06T18:54:47.293822",{"slug":7699,"name":7699,"fn":7700,"description":7701,"org":7702,"tags":7703,"stars":7651,"repoUrl":7652,"updatedAt":7709},"trigger-setup","set up Trigger.dev in projects","Set up Trigger.dev in your project. Use when adding Trigger.dev for the first time, creating trigger.config.ts, or initializing the trigger directory.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7704,7705,7708],{"name":7661,"slug":7662,"type":14},{"name":7706,"slug":7707,"type":14},"Local Development","local-development",{"name":9,"slug":8,"type":14},"2026-04-06T18:54:42.280816",{"slug":7711,"name":7711,"fn":7712,"description":7713,"org":7714,"tags":7715,"stars":7651,"repoUrl":7652,"updatedAt":7720},"trigger-tasks","build durable background tasks with Trigger.dev","Build AI agents, workflows and durable background tasks with Trigger.dev. Use when creating tasks, triggering jobs, handling retries, scheduling cron jobs, or implementing queues and concurrency control.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7716,7717,7718,7719],{"name":16,"slug":17,"type":14},{"name":7611,"slug":7612,"type":14},{"name":9,"slug":8,"type":14},{"name":19,"slug":20,"type":14},"2026-04-06T18:54:43.514369",{"slug":7722,"name":7722,"fn":7723,"description":7724,"org":7725,"tags":7726,"stars":309,"repoUrl":7733,"updatedAt":7734},"staff-engineering-skills-backpressure","implement backpressure in streaming pipelines","Prevent unbounded resource growth when producers outpace consumers. Use when writing producer-consumer code, queue processing, batch operations, fan-out patterns, streaming pipelines, or any code where work is generated faster than it can be processed. Activates on patterns like Promise.all on dynamic-sized arrays, unbounded in-memory queues, producer loops without depth checks, fire-and-forget async calls in loops, or any buffer between a producer and consumer without a size limit.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7727,7730],{"name":7728,"slug":7729,"type":14},"Architecture","architecture",{"name":7731,"slug":7732,"type":14},"Performance","performance","https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fstaff-engineering-skills","2026-06-17T08:40:42.723559",{"slug":7736,"name":7736,"fn":7737,"description":7738,"org":7739,"tags":7740,"stars":309,"repoUrl":7733,"updatedAt":7749},"staff-engineering-skills-cache-invalidation","implement cache invalidation strategies","Prevent stale data bugs caused by missing or incomplete cache invalidation. Use when adding caching layers (Redis, in-memory Map, CDN, HTTP cache headers), optimizing read performance, or reviewing code that caches query results, API responses, or computed values. Activates on patterns like cache.set without cache.delete on write paths, unbounded Map\u002Fobject caches, TTL-only invalidation on security-sensitive data, Cache-Control headers on mutable content, or any caching where the write path doesn't invalidate the read cache.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7741,7742,7745,7748],{"name":7728,"slug":7729,"type":14},{"name":7743,"slug":7744,"type":14},"Caching","caching",{"name":7746,"slug":7747,"type":14},"Engineering","engineering",{"name":7731,"slug":7732,"type":14},"2026-06-17T08:40:45.194583",26,{"items":7752,"total":319},[7753,7760,7767,7773],{"slug":7395,"name":7395,"fn":7594,"description":7595,"org":7754,"tags":7755,"stars":21,"repoUrl":22,"updatedAt":7604},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7756,7757,7758,7759],{"name":16,"slug":17,"type":14},{"name":7600,"slug":7601,"type":14},{"name":9,"slug":8,"type":14},{"name":19,"slug":20,"type":14},{"slug":7433,"name":7433,"fn":7606,"description":7607,"org":7761,"tags":7762,"stars":21,"repoUrl":22,"updatedAt":7616},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7763,7764,7765,7766],{"name":7611,"slug":7612,"type":14},{"name":7600,"slug":7601,"type":14},{"name":9,"slug":8,"type":14},{"name":19,"slug":20,"type":14},{"slug":4,"name":4,"fn":5,"description":6,"org":7768,"tags":7769,"stars":21,"repoUrl":22,"updatedAt":23},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7770,7771,7772],{"name":16,"slug":17,"type":14},{"name":9,"slug":8,"type":14},{"name":19,"slug":20,"type":14},{"slug":7422,"name":7422,"fn":7624,"description":7625,"org":7774,"tags":7775,"stars":21,"repoUrl":22,"updatedAt":7638},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[7776,7777,7778,7779],{"name":7629,"slug":7630,"type":14},{"name":7632,"slug":7633,"type":14},{"name":7635,"slug":7636,"type":14},{"name":9,"slug":8,"type":14}]