Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
docs: reframe .use() around session rehydration, not custom tools
Abir Taheer1252423481cc
diff --git a/docs/content/docs/toolkits/custom-tools-and-toolkits.mdx b/docs/content/docs/toolkits/custom-tools-and-toolkits.mdxindex ba6cb0253..f2bac0700 100644--- a/docs/content/docs/toolkits/custom-tools-and-toolkits.mdx+++ b/docs/content/docs/toolkits/custom-tools-and-toolkits.mdx@@ -636,9 +636,9 @@ custom_toolkits = session.custom_toolkits()</Tab></Tabs>-## Attaching custom tools to an existing session+## Reusing a session with custom tools-Use `composio.use()` to rehydrate an existing session and attach custom tools to it. This is useful when you have a session ID from a previous `create()` call and want to bind custom tools in a different process or request.+When [reusing a session](/docs/users-and-sessions#reusing-a-session) via `composio.use()`, you can attach custom tools at the same time:<Tabs groupId="language" items={['TypeScript', 'Python']} persist><Tab value="TypeScript">@@ -650,12 +650,9 @@ declare const getUserProfile: ReturnType<typeof experimental_createTool>;const composio = new Composio({ apiKey: "your_api_key" });// ---cut----// Rehydrate with custom toolsconst session = await composio.use("session_id", {customTools: [getUserProfile],});--const tools = await session.tools();```</Tab><Tab value="Python">@@ -664,32 +661,10 @@ from composio import Composiocomposio = Composio(api_key="your_api_key")-# Rehydrate with custom toolssession = composio.use("session_id",custom_tools=[get_user_profile],)--tools = session.tools()-```-</Tab>-</Tabs>--Without custom tools, `composio.use()` simply rehydrates the session:--<Tabs groupId="language" items={['TypeScript', 'Python']} persist>-<Tab value="TypeScript">-```typescript-import { Composio } from "@composio/core";-const composio = new Composio({ apiKey: "your_api_key" });-// ---cut-----const session = await composio.use("session_id");-```-</Tab>-<Tab value="Python">-```python-session = composio.use("session_id")```</Tab></Tabs>diff --git a/docs/content/docs/users-and-sessions.mdx b/docs/content/docs/users-and-sessions.mdxindex e1418f8dd..0c060c6ed 100644--- a/docs/content/docs/users-and-sessions.mdx+++ b/docs/content/docs/users-and-sessions.mdx@@ -107,13 +107,29 @@ A session ties together a user, a set of available toolkits, auth configurationYou don't need to cache session IDs, manage session lifetimes, or worry about expiration. Sessions persist on the server and don't expire. Just call `create()` with what you need.-### Session configuration is fixed at creation+### Reusing a session-A session's toolkits, auth configs, and connected accounts are fixed at creation. You cannot change them on an existing session.+In multi-turn chat apps, you create a session once and reuse it across requests. Store the session ID and call `composio.use()` to rehydrate it:-The one exception is [custom tools](/docs/toolkits/custom-tools-and-toolkits): you can attach custom tools to an existing session via `composio.use(sessionId, { customTools: [...] })`.+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>+<Tab value="Python">+```python+session = composio.use("session_id")+tools = session.tools()+```+</Tab>+<Tab value="TypeScript">+```typescript+import { Composio } from '@composio/core';+const composio = new Composio({ apiKey: 'your_api_key' });+// ---cut---+const session = await composio.use("session_id");+const tools = await session.tools();+```+</Tab>+</Tabs>-This means the boundary for a new session isn't a new chat or a new request. It's when the contract changes. If a user starts with "search my personal Gmail" and then says "actually use my work email," that's a different session because the auth changed.+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.### Connected accounts persist across sessions@@ -121,7 +137,7 @@ Connections are tied to the user ID, not the session. A user who connected Gmail<Accordions><Accordion title="When should I create a new session?">-Create a new session when the config changes: different toolkits, different auth config, or a different connected account. You don't need to store or manage session IDs. Just call `create()` each time.+Create a new session when the config changes: different toolkits, different auth config, or a different connected account. For multi-turn conversations where the config stays the same, reuse the session with `composio.use()`.</Accordion></Accordions>