@devries-cameron20 / composio Mirror · read-only / commits / d684eb0c3
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 17:00 UTC

migration and mutli tuen quickstart

Sushmithamallesh committed Dec 18, 2025 at 10:45 UTC d684eb0c32b82309f072a157d8188b5a5cc7f2a2
3 files changed +25 -11
fern/pages/src/tool-router/migration/tool-router-beta-to-stable.mdx
+6 -4
@@ -44,10 +44,12 @@ The stable version includes improved session management, multiple configuring op
44 </CodeGroup>
45 </Step>
46 <Step title="Moving users (optional)">
47 - If you have existing users on tool router and you don't want them to authenticate again:
48 - - Search for the Auth config created by Tool Router for that connected account. See [Connected Accounts](/docs/connected-accounts) to fetch existing accounts programmatically.
49 - - While creating a session configure to use this Auth config.
50 - - You need to repeat this for each toolkit you want to enable for that session.
47 + If you have existing users on tool router and you don't want them to authenticate again:
48 + - Tool Router will auto-detect auth configs and connected accounts it created(from the beta version).
49 + - If you have custom auth configs (not created by Tool Router):
50 + - Search for the Auth config for that connected account. See [Connected Accounts](/docs/connected-accounts) to fetch existing accounts programmatically.
51 + - While creating a session configure to use this Auth config.
52 + - You need to repeat this for each toolkit you want to enable for that session.
53 <CodeGroup>
54 ```python title="Python" for="python"
55 session = composio.create(
fern/snippets/tool-router/python/quickstart-mcp-openai.py
+14 -5
@@ -1,16 +1,15 @@
1 import os
2 from dotenv import load_dotenv
3 from composio import Composio
4 -from agents import Agent, Runner, HostedMCPTool, ModelSettings
4 +from agents import Agent, Runner, HostedMCPTool, SQLiteSession
5
6 -# Load environment variables from .env file
6 load_dotenv()
7
8 composio_api_key = os.environ.get("COMPOSIO_API_KEY")
9 user_id = "user_123" # Your user's unique identifier
10
11 composio = Composio(api_key=composio_api_key)
13 -session = composio.create(user_id=user_id)
12 +composio_session = composio.create(user_id=user_id)
13
14 agent = Agent(
15 name="Personal Assistant",
@@ -21,7 +20,7 @@ agent = Agent(
20 tool_config={
21 "type": "mcp",
22 "server_label": "composio",
24 - "server_url": session.mcp.url,
23 + "server_url": composio_session.mcp.url,
24 "require_approval": "never",
25 "headers": {"x-api-key": composio_api_key},
26 }
@@ -29,11 +28,21 @@ agent = Agent(
28 ],
29 )
30
31 +# Create a session for multi-turn conversation memory
32 +conversation_session = SQLiteSession(user_id)
33 +
34 print("Assistant: What would you like me to do today?\n")
35
36 while True:
37 user_input = input("> ")
38 if user_input == "exit":
39 break
38 - result = Runner.run_sync(starting_agent=agent, input=user_input)
40 +
41 + result = Runner.run_sync(
42 + starting_agent=agent,
43 + input=user_input,
44 + session=conversation_session
45 + )
46 +
47 print(f"Assistant: {result.final_output}\n")
48 +
fern/snippets/tool-router/typescript/quickstart-mcp-openai.ts
+5 -2
@@ -1,6 +1,6 @@
1 import "dotenv/config"; // Load environment variables from .env file
2 import { Composio } from "@composio/core";
3 -import { Agent, run, hostedMcpTool } from "@openai/agents";
3 +import { Agent, run, hostedMcpTool, MemorySession } from "@openai/agents";
4 import { createInterface } from "readline/promises";
5
6 const composioApiKey = process.env.COMPOSIO_API_KEY;
@@ -24,12 +24,15 @@ const agent = new Agent({
24 ],
25 });
26
27 +// Create a session for persistent multi-turn conversation memory
28 +const session = new MemorySession();
29 +
30 const rl = createInterface({ input: process.stdin, output: process.stdout });
31 console.log("Assistant: What would you like me to do today?\n");
32 while (true) {
33 const input = await rl.question("> ");
34 if (input === "exit") break;
32 - const result = await run(agent, input);
35 + const result = await run(agent, input, { session });
36 console.log(`Assistant: ${result.finalOutput}\n`);
37 }
38 rl.close();