fix(chat): include "action" in ChatTaskPayload.trigger type

run() is invoked with trigger: "action" after onAction processes a
typed action, but the type previously omitted it. Adding it lets
users cleanly short-circuit the LLM call for actions that don't
need a response (e.g. user-initiated compaction):
  if (trigger === "action") return;
This commit is contained in:
Eric Allam
2026-04-18 16:15:04 +01:00
parent 0a401d8bb7
commit b27da8b976
2 changed files with 10 additions and 1 deletions
@@ -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;`.
+5 -1
View File
@@ -626,8 +626,12 @@ export type ChatTaskPayload<TClientData = unknown> = {
* - `"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;