636
</Tab>
637
</Tabs>
638
639
+## Attaching custom tools to an existing session
640
+
641
+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.
642
+
643
+<Tabs groupId="language" items={['TypeScript', 'Python']} persist>
644
+<Tab value="TypeScript">
645
+```typescript
646
+// @noErrors
647
+import { Composio, experimental_createTool } from "@composio/core";
648
+import { z } from "zod/v3";
649
+
650
+declare const getUserProfile: ReturnType<typeof experimental_createTool>;
651
+const composio = new Composio({ apiKey: "your_api_key" });
652
+// ---cut---
653
+
654
+// Rehydrate with custom tools
655
+const session = await composio.use("session_id", {
656
+ customTools: [getUserProfile],
657
+});
658
+
659
+const tools = await session.tools();
660
+```
661
+</Tab>
662
+<Tab value="Python">
663
+```python
664
+from composio import Composio
665
+
666
+composio = Composio(api_key="your_api_key")
667
+
668
+# Rehydrate with custom tools
669
+session = composio.use(
670
+ "session_id",
671
+ custom_tools=[get_user_profile],
672
+)
673
+
674
+tools = session.tools()
675
+```
676
+</Tab>
677
+</Tabs>
678
+
679
+Without custom tools, `composio.use()` simply rehydrates the session:
680
+
681
+<Tabs groupId="language" items={['TypeScript', 'Python']} persist>
682
+<Tab value="TypeScript">
683
+```typescript
684
+// @noErrors
685
+import { Composio } from "@composio/core";
686
+const composio = new Composio({ apiKey: "your_api_key" });
687
+// ---cut---
688
+
689
+const session = await composio.use("session_id");
690
+```
691
+</Tab>
692
+<Tab value="Python">
693
+```python
694
+session = composio.use("session_id")
695
+```
696
+</Tab>
697
+</Tabs>
698
+
699
## Programmatic execution
700
701
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.