Trigger authoring chat agent

From code-with-antonio/browser-automation-app · View interactive version

Trigger authoring chat agent is an AI agent skill from the GitHub repository code-with-antonio/browser-automation-app. Author and run a durable AI chat agent with chat.agent from @trigger.dev/sdk/ai: 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 w

How to use this skill

Skill file

Authoring a chat.agent

The full, version-pinned reference ships inside your installed @trigger.dev/sdk. Read it before writing code — it always matches the SDK version in this project, so it never drifts:

If those paths don't exist, @trigger.dev/sdk isn't installed yet — install it first. In a non-hoisted layout, resolve the package with node -p "require.resolve('@trigger.dev/sdk/package.json')" and read skills/ + docs/ beside it.

Common mistakes

```ts

// Wrong - compaction / steering / background injection silently no-op

return streamText({ model, messages, abortSignal: signal });

// Correct - spread FIRST so explicit overrides win

return streamText({ ...chat.toStreamTextOptions(), model, messages, abortSignal: signal });

```

It wires the prepareStep callback behind compaction, mid-turn steering, and background

injection, injects the system prompt from chat.prompt(), resolves the registry model, and adds

telemetry. Omitting it makes all of those silently no-op with no error.

back from run, and pass chat.toStreamTextOptions({ tools }). Otherwise each tool's

toModelOutput runs on turn 1 but is dropped when history is re-converted on later turns.

model keeps generating server-side.

once per chat, so continuation runs skip it and crash with

chat.local can only be modified after initialization. onBoot fires on every fresh worker.

the two server actions; the transport calls them.

only when the Session itself closes. It is sessionId-keyed, so clearing forces a resubscribe from

seq_num=0 that can hit the prior turn's stale turn-complete and close the stream empty.

stack traces). Return a sanitized string instead.

References

Sibling skills: trigger-chat-agent-advanced (Sessions primitive, custom transports, sub-agents, HITL, fast starts, resilience, testing, upgrades), trigger-authoring-tasks and trigger-realtime-and-frontend (the task + frontend foundations chat builds on).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.