Skip to content

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

Fix method binding in tool router (#2328)

Musthaq Ahamad019f54f157dd
diff --git a/.changeset/dark-zoos-own.md b/.changeset/dark-zoos-own.md
new file mode 100644
index 000000000..c5c8b1df7
--- /dev/null
+++ b/.changeset/dark-zoos-own.md
@@ -0,0 +1,5 @@
+---
+'@composio/core': patch
+---
+
+Fix method binding for top level tool router methods
diff --git a/ts/packages/core/src/composio.ts b/ts/packages/core/src/composio.ts
index ec81b2e92..e4b4c44ef 100644
--- a/ts/packages/core/src/composio.ts
+++ b/ts/packages/core/src/composio.ts
@@ -272,14 +272,13 @@ export class Composio<
this.files = new Files(this.client);
this.connectedAccounts = new ConnectedAccounts(this.client);
this.toolRouter = new ToolRouter(this.client, this.config);
- this.toolRouter.create.bind(this.toolRouter);
- this.toolRouter.use.bind(this.toolRouter);
/**
* Initialize tool router methods
+ * Properly bind the methods to maintain the correct 'this' context
*/
- this.create = this.toolRouter.create;
- this.use = this.toolRouter.use;
+ this.create = this.toolRouter.create.bind(this.toolRouter);
+ this.use = this.toolRouter.use.bind(this.toolRouter);
/**
* Initialize Experimental features