docs(ai-chat): atomic onTurnComplete writes + Anthropic prose#3693
Conversation
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.
|
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (1)docs/**/*.mdx📄 CodeRabbit inference engine (docs/CLAUDE.md)
Files:
🧠 Learnings (2)📚 Learning: 2026-03-10T12:44:14.176ZApplied to files:
📚 Learning: 2026-04-30T20:30:29.458ZApplied to files:
🔇 Additional comments (3)
WalkthroughThis PR updates AI chat documentation across three files. It changes the documented background self-review model from Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
Summary
Three post-merge fixes for the AI Agents docs (#3226), all caught by review after merge.
Fixes
onTurnCompleteexamples now usedb.$transaction— both the Database persistence "Complete example" and the Lifecycle hooks reference example were doing two separateawaitcalls (db.chat.updatethendb.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 stalelastEventIdand 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
db.$transaction([...])