trigger-authoring-chat-agent

Author durable AI chat agents with chat.agent from the Trigger.dev SDK.

1.1k|103|Updated Nov 28, 2024
One-click install
npx skills add https://github.com/VladSez/easy-invoice-pdf --skill trigger-authoring-chat-agent
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: trigger-authoring-chat-agent
Source: https://github.com/VladSez/easy-invoice-pdf/tree/main/.cursor/skills/trigger-authoring-chat-agent
Command: npx skills add https://github.com/VladSez/easy-invoice-pdf --skill trigger-authoring-chat-agent

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @trigger.dev/sdk.

What problem does it solve?

Building a durable AI chat backend with Trigger.dev involves subtle wiring—spreading chat.toStreamTextOptions(), declaring typed tools, minting public tokens server-side, and connecting the React transport—where small omissions silently break compaction, steering, and stop behavior.

Core Features & Use Cases

  • Correct run-loop wiring: Enforces spreading ...chat.toStreamTextOptions() first in streamText so compaction, mid-turn steering, background injection, and telemetry actually work.
  • Server action setup: Guides implementation of chat.createStartSessionAction and auth.createPublicToken so browser clients never see the secret key.
  • Frontend transport: Connects useChat to useTriggerChatTransport for the React side of the chat session.
  • Use Case: When migrating a plain AI SDK streamText route to chat.agent, load this Skill to avoid pitfalls like tools dropped on later turns, Stop not aborting generation, or chat.local initialization crashes.

Quick Start

Ask the AI to build a Trigger.dev chat agent backend with typed tools and wire it to a React useChat hook using this skill's guidance.

Frequently Asked Questions about trigger-authoring-chat-agent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a chat agent with Trigger.dev?

Define a chat.agent task from @trigger.dev/sdk/ai, return streamText with ...chat.toStreamTextOptions() spread first, then expose it via chat.createStartSessionAction and auth.createPublicToken server actions. On the frontend, connect useChat through useTriggerChatTransport.

Why is chat.toStreamTextOptions required in streamText?

It wires the prepareStep callback behind compaction, mid-turn steering, and background injection, injects the system prompt, resolves the registry model, and adds telemetry. Omitting it makes all of these silently no-op with no error.

How do I migrate a plain AI SDK streamText route to chat.agent?

Wrap the logic in chat.agent, spread chat.toStreamTextOptions() before your explicit streamText options, declare tools on both the agent and streamText, and replace direct streaming with the two server actions plus the Trigger chat transport.

Why does Stop not halt model generation in my Trigger.dev chat?

Stop fails when the abort signal is not forwarded. Pass abortSignal: signal into streamText so the Stop action actually cancels server-side generation instead of only updating the UI.

Can I mint Trigger.dev public tokens in the browser?

No. Minting tokens client-side exposes the environment secret key. Always mint through the server actions chat.createStartSessionAction and auth.createPublicToken, which the transport calls automatically.

Why does chat.local throw 'can only be modified after initialization'?

This happens when chat.local is initialized in onChatStart, which fires once per chat and is skipped on continuation runs. Initialize it in onBoot instead, which fires on every fresh worker.