Skip to content

docs(ai-chat): document stopping generation for custom agents#3976

Open
ericallam wants to merge 1 commit into
mainfrom
docs/custom-agents-stopping-generation
Open

docs(ai-chat): document stopping generation for custom agents#3976
ericallam wants to merge 1 commit into
mainfrom
docs/custom-agents-stopping-generation

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

Adds a "Stopping generation" section to the Custom agents page. It documents how stop works when you drop down from chat.agent to chat.createSession: pass turn.signal (a combined stop-and-cancel AbortSignal) to streamText, and turn.complete() cleans up the aborted partial, accumulates it as its own assistant message, and keeps the run alive for the next turn. turn.stopped distinguishes a user stop from a full run cancel.

Until now the createSession stop story only existed as scattered fields in the reference table; the client side (transport.stopGeneration) and the chat.agent run-callback signals were documented, but not the custom-agent turn loop. Steering for these backends is already covered on the pending messages page, which this page links to.

@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 26a7c14

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

A new "Stopping generation" section is added to docs/ai-chat/custom-agents.mdx. It documents how transport.stopGeneration(chatId) aborts the current custom agent turn via turn.signal, distinguishes turn.stopped outcomes for user-initiated stops versus run cancels, describes turn.complete() behavior when a stop occurs (cleanup and token accumulation without ending the run), provides a streamText code example using abortSignal: turn.signal, and references the hand-rolled loop checklist for equivalent wiring.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete. While it provides a good summary of the documentation added, it is missing all required checklist items, testing steps, and changelog sections from the template. Complete the PR description by adding the checklist items (marked complete), describing testing steps, and providing the changelog entry as specified in the repository template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding documentation for stopping generation in custom agents, which matches the changeset perfectly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/custom-agents-stopping-generation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f6f553eb-676b-42f5-8973-f75c3513897b

📥 Commits

Reviewing files that changed from the base of the PR and between 4e919e7 and 26a7c14.

📒 Files selected for processing (1)
  • docs/ai-chat/custom-agents.mdx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (1)
docs/**/*.mdx

📄 CodeRabbit inference engine (docs/CLAUDE.md)

docs/**/*.mdx: MDX documentation pages must include frontmatter with title (required), description (required), and sidebarTitle (optional) in YAML format
Use Mintlify components for structured content: , , , , , , /, /
Always import from @trigger.dev/sdk in code examples (never from @trigger.dev/sdk/v3)
Code examples must be complete and runnable where possible
Use language tags in code fences: typescript, bash, json

Files:

  • docs/ai-chat/custom-agents.mdx
🧠 Learnings (4)
📚 Learning: 2026-03-10T12:44:14.176Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 3200
File: docs/config/config-file.mdx:353-368
Timestamp: 2026-03-10T12:44:14.176Z
Learning: In the trigger.dev repo, docs PRs are often companions to implementation PRs. When reviewing docs PRs (MDX files under docs/), check the PR description for any companion/related PR references and verify that the documented features exist in those companion PRs before flagging missing implementations. This ensures docs stay in sync with code changes across related PRs.

Applied to files:

  • docs/ai-chat/custom-agents.mdx
📚 Learning: 2026-04-30T20:30:29.458Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3226
File: docs/ai-chat/quick-start.mdx:13-13
Timestamp: 2026-04-30T20:30:29.458Z
Learning: In this repo’s documentation MDX files (`docs/**/*.mdx`), use `ts` and `tsx` (not `typescript`) as the code-fence language tags for TypeScript/TSX snippets. Do not flag `ts`/`tsx` code-fence language tags as incorrect in any docs MDX file, since this is the site-wide Mintlify-compatible convention.

Applied to files:

  • docs/ai-chat/custom-agents.mdx
📚 Learning: 2026-06-16T13:14:09.440Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3964
File: docs/ai-chat/reference.mdx:482-482
Timestamp: 2026-06-16T13:14:09.440Z
Learning: When documenting or reviewing usage of `ChatTurn.complete(source?)` (in `packages/trigger-sdk/src/v3/ai.ts`), note that `source` is optional (`source?: UIMessageStreamable`). Calling `complete()` with no `source` is valid specifically for a final head-start handover (`handover.isFinal`), because the warm partial already contains the response. If examples or guidance omit `source`, ensure they are in this final-hand-over context so they remain correct.

Applied to files:

  • docs/ai-chat/custom-agents.mdx
📚 Learning: 2026-06-16T13:14:14.382Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3964
File: docs/ai-chat/reference.mdx:478-478
Timestamp: 2026-06-16T13:14:14.382Z
Learning: When reviewing RC-gated `ai-chat` docs under `docs/ai-chat/`, don’t immediately flag missing SDK type fields or implementation details just because the field isn’t present on the docs branch yet. Instead, find and cross-check the companion implementation PR that’s intended to land alongside the docs PR, and only report missing/incorrect fields if they are also absent in the companion SDK/type changes.

Applied to files:

  • docs/ai-chat/custom-agents.mdx
🪛 LanguageTool
docs/ai-chat/custom-agents.mdx

[uncategorized] ~207-~207: Possible missing preposition found.
Context: ...rn. Read turn.stopped to tell a user stop from a full run cancel: - *User stop...

(AI_HYDRA_LEO_MISSING_TO)


[uncategorized] ~207-~207: Possible missing comma found.
Context: ...topped to tell a user stop from a full run cancel: - **User stop** (transport.st...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~207-~207: Possible missing preposition found.
Context: ...ed to tell a user stop from a full run cancel: - **User stop** (transport.stopGener...

(AI_HYDRA_LEO_MISSING_TO)

Comment thread docs/ai-chat/custom-agents.mdx
@ericallam ericallam marked this pull request as ready for review June 17, 2026 11:10

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant