diff --git a/.changeset/chat-agent-action-trigger-type.md b/.changeset/chat-agent-action-trigger-type.md new file mode 100644 index 000000000..050951c02 --- /dev/null +++ b/.changeset/chat-agent-action-trigger-type.md @@ -0,0 +1,5 @@ +--- +"@trigger.dev/sdk": patch +--- + +Include `"action"` in the `ChatTaskPayload.trigger` union. `run()` is invoked with `trigger: "action"` after `onAction` processes a typed action, but the type previously omitted it. Users can now cleanly short-circuit the LLM call for actions that don't need a response (e.g. user-initiated compaction): `if (trigger === "action") return;`. diff --git a/packages/trigger-sdk/src/v3/ai.ts b/packages/trigger-sdk/src/v3/ai.ts index ab6709181..398ef7db7 100644 --- a/packages/trigger-sdk/src/v3/ai.ts +++ b/packages/trigger-sdk/src/v3/ai.ts @@ -626,8 +626,12 @@ export type ChatTaskPayload = { * - `"submit-message"`: A new user message * - `"regenerate-message"`: Regenerate the last assistant response * - `"preload"`: Run was preloaded before the first message (only on turn 0) + * - `"action"`: A typed action from the frontend (see `actionSchema` + `onAction`). + * The action has already been applied before `run()` fires — check `trigger === "action"` + * to short-circuit the LLM call when an action doesn't need a response. + * - `"close"`: The chat session is being closed (internal; `run()` is not called). */ - trigger: "submit-message" | "regenerate-message" | "preload" | "close"; + trigger: "submit-message" | "regenerate-message" | "preload" | "action" | "close"; /** The ID of the message to regenerate (only for `"regenerate-message"`) */ messageId?: string;