Skip to content

docs: update chat-app cookbook and examples to use composio.use()#3381

Merged
abir-taheer merged 3 commits into
nextfrom
abir/docs-v31-round2
May 8, 2026
Merged

docs: update chat-app cookbook and examples to use composio.use()#3381
abir-taheer merged 3 commits into
nextfrom
abir/docs-v31-round2

Conversation

@abir-taheer
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #3357 per Dhawal's review comments.

  • Chat-app cookbook: Updated route.ts to create session once and reuse via composio.use(sessionId) across requests — the correct pattern for multi-turn chat apps
  • Updated cookbook description to explain the create-once/reuse pattern

What was checked but didn't need changes

Test plan

  • Verify docs build passes
  • Check chat-app example renders correctly

🤖 Generated with Claude Code

The chat app now creates the session once and reuses it across
requests via composio.use(sessionId), which is the correct pattern
for multi-turn chat apps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 8, 2026 10:11
@vercel
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 8, 2026 10:47am

Request Review

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 8, 2026

Claude finished @abir-taheer's task in 1m 9s —— View job


Review

Looks good.

The cookbook now correctly demonstrates the multi-turn session pattern:

  • route.ts:21-24 — first request calls composio.create("user_123"), subsequent requests reuse via composio.use(sessionId). API matches Composio.use(id) defined in ts/packages/core/src/composio.ts:240.
  • The module-level let sessionId is the right size of shortcut for a teaching example, and the inline comment (route.ts:14) plus the prose update in chat-app.mdx:57 both call out the production caveat ("store the session ID per user in your database").
  • Pattern is consistent with how composio.use() is documented elsewhere — provider docs (openai/anthropic/vercel), users-and-sessions.mdx, and custom-tools-and-toolkits.mdx.

No issues to flag against the docs-reviewer checklist — no wrong API usage, no missing steps, no outdated patterns, and no new pages requiring index entries.


  • Read docs reviewer guidelines
  • Review the PR diff
  • Read changed files for context
  • Apply the review checklist
  • Post review feedback
    • Branch: abir/docs-v31-round2

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the chat-app cookbook and its example API route to demonstrate the recommended multi-turn pattern: create a Composio session once, then reuse it across subsequent requests via composio.use(sessionId).

Changes:

  • Updated docs/examples/chat-app/route.ts to reuse an existing session when a sessionId is available.
  • Updated the cookbook narrative to describe the create-once/reuse pattern for multi-turn chat apps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
docs/examples/chat-app/route.ts Introduces session reuse via .use(sessionId) in the chat route example.
docs/content/cookbooks/chat-app.mdx Updates the cookbook explanation to match the intended multi-turn session reuse workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/examples/chat-app/route.ts
Comment thread docs/content/cookbooks/chat-app.mdx Outdated
Shows how to modify a session's config (toolkits, auth configs,
connected accounts, etc.) without creating a new session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 8, 2026

Claude finished @abir-taheer's task in 1m 24s —— View job


Review (synchronize)

Looks good.

The push since my last review adds an "Updating a session" section to users-and-sessions.mdx (commit c1b1fa7). I re-applied the docs-reviewer checklist against it.

API accuracy verified

  • Python signature in users-and-sessions.mdx:142-148 matches python/composio/core/models/tool_router_session.py:804-822toolkits, auth_configs, connected_accounts (snake_case) are real kwargs on session.update().
  • TypeScript signature in users-and-sessions.mdx:156-160 matches ts/packages/core/src/models/ToolRouterSession.ts:494 and the ToolRouterUpdateSessionConfigSchema in ts/packages/core/src/types/toolRouter.types.ts:614-666toolkits, authConfigs, connectedAccounts (camelCase). Method returns Promise<void>, so await session.update(...) with no assignment is right.
  • The prose list of updatable fields at users-and-sessions.mdx:165 (toolkits, tools, tags, authConfigs, connectedAccounts, manageConnections, workbench, multiAccount, preload) is exhaustive against the schema.
  • Internal link /docs/configuring-sessions resolves to docs/content/docs/configuring-sessions.mdx.

No new index entries required — section was added to an existing page, not a new file.

Re: prior Copilot comments

  • Module-level let sessionId in route.ts: noted by Copilot as a session-leakage risk. Per docs/CLAUDE.md ("docs/examples/ is tutorial code … review for correctness and clarity, not production-readiness"), and given the inline comment on route.ts:14 plus the prose caveat in chat-app.mdx:57 ("In production, store the session ID per user in your database"), the simplification is appropriate for a teaching example.
  • "agent keeps its context across messages" wording in chat-app.mdx:57: technically the session preserves tool/connection state, while conversational memory comes from the message history sent to the model. The phrasing is loose but not misleading enough to flag in a cookbook intro — readers see the actual messages array passed to streamText immediately below.

  • Read docs reviewer guidelines
  • Review the new PR diff (since previous review)
  • Read changed files for context
  • Apply the review checklist
  • Post review feedback
    • Branch: abir/docs-v31-round2

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c1b1fa7. Configure here.

Comment thread docs/examples/chat-app/route.ts
Sessions preserve tool access and connected accounts, not chat memory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 8, 2026

Claude finished @abir-taheer's task in 48s —— View job


Review (synchronize)

Looks good.

The push since my last review is a single one-line wording fix in docs/content/cookbooks/chat-app.mdx:57 (commit 7e76ea6).

What changed

  • Before: …so the agent keeps its context across messages.
  • After: …so tool access and connected accounts carry over.

Why this is the right fix

This addresses the exact concern flagged in my previous review and in Copilot's review comment on the same line: a Composio session scopes tool access and connected-account state, while chat context comes from the message history sent to the model on each request. The new wording is technically accurate without overclaiming.

Re-applied docs-reviewer checklist

  • No wrong API usage — purely prose, no code touched.
  • No missing steps, no outdated patterns.
  • No new pages → no index entries needed.
  • The remaining outstanding bot comment (Copilot/Cursor on module-level let sessionId in route.ts:24) is acknowledged in the prose ("In production, store the session ID per user in your database") and per docs/CLAUDE.md ("docs/examples/ is tutorial code … review for correctness and clarity, not production-readiness") the simplification is appropriate.

  • Read docs-reviewer guidelines
  • Diff against origin/next to see what changed since last review
  • Read changed files for context
  • Apply the review checklist
  • Post review feedback
    • Branch: abir/docs-v31-round2

Copy link
Copy Markdown
Contributor

@zen-agent zen-agent left a comment

Choose a reason for hiding this comment

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

Docs follow-up looks good. Session reuse pattern via composio.use(sessionId) is the right guidance, and the new session.update() section in users-and-sessions.mdx is a useful addition.

@abir-taheer abir-taheer merged commit fb0668d into next May 8, 2026
13 checks passed
@abir-taheer abir-taheer deleted the abir/docs-v31-round2 branch May 8, 2026 10:51
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