557
</Tab>
558
</Tabs>
559
560
+## Attaching custom tools to an existing session
561
+
562
+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.
563
+
564
+<Tabs groupId="language" items={['TypeScript', 'Python']} persist>
565
+<Tab value="TypeScript">
566
+```typescript
567
+// @noErrors
568
+import { Composio, experimental_createTool } from "@composio/core";
569
+import { z } from "zod/v3";
570
+
571
+declare const getUserProfile: ReturnType<typeof experimental_createTool>;
572
+const composio = new Composio({ apiKey: "your_api_key" });
573
+// ---cut---
574
+
575
+// Rehydrate with custom tools
576
+const session = await composio.use("session_id", {
577
+ customTools: [getUserProfile],
578
+});
579
+
580
+const tools = await session.tools();
581
+```
582
+</Tab>
583
+<Tab value="Python">
584
+```python
585
+from composio import Composio
586
+
587
+composio = Composio(api_key="your_api_key")
588
+
589
+# Rehydrate with custom tools
590
+session = composio.use(
591
+ "session_id",
592
+ custom_tools=[get_user_profile],
593
+)
594
+
595
+tools = session.tools()
596
+```
597
+</Tab>
598
+</Tabs>
599
+
600
+Without custom tools, `composio.use()` simply rehydrates the session:
601
+
602
+<Tabs groupId="language" items={['TypeScript', 'Python']} persist>
603
+<Tab value="TypeScript">
604
+```typescript
605
+// @noErrors
606
+import { Composio } from "@composio/core";
607
+const composio = new Composio({ apiKey: "your_api_key" });
608
+// ---cut---
609
+
610
+const session = await composio.use("session_id");
611
+```
612
+</Tab>
613
+<Tab value="Python">
614
+```python
615
+session = composio.use("session_id")
616
+```
617
+</Tab>
618
+</Tabs>
619
+
620
## Programmatic execution
621
622
Use `session.execute()` to run custom tools directly, outside of an agent loop. Custom tools execute in-process; remote tools are sent to the backend automatically.