Skip to content

docs(ai-chat): clarify lastEventId is sessionId-keyed across run boundaries#3700

Merged
ericallam merged 1 commit into
mainfrom
docs/ai-chat-lasteventid-session-lifetime
May 22, 2026
Merged

docs(ai-chat): clarify lastEventId is sessionId-keyed across run boundaries#3700
ericallam merged 1 commit into
mainfrom
docs/ai-chat-lasteventid-session-lifetime

Conversation

@ericallam
Copy link
Copy Markdown
Member

Summary

Two docs edits that close a footgun customers persisting transport state can hit. Clearing lastEventId on chat.endRun() looks intuitive — the Run ended, the cursor must be stale — but the cursor is sessionId-keyed, not runId-keyed. Clearing it forces the next sendMessages to subscribe from seq_num=0, which may hit the prior turn's still-durable turn-complete record and close the SSE empty before the new Run's chunks arrive.

Spells out the invariant in the frontend transport persistence table and adds a Warning in the chat.endRun() reference.

Test plan

  • Mintlify preview renders
  • No callout stacking

…daries

Clearing lastEventId on chat.endRun() looks intuitive (Run ended, cursor must be stale) but breaks the next-message subscription. The cursor is sessionId-keyed, not runId-keyed. Clearing it forces the next sendMessages to subscribe from seq_num=0, where it may hit the prior turn's still-durable turn-complete record and close the SSE empty before the new Run's chunks arrive.

Spells out the invariant in the frontend transport persistence table and adds a Warning in the chat.endRun() reference.
@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented May 22, 2026

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

Project Status Preview Updated (UTC)
trigger 🟢 Ready View Preview May 22, 2026, 9:20 AM

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 22, 2026

⚠️ No Changeset found

Latest commit: 1acf59e

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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 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: c867a2fe-9c94-46ad-9aee-dfd7e56ae6ac

📥 Commits

Reviewing files that changed from the base of the PR and between c80b85e and 1acf59e.

📒 Files selected for processing (2)
  • docs/ai-chat/backend.mdx
  • docs/ai-chat/frontend.mdx
📜 Recent 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). (4)
  • GitHub Check: Mintlify Deployment
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (python)
🧰 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/backend.mdx
  • docs/ai-chat/frontend.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/backend.mdx
  • docs/ai-chat/frontend.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/backend.mdx
  • docs/ai-chat/frontend.mdx
🔇 Additional comments (2)
docs/ai-chat/frontend.mdx (1)

116-116: LGTM!

docs/ai-chat/backend.mdx (1)

588-590: LGTM!


Walkthrough

This PR refines documentation for the AI chat API's lastEventId field to clarify its persistence semantics across session boundaries. The frontend documentation specifies that lastEventId remains valid for the entire Session lifetime and should be retained across run continuations, not just for reload-based resumption. The backend documentation adds a warning that when using external persistence for cross-page-load resume, the externally persisted lastEventId must not be cleared during chat.endRun() calls, since the session cursor is keyed by sessionId and clearing it could cause the next sendMessages call to resubscribe from seq_num=0.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: clarifying that lastEventId is sessionId-keyed across run boundaries, which directly matches the documentation updates.
Description check ✅ Passed The description is largely complete with a clear summary, detailed explanation of the footgun, and test plan. However, it is missing the closing issue reference and the 'Changelog' section from the template.
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/ai-chat-lasteventid-session-lifetime

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.

@ericallam ericallam marked this pull request as ready for review May 22, 2026 09:23
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 bugs or issues to report.

Open in Devin Review

@ericallam ericallam merged commit c0b9fdf into main May 22, 2026
22 checks passed
@ericallam ericallam deleted the docs/ai-chat-lasteventid-session-lifetime branch May 22, 2026 09:26
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.

3 participants