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.

Clean up request execution

haxzie1f363e42e488
diff --git a/examples/openai/src/index.ts b/examples/openai/src/index.ts
index 0ac296ce3..669b7c93f 100644
--- a/examples/openai/src/index.ts
+++ b/examples/openai/src/index.ts
@@ -33,6 +33,11 @@ const response = await openai.chat.completions.create({
if (response.choices[0].message.tool_calls) {
- const result = await composio.toolset.executeToolCall(response.choices[0].message.tool_calls[0]);
- console.log(JSON.stringify(result, null, 2));
+ try {
+
+ const result = await composio.toolset.executeToolCall(response.choices[0].message.tool_calls[0]);
+ console.log(JSON.stringify(result, null, 2));
+ } catch (error) {
+ console.error(JSON.stringify(error, null, 2));
+ }
}
\ No newline at end of file
diff --git a/packages/toolsets/openai/src/index.ts b/packages/toolsets/openai/src/index.ts
index 62ed7c372..0d2c357f5 100644
--- a/packages/toolsets/openai/src/index.ts
+++ b/packages/toolsets/openai/src/index.ts
@@ -62,12 +62,13 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
const appName = toolSchema?.toolkit?.name.toLowerCase();
const connectedAccountId = this.client.getConnectedAccountId(appName);
-
- const results = await this.client.tools.execute(toolSchema.slug, {
- arguments: JSON.parse(tool.function.arguments),
+ const payload = {
entity_id: userId ?? this.client.userId,
connected_account_id: connectedAccountId,
- });
+ arguments: JSON.parse(tool.function.arguments),
+ }
+
+ const results = await this.client.tools.execute(toolSchema.slug, payload);
return JSON.stringify(results);
}