Skip to content

docs(ai-chat): atomic onTurnComplete writes + Anthropic prose#3693

Merged
ericallam merged 1 commit into
mainfrom
fix/docs-ai-chat-post-merge-devin
May 21, 2026
Merged

docs(ai-chat): atomic onTurnComplete writes + Anthropic prose#3693
ericallam merged 1 commit into
mainfrom
fix/docs-ai-chat-post-merge-devin

Conversation

@ericallam
Copy link
Copy Markdown
Member

Summary

Three post-merge fixes for the AI Agents docs (#3226), all caught by review after merge.

Fixes

  • onTurnComplete examples now use db.$transaction — both the Database persistence "Complete example" and the Lifecycle hooks reference example were doing two separate await calls (db.chat.update then db.chatSession.upsert). That's the exact non-atomic pattern the warning earlier on the persistence page calls out as ❌: a refresh between the two writes reads a stale lastEventId and duplicates the assistant message on resume. Both examples now use the recommended atomic form.

  • Background injection self-review prose aligned with the code — the prose said "gpt-4o-mini" but the example above it had been swapped to claude-haiku-4-5. The Anthropic-sweep script only touched code blocks; this prose line wasn't picked up.

Test plan

  • Both updated examples use db.$transaction([...])
  • Prose matches the model used in the code block
  • Mintlify deployment passes

Three fixes for issues caught after the docs PR merged:

- Both onTurnComplete examples (Database persistence "Complete example"
  and Lifecycle hooks reference) now use db.$transaction([...]) instead
  of two separate awaits. The non-atomic form contradicted the warning
  earlier on the persistence page and reintroduced the exact race
  condition that warning calls out: a refresh between the two writes
  reads a stale lastEventId and duplicates the assistant message on
  resume.

- Background injection self-review prose said "gpt-4o-mini" but the
  code in the same example uses claude-haiku-4-5. Aligned the prose.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: 0a1688e

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

@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented May 21, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
trigger 🟢 Ready View Preview May 21, 2026, 3:59 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@ericallam ericallam marked this pull request as ready for review May 21, 2026 15:58
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 009d2e46-7bc7-4f25-9585-d6ab579db569

📥 Commits

Reviewing files that changed from the base of the PR and between 80bb600 and 0a1688e.

📒 Files selected for processing (3)
  • docs/ai-chat/background-injection.mdx
  • docs/ai-chat/lifecycle-hooks.mdx
  • docs/ai-chat/patterns/database-persistence.mdx
📜 Recent review details
🧰 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/background-injection.mdx
  • docs/ai-chat/lifecycle-hooks.mdx
  • docs/ai-chat/patterns/database-persistence.mdx
🧠 Learnings (2)
📚 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/background-injection.mdx
  • docs/ai-chat/lifecycle-hooks.mdx
  • docs/ai-chat/patterns/database-persistence.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/background-injection.mdx
  • docs/ai-chat/lifecycle-hooks.mdx
  • docs/ai-chat/patterns/database-persistence.mdx
🔇 Additional comments (3)
docs/ai-chat/background-injection.mdx (1)

157-157: LGTM!

docs/ai-chat/lifecycle-hooks.mdx (1)

415-426: LGTM!

docs/ai-chat/patterns/database-persistence.mdx (1)

261-273: LGTM!


Walkthrough

This PR updates AI chat documentation across three files. It changes the documented background self-review model from gpt-4o-mini to claude-haiku-4-5 in the background injection documentation. Additionally, two onTurnComplete code examples in the lifecycle hooks and database persistence pattern documentation are refactored to demonstrate atomic database persistence by combining separate conversation and session database operations into a single db.$transaction call, ensuring lastEventId and message updates persist together.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: atomic onTurnComplete writes and Anthropic model name alignment in prose, matching the pull request's primary objectives.
Description check ✅ Passed The description covers all essential information: it explains the fixes, provides context about the non-atomic pattern issue, details the Anthropic prose alignment, and includes a test plan with checkmarks.
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 fix/docs-ai-chat-post-merge-devin

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

Copy link
Copy Markdown
Contributor

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

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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@ericallam ericallam merged commit c80b85e into main May 21, 2026
21 checks passed
@ericallam ericallam deleted the fix/docs-ai-chat-post-merge-devin branch May 21, 2026 16:04
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.

2 participants