From 63535afc4de6d55e0ceb455105650ab4af9573d9 Mon Sep 17 00:00:00 2001 From: Abir Taheer Date: Fri, 8 May 2026 03:11:09 -0700 Subject: [PATCH 1/3] docs: update chat-app cookbook to use composio.use() for multi-turn 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) --- docs/content/cookbooks/chat-app.mdx | 2 +- docs/examples/chat-app/route.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/content/cookbooks/chat-app.mdx b/docs/content/cookbooks/chat-app.mdx index 9787e04b0e..7c79aaa6ce 100644 --- a/docs/content/cookbooks/chat-app.mdx +++ b/docs/content/cookbooks/chat-app.mdx @@ -54,7 +54,7 @@ A **session** scopes tools and credentials to a specific user. Create `app/api/c ../../examples/chat-app/route.ts -That's the entire backend. `composio.create("user_123")` creates a session that lets the agent search for tools, authenticate users, and execute actions. This ID scopes all connections and credentials to this user. In production, use the user ID from your auth system. +That's the entire backend. On the first request, `composio.create("user_123")` creates a session that lets the agent search for tools, authenticate users, and execute actions. Subsequent requests reuse the same session via `composio.use(sessionId)` so the agent keeps its context across messages. In production, store the session ID per user in your database and use the user ID from your auth system. ## Build the chat UI diff --git a/docs/examples/chat-app/route.ts b/docs/examples/chat-app/route.ts index 97cf4a44c5..60cbc1dd91 100644 --- a/docs/examples/chat-app/route.ts +++ b/docs/examples/chat-app/route.ts @@ -11,10 +11,18 @@ import { const composio = new Composio({ provider: new VercelProvider() }); +// In production, store session IDs per user in your database +let sessionId: string | null = null; + export async function POST(req: Request) { const { messages }: { messages: UIMessage[] } = await req.json(); - const session = await composio.create("user_123"); + // Reuse existing session or create a new one + const session = sessionId + ? await composio.use(sessionId) + : await composio.create("user_123"); + sessionId = session.sessionId; + const tools = await session.tools(); const result = streamText({ From c1b1fa7fe875ca95953f9726e6c621259e762ba5 Mon Sep 17 00:00:00 2001 From: Abir Taheer Date: Fri, 8 May 2026 03:26:27 -0700 Subject: [PATCH 2/3] docs: add session.update() section to users-and-sessions 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) --- docs/content/docs/users-and-sessions.mdx | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/content/docs/users-and-sessions.mdx b/docs/content/docs/users-and-sessions.mdx index 6e8296260f..80bfe3670b 100644 --- a/docs/content/docs/users-and-sessions.mdx +++ b/docs/content/docs/users-and-sessions.mdx @@ -131,7 +131,38 @@ const tools = await session.tools(); -This returns the same session with the same toolkits, auth configs, and connected accounts. The session's configuration is fixed at creation — to change toolkits or auth, create a new session. +This returns the same session with the same toolkits, auth configs, and connected accounts. + +### Updating a session + +Use `session.update()` to modify a session's configuration without creating a new one. Only the fields you pass are changed — everything else is preserved. + + + +```python +session.update( + toolkits=["gmail", "slack"], + auth_configs={"gmail": "ac_new_config"}, + connected_accounts={"slack": ["ca_work_slack"]}, +) +``` + + +```typescript +import { Composio } from '@composio/core'; +const composio = new Composio({ apiKey: 'your_api_key' }); +const session = await composio.create("user_123"); +// ---cut--- +await session.update({ + toolkits: ["gmail", "slack"], + authConfigs: { gmail: "ac_new_config" }, + connectedAccounts: { slack: ["ca_work_slack"] }, +}); +``` + + + +You can update toolkits, auth configs, connected accounts, workbench settings, multi-account config, manage connections, tags, tools, and preload. See [Configuring Sessions](/docs/configuring-sessions) for the full list of options. ### Connected accounts persist across sessions From 7e76ea669de8ca99180b30cfd49ee22b91016875 Mon Sep 17 00:00:00 2001 From: Abir Taheer Date: Fri, 8 May 2026 03:46:16 -0700 Subject: [PATCH 3/3] docs: fix chat-app wording per review Sessions preserve tool access and connected accounts, not chat memory. Co-Authored-By: Claude Opus 4.6 (1M context) --- docs/content/cookbooks/chat-app.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/cookbooks/chat-app.mdx b/docs/content/cookbooks/chat-app.mdx index 7c79aaa6ce..8852744fda 100644 --- a/docs/content/cookbooks/chat-app.mdx +++ b/docs/content/cookbooks/chat-app.mdx @@ -54,7 +54,7 @@ A **session** scopes tools and credentials to a specific user. Create `app/api/c ../../examples/chat-app/route.ts -That's the entire backend. On the first request, `composio.create("user_123")` creates a session that lets the agent search for tools, authenticate users, and execute actions. Subsequent requests reuse the same session via `composio.use(sessionId)` so the agent keeps its context across messages. In production, store the session ID per user in your database and use the user ID from your auth system. +That's the entire backend. On the first request, `composio.create("user_123")` creates a session that lets the agent search for tools, authenticate users, and execute actions. Subsequent requests reuse the same session via `composio.use(sessionId)` so tool access and connected accounts carry over. In production, store the session ID per user in your database and use the user ID from your auth system. ## Build the chat UI