Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
docs: add session.update() examples for TypeScript and Python
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Abir Taheer committed
May 7, 2026 at 02:28 UTC
a9977af2c1e2303944a8e7331f1f98e762c1000e
2 files changed
+99
python/examples/tool_router/session_update.py
new
+45
@@ -0,0 +1,45 @@
1
+"""
2
+Tool Router - Session Update Example
3
+
4
+Demonstrates using session.update() to modify a session's configuration
5
+after creation — e.g. adding toolkits, changing workbench settings, or
6
+updating preload config without creating a new session.
7
+"""
8
+
9
+from composio import Composio
10
+
11
+composio = Composio()
12
+
13
+# Create a session with gmail only
14
+session = composio.create(
15
+ user_id="session-update-demo",
16
+ toolkits=["gmail"],
17
+ manage_connections=False,
18
+)
19
+
20
+print(f"Session created: {session.session_id}")
21
+print(f"Preload: {session.preload}")
22
+
23
+# Update: add github toolkit, enable workbench, and preload a tool
24
+session.update(
25
+ toolkits={"enable": ["gmail", "github"]},
26
+ workbench={"enable": True, "sandbox_size": "medium"},
27
+ preload={"tools": ["GITHUB_CREATE_ISSUE"]},
28
+)
29
+
30
+print(f"\nAfter update:")
31
+print(f"Preload: {session.preload}")
32
+
33
+# Update: disable workbench entirely
34
+session.update(
35
+ workbench={"enable": False},
36
+)
37
+
38
+print(f"\nAfter disabling workbench: done")
39
+
40
+# Update: clear manage_connections by passing None
41
+session.update(
42
+ manage_connections=None,
43
+)
44
+
45
+print(f"\nAfter clearing manage_connections: done")
ts/examples/tool-router/src/session-update.ts
new
+54
@@ -0,0 +1,54 @@
1
+/**
2
+ * Session Update Example
3
+ *
4
+ * Demonstrates using session.update() to modify a session's configuration
5
+ * after creation — e.g. adding toolkits, changing workbench settings, or
6
+ * updating preload config without creating a new session.
7
+ *
8
+ * Usage:
9
+ * COMPOSIO_API_KEY=... bun src/session-update.ts
10
+ */
11
+import { Composio } from "@composio/core";
12
+
13
+const composio = new Composio({
14
+ apiKey: process.env.COMPOSIO_API_KEY,
15
+ baseURL: process.env.COMPOSIO_BASE_URL || undefined,
16
+});
17
+
18
+// Create a session with gmail only
19
+const session = await composio.create("session-update-demo", {
20
+ toolkits: ["gmail"],
21
+ manageConnections: false,
22
+});
23
+
24
+console.log(`Session created: ${session.sessionId}`);
25
+console.log(`Config version: ${session.configVersion}`);
26
+console.log(`Preload: ${JSON.stringify(session.preload)}`);
27
+
28
+// Update: add github toolkit, enable workbench, and preload a tool
29
+await session.update({
30
+ toolkits: { enable: ["gmail", "github"] },
31
+ workbench: { enable: true, sandboxSize: "medium" },
32
+ preload: { tools: ["GITHUB_CREATE_ISSUE"] },
33
+});
34
+
35
+console.log(`\nAfter update:`);
36
+console.log(`Config version: ${session.configVersion}`);
37
+console.log(`Preload: ${JSON.stringify(session.preload)}`);
38
+
39
+// Update: disable workbench entirely
40
+await session.update({
41
+ workbench: { enable: false },
42
+});
43
+
44
+console.log(`\nAfter disabling workbench:`);
45
+console.log(`Config version: ${session.configVersion}`);
46
+
47
+// Update: clear manage_connections by passing null
48
+await session.update({
49
+ manageConnections: null,
50
+});
51
+
52
+console.log(`\nAfter clearing manageConnections:`);
53
+console.log(`Config version: ${session.configVersion}`);
54
+console.log(`Warnings: ${JSON.stringify(session.warnings)}`);