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.

Chore: Update Openai dependencies to v5 and deprecate assistant API helper methods (#1878)

Musthaq Ahamadbb32cc2d8f96
diff --git a/.changeset/lemon-brooms-hunt.md b/.changeset/lemon-brooms-hunt.md
new file mode 100644
index 000000000..4da983414
--- /dev/null
+++ b/.changeset/lemon-brooms-hunt.md
@@ -0,0 +1,7 @@
+---
+'@composio/core': patch
+'@composio/openai': patch
+'@composio/openai-agents': patch
+---
+
+Bump openai responses and deprecate openai assistant
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e63fd5e91..617a0ca9f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -296,7 +296,7 @@ importers:
version: link:../../packages/providers/google
'@google/genai':
specifier: ^1.1.0
- version: 1.5.1(@modelcontextprotocol/[email protected])
+ version: 1.5.1(@modelcontextprotocol/[email protected])
dotenv:
specifier: ^16.4.1
version: 16.5.0
@@ -423,14 +423,14 @@ importers:
specifier: workspace:*
version: link:../../packages/providers/openai-agents
'@openai/agents':
- specifier: ^0.0.7
+ specifier: ^0.0.17
dotenv:
specifier: ^16.4.1
version: 16.5.0
openai:
- specifier: ^4.94.0
+ specifier: ^5.16.0
zod:
specifier: ^3.24.2
version: 3.25.67
@@ -652,8 +652,8 @@ importers:
specifier: ^4.1.2
version: 4.1.2
openai:
- specifier: ^4.94.0
+ specifier: ^5.16.0
pusher-js:
specifier: ^8.4.0
version: 8.4.0
@@ -750,7 +750,7 @@ importers:
dependencies:
'@google/genai':
specifier: ^1.1.0
- version: 1.5.1(@modelcontextprotocol/[email protected])
+ version: 1.5.1(@modelcontextprotocol/[email protected])
devDependencies:
'@composio/core':
specifier: workspace:*
@@ -766,7 +766,7 @@ importers:
dependencies:
'@langchain/core':
specifier: ^0.3.63
devDependencies:
'@composio/core':
specifier: workspace:*
@@ -803,8 +803,8 @@ importers:
ts/packages/providers/openai:
dependencies:
openai:
- specifier: ^4.3.8
+ specifier: ^5.16.0
devDependencies:
'@composio/core':
specifier: workspace:*
@@ -822,8 +822,8 @@ importers:
ts/packages/providers/openai-agents:
dependencies:
'@openai/agents':
- specifier: ^0.0.7
+ specifier: ^0.0.17
devDependencies:
'@composio/core':
specifier: workspace:*
@@ -2222,6 +2222,10 @@ packages:
resolution: {integrity: sha512-P5FZsXU0kY881F6Hbk9GhsYx02/KgWK1DYf7/tyE/1lcFKhDYPQR9iYjhQXJn+Sg6hQleMo3DB7h7+p4wgp2Lw==}
engines: {node: '>=18'}
+ '@modelcontextprotocol/[email protected]':
+ resolution: {integrity: sha512-zq24hfuAmmlNZvik0FLI58uE5sriN0WWsQzIlYnzSuKDAHFqJtBFrl/LfB1NLgJT5Y7dEBzaX4yAKqOPrcetaw==}
+ engines: {node: '>=18'}
+
'@msgpackr-extract/[email protected]':
resolution: {integrity: sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==}
cpu: [arm64]
@@ -2315,22 +2319,28 @@ packages:
resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
engines: {node: '>= 8'}
- '@openai/[email protected]':
- resolution: {integrity: sha512-qbJ0w20hTMUJM97q9aGWchr7kyNo35emvjKiVjCW/grR4sMJo1fLia4bE52tjCQGo8EZJBJ9bkjXFSqETjdJYw==}
+ '@openai/[email protected]':
+ resolution: {integrity: sha512-+V8rtwq8OtvCvXIVN/8ZFJNfQXLeCpeaBuFwJY7QBa44lIdMSB3vULcUVm1L7bTGKeVKpdB8GDky64hOFG4w7Q==}
peerDependencies:
zod: ^3.25.40
peerDependenciesMeta:
zod:
optional: true
- '@openai/[email protected]':
- resolution: {integrity: sha512-bWlJUZ6VutBnuESd74i9ttpIsfbw9kuH6mhHhN5bNgUjmbQfxM+2aUBfyxXGzr4mEvBkAuKiyAs3DX1shqOBdQ==}
+ '@openai/[email protected]':
+ resolution: {integrity: sha512-gGpcAWXh858HiNI51Nhl0MxM66asG0mv1LGASwB4jfzP7/GjM9k0on/ZlMBffM+6HID1zuDDYPbETD2y4XTY4w==}
+ peerDependencies:
+ zod: ^3.25.40
- '@openai/[email protected]':
- resolution: {integrity: sha512-ndPVQpOIX0J+C5wYo+YUb68q4zrXTIbQH/VS24qSIo9fxJokSxwS5P5hNSxDrdQ3+UlYyx/s1Xu6zRCE11H63Q==}
+ '@openai/[email protected]':
+ resolution: {integrity: sha512-9yxe93XKuy/pMhFMSrqAu0GlB3mpHh6J9ZGv6PdVpgQyc8uTmujJakMTsYBlogWHJNmGlWIRgf0+x8jIVoTv4A==}
+ peerDependencies:
+ zod: ^3.25.40
- '@openai/[email protected]':
- resolution: {integrity: sha512-qDQn7f33fCySEuEVP+PIpBASmD5bjxhzSglzJ3Z21JcRbLq+hxyBz6hpJy6sa0XOSgHh50u2nlsz+rogTizdew==}
+ '@openai/[email protected]':
+ resolution: {integrity: sha512-3tkN03WRLTTqcuzkopf37rAF6WtX0js3ciOqFn+EC1873J04Yf2m4xTYkYKT4RkwbOZh620+sIMPNKiUhW2rMg==}
+ peerDependencies:
+ zod: ^3.25.40
'@opentelemetry/[email protected]':
resolution: {integrity: sha512-IxcFDP1IGMDemVFG2by/AMK+/o6EuBQ8idUq3xZ6MxgQGeumYZuX5OwR0h9HuvcUc/JPjQGfU5OHKIKYDJcXeA==}
@@ -5787,6 +5797,18 @@ packages:
zod:
optional: true
+ resolution: {integrity: sha512-hoEH8ZNvg1HXjU9mp88L/ZH8O082Z8r6FHCXGiWAzVRrEv443aI57qhch4snu07yQydj+AUAWLenAiBXhu89Tw==}
+ hasBin: true
+ peerDependencies:
+ ws: ^8.18.0
+ zod: ^3.23.8
+ peerDependenciesMeta:
+ ws:
+ optional: true
+ zod:
+ optional: true
+
resolution: {integrity: sha512-5i19097mGotHA1eFsM6Tjd/tJ8uo9sa5Ysv4Q6bKJ2vtN6rc0MzMrUefXnLXYAJcmMQrC1Efhj0AvfIkXrQamw==}
hasBin: true
@@ -8273,14 +8295,14 @@ snapshots:
'@shikijs/types': 3.6.0
'@shikijs/vscode-textmate': 10.0.2
- '@google/[email protected](@modelcontextprotocol/[email protected])':
+ '@google/[email protected](@modelcontextprotocol/[email protected])':
dependencies:
google-auth-library: 9.15.1
ws: 8.18.2
zod: 3.25.67
zod-to-json-schema: 3.24.5([email protected])
optionalDependencies:
- '@modelcontextprotocol/sdk': 1.13.0
+ '@modelcontextprotocol/sdk': 1.17.4
transitivePeerDependencies:
- bufferutil
- encoding
@@ -8630,14 +8652,14 @@ snapshots:
transitivePeerDependencies:
- openai
dependencies:
'@cfworker/json-schema': 4.1.1
ansi-styles: 5.2.0
camelcase: 6.3.0
decamelize: 1.2.0
js-tiktoken: 1.0.20
mustache: 4.2.0
p-queue: 6.6.2
p-retry: 4.6.2
@@ -8888,6 +8910,24 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@modelcontextprotocol/[email protected]':
+ dependencies:
+ ajv: 6.12.6
+ content-type: 1.0.5
+ cors: 2.8.5
+ cross-spawn: 7.0.6
+ eventsource: 3.0.7
+ eventsource-parser: 3.0.3
+ express: 5.1.0
+ express-rate-limit: 7.5.0([email protected])
+ pkce-challenge: 5.0.0
+ raw-body: 3.0.0
+ zod: 3.25.67
+ zod-to-json-schema: 3.24.5([email protected])
+ transitivePeerDependencies:
+ - supports-color
+ optional: true
+
'@msgpackr-extract/[email protected]':
optional: true
@@ -8944,55 +8984,52 @@ snapshots:
'@nodelib/fs.scandir': 2.1.5
fastq: 1.19.1
dependencies:
- '@openai/zod': [email protected]
debug: 4.4.1([email protected])
optionalDependencies:
- '@modelcontextprotocol/sdk': 1.13.0
+ '@modelcontextprotocol/sdk': 1.17.4
zod: 3.25.67
transitivePeerDependencies:
- supports-color
- ws
dependencies:
- '@openai/agents-core': 0.0.7([email protected])([email protected])
- '@openai/zod': [email protected]
+ '@openai/agents-core': 0.0.17([email protected])([email protected])
debug: 4.4.1([email protected])
+ zod: 3.25.67
transitivePeerDependencies:
- supports-color
- ws
- - zod
dependencies:
- '@openai/agents-core': 0.0.7([email protected])([email protected])
- '@openai/zod': [email protected]
+ '@openai/agents-core': 0.0.17([email protected])([email protected])
'@types/ws': 8.18.1
debug: 4.4.1([email protected])
ws: 8.18.2
+ zod: 3.25.67
transitivePeerDependencies:
- bufferutil
- supports-color
- utf-8-validate
- - zod
dependencies:
- '@openai/agents-core': 0.0.7([email protected])([email protected])
- '@openai/agents-openai': 0.0.7([email protected])([email protected])
- '@openai/agents-realtime': 0.0.7([email protected])
+ '@openai/agents-core': 0.0.17([email protected])([email protected])
+ '@openai/agents-openai': 0.0.17([email protected])([email protected])
+ '@openai/agents-realtime': 0.0.17([email protected])
debug: 4.4.1([email protected])
+ zod: 3.25.67
transitivePeerDependencies:
- bufferutil
- supports-color
- utf-8-validate
- ws
- - zod
'@opentelemetry/[email protected]':
dependencies:
@@ -12689,7 +12726,7 @@ snapshots:
optionalDependencies:
dependencies:
'@types/uuid': 10.0.0
chalk: 4.1.2
@@ -12699,7 +12736,7 @@ snapshots:
semver: 7.7.2
uuid: 10.0.0
optionalDependencies:
dependencies:
@@ -13065,6 +13102,11 @@ snapshots:
transitivePeerDependencies:
- encoding
+ optionalDependencies:
+ ws: 8.18.2
+ zod: 3.25.67
+
optionalDependencies:
ws: 8.18.2
diff --git a/ts/examples/openai/package.json b/ts/examples/openai/package.json
index 81d9d9cf0..23b17014d 100644
--- a/ts/examples/openai/package.json
+++ b/ts/examples/openai/package.json
@@ -22,13 +22,13 @@
"@composio/core": "workspace:*",
"@composio/openai": "workspace:*",
"@composio/openai-agents": "workspace:*",
- "@openai/agents": "^0.0.7",
+ "@openai/agents": "^0.0.17",
"dotenv": "^16.4.1",
- "openai": "^4.94.0",
+ "openai": "^5.16.0",
"zod": "^3.24.2"
},
"devDependencies": {
"@types/bun": "^1.2.9",
"typescript": "^5.8.3"
}
-}
+}
\ No newline at end of file
diff --git a/ts/examples/openai/src/assistants.ts b/ts/examples/openai/src/assistants.ts
deleted file mode 100644
index dbbbdf4a5..000000000
--- a/ts/examples/openai/src/assistants.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * OpenAI Assistants with Composio Tool Example
- *
- * This example demonstrates how to use the Composio OpenAIProvider with OpenAI Assistants API.
- * It uses the HACKERNEWS_GET_USER tool to fetch information about a HackerNews user.
- */
-import { Composio } from '@composio/core';
-import { OpenAI } from 'openai';
-import dotenv from 'dotenv';
-
-dotenv.config();
-
-const openai = new OpenAI({
- apiKey: process.env.OPENAI_API_KEY,
-});
-
-const composio = new Composio({
- apiKey: process.env.COMPOSIO_API_KEY,
-});
-
-/**
- * Main function to demonstrate OpenAI Assistants with Composio tool
- */
-async function main() {
- try {
- console.log('πŸ”„ Setting up Composio and fetching tool...');
-
- const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
-
- console.log('πŸ”„ Creating OpenAI Assistant with Composio tool...');
-
- const assistant = await openai.beta.assistants.create({
- name: 'HackerNews Helper',
- instructions:
- 'You are a helpful assistant that can fetch information about HackerNews users.',
- model: 'gpt-4o',
- tools: tools,
- });
-
- console.log(`βœ… Assistant created with ID: ${assistant.id}`);
-
- const thread = await openai.beta.threads.create();
- console.log(`βœ… Thread created with ID: ${thread.id}`);
-
- const query = "Get information about the HackerNews user 'pg'";
- console.log(`πŸ”„ Adding message to thread: "${query}"`);
-
- await openai.beta.threads.messages.create(thread.id, {
- role: 'user',
- content: query,
- });
-
- console.log('πŸ”„ Running the assistant...');
- const run = await openai.beta.threads.runs.create(thread.id, {
- assistant_id: assistant.id,
- });
-
- console.log('πŸ”„ Waiting for assistant response and handling tool calls...');
- const completedRun = await composio.provider.waitAndHandleAssistantToolCalls(
- 'default',
- openai,
- run,
- thread
- );
-
- console.log(`βœ… Run completed with status: ${completedRun.status}`);
-
- const messages = await openai.beta.threads.messages.list(thread.id);
-
- console.log('πŸ€– Assistant responses:');
- for (const message of messages.data) {
- if (message.role === 'assistant') {
- for (const content of message.content) {
- if (content.type === 'text') {
- console.log(`- ${content.text.value}`);
- }
- }
- }
- }
-
- await openai.beta.assistants.del(assistant.id);
- console.log('🧹 Cleaned up: Assistant deleted');
- } catch (error) {
- console.error('❌ Error:', error);
- }
-}
-
-main();
diff --git a/ts/examples/openai/src/chat-completions.ts b/ts/examples/openai/src/chat-completions.ts
index 01553f7b2..c1f91495a 100644
--- a/ts/examples/openai/src/chat-completions.ts
+++ b/ts/examples/openai/src/chat-completions.ts
@@ -44,7 +44,7 @@ async function main() {
tool_choice: 'auto',
});
- if (response.choices[0].message.tool_calls) {
+ if (response.choices[0].message.tool_calls && response.choices[0].message.tool_calls[0].type === 'function') {
console.log(
'πŸ”§ Assistant is using tool:',
response.choices[0].message.tool_calls[0].function.name
diff --git a/ts/examples/openai/src/index.ts b/ts/examples/openai/src/index.ts
index 962483290..0fe88f597 100644
--- a/ts/examples/openai/src/index.ts
+++ b/ts/examples/openai/src/index.ts
@@ -44,8 +44,13 @@ const response = await openai.chat.completions.create({
/**
* If the assistant has tool calls, execute them and log the result
*/
-if (response.choices[0].message.tool_calls) {
- console.log(`βœ… Calling tool ${response.choices[0].message.tool_calls[0].function.name}`);
+if (response.choices[0].message.tool_calls && response.choices[0].message.tool_calls[0].type === 'function') {
+ console.log(JSON.stringify(response, null, 2));
+ const toolCall = response.choices[0].message.tool_calls[0];
+ if (toolCall.type === 'function') {
+
+ console.log(`βœ… Calling tool ${response.choices[0].message.tool_calls[0].function.name}`);
+ }
const result = await composio.provider.handleToolCalls('default', response);
console.log(result);
}
diff --git a/ts/examples/openai/src/mcp.ts b/ts/examples/openai/src/mcp.ts
deleted file mode 100644
index 15feda4ae..000000000
--- a/ts/examples/openai/src/mcp.ts
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * OpenAI MCP Gmail Example
- *
- * This example demonstrates how to use Composio MCP with OpenAI to:
- * 1. Create an MCP server for Gmail toolkit
- * 2. Generate URLs for the server
- * 3. Use OpenAI to summarize emails
- *
- */
-
-import { OpenAIResponsesProvider } from '@composio/openai';
-import { Composio, ConnectionStatus } from '@composio/core';
-import OpenAI from 'openai';
-import dotenv from 'dotenv';
-dotenv.config();
-
-/**
- * Initialize Composio with OpenAI provider
- */
-const composio = new Composio({
- apiKey: process.env.COMPOSIO_API_KEY,
- provider: new OpenAIResponsesProvider(),
-});
-
-/**
- * Initialize OpenAI client
- */
-const openai = new OpenAI({
- apiKey: process.env.OPENAI_API_KEY,
-});
-
-const MCP_SERVER_NAME = "gmail-readonly-server";
-const USER_ID = "utkarsh";
-
-/**
- * Get or create MCP server
- */
-async function getOrCreateMCPServer() {
- try {
- // Check if MCP server with name already exists
- const existingServer = await composio.mcp.getByName(MCP_SERVER_NAME);
- console.log(`βœ… Found existing MCP server: ${existingServer.id}`);
- return existingServer;
- } catch (error) {
- // Server doesn't exist, create a new one
- console.log(`πŸ“ Creating new MCP server: ${MCP_SERVER_NAME}`);
-
- // Get available auth configs for Gmail
- const authConfigsResponse = await composio.authConfigs.list();
- const gmailAuthConfig = authConfigsResponse.items.find((config) =>
- config.name?.toLowerCase().includes('gmail') ||
- config.name?.toLowerCase().includes('google')
- );
-
- if (!gmailAuthConfig) {
- throw new Error('No Gmail/Google auth config found. Please create one first.');
- }
-
- // Create MCP server using the new API signature
- await composio.mcp.create(
- MCP_SERVER_NAME,
- [
- {
- authConfigId: gmailAuthConfig.id,
- allowedTools: [
- "GMAIL_FETCH_EMAILS"
- ]
- }
- ],
- {
- isChatAuth: true
- }
- );
-
- // Get the newly created server details
- const newServer = await composio.mcp.getByName(MCP_SERVER_NAME);
- console.log(`βœ… MCP server created: ${newServer.id}`);
- return newServer;
- }
-}
-
-/**
- * Handle authentication for disconnected toolkits
- */
-async function handleAuthentication(serverId: string) {
- const connectionStatus = await composio.mcp.getUserConnectionStatus(
- USER_ID,
- serverId
- );
-
- console.log("Connection status:", connectionStatus);
-
- const toolkits = connectionStatus.connectedToolkits;
-
- for (let toolkit of Object.values(toolkits)) {
- if (toolkit.type === ConnectionStatus.DISCONNECTED) {
- try {
- const requiredParams = await composio.mcp.getConnectionParams(
- serverId,
- toolkit.toolkit
- );
- console.log("Required params:", requiredParams);
-
- const authStatus = await composio.mcp.authorize(
- serverId,
- USER_ID,
- toolkit.toolkit
- );
- console.log("Connection status:", authStatus);
-
- if (authStatus.redirectUrl) {
- console.log(`Please complete the authentication by visiting the following URL: ${authStatus.redirectUrl}`);
- console.log("Press 'Enter' once you have completed the authentication.");
- await new Promise(resolve => process.stdin.once('data', resolve));
- }
- } catch (error) {
- console.error(`Error handling authentication for ${toolkit.toolkit}:`, error);
- }
- }
- }
-}
-
-/**
- * Fetch and summarize emails using OpenAI
- */
-async function fetchAndSummarizeEmails(serverUrls: unknown) {
- try {
- console.log('\n=== Generating Email Summary ===');
- const completion = await openai.responses.create({
- model: "gpt-4o-mini",
- input: "I've connected to gmail and I want to fetch the latest email from my inbox and summarize it",
- tools: serverUrls,
- });
-
- console.log('\nπŸ“¬ Email Summary:');
- console.log(completion.output_text);
-
- } catch (error) {
- console.error('Error fetching or summarizing emails:', error);
- throw error;
- }
-}
-
-/**
- * Main function to run the MCP example
- */
-async function main() {
- try {
- // Validate environment variables
- if (!process.env.COMPOSIO_API_KEY) {
- throw new Error('COMPOSIO_API_KEY environment variable is required');
- }
- if (!process.env.OPENAI_API_KEY) {
- throw new Error('OPENAI_API_KEY environment variable is required');
- }
-
- // Get or create MCP server
- const server = await getOrCreateMCPServer();
- console.log("Server details:", server);
-
- // Handle authentication for disconnected toolkits
- await handleAuthentication(server.id);
-
- // Get server URLs with user ID using the new API signature
- const serverUrls = await composio.mcp.getServer(
- server.id,
- USER_ID,
- {
- limitTools: ["GMAIL_FETCH_EMAILS"],
- isChatAuth: true
- }
- );
-
- // Fetch and summarize emails
- await fetchAndSummarizeEmails(serverUrls);
-
- console.log('\nβœ… OpenAI MCP Example completed successfully!');
- console.log('\nπŸ’‘ Note: The MCP server URLs can be used to connect from other MCP-compatible clients');
- console.log(`πŸ“ Server ID for future reference: ${server.id}`);
-
- } catch (error) {
- console.error('❌ Error running MCP example:', error);
- process.exit(1);
- }
-}
-
-// Run the example
-main();
diff --git a/ts/examples/triggers/src/create.ts b/ts/examples/triggers/src/create.ts
index ac7b7e214..051d9bfd1 100644
--- a/ts/examples/triggers/src/create.ts
+++ b/ts/examples/triggers/src/create.ts
@@ -11,12 +11,8 @@ console.log(JSON.stringify(triggerType, null, 2));
// create a trigger
const trigger = await composio.triggers.create('default', triggerType.slug, {
- connectedAccountId: 'ca_jjYIG9L40LDIS',
- triggerConfig: {
- labelIds: 'INBOX',
- userId: 'me',
- interval: 60,
- },
+ connectedAccountId: 'ca_uQvmu9uZOhQo',
+ triggerConfig: {},
});
console.log(trigger);
diff --git a/ts/packages/core/package.json b/ts/packages/core/package.json
index 9e7ef5613..3694f8955 100644
--- a/ts/packages/core/package.json
+++ b/ts/packages/core/package.json
@@ -48,7 +48,7 @@
"@composio/json-schema-to-zod": "0.1.13",
"@types/json-schema": "^7.0.15",
"chalk": "^4.1.2",
- "openai": "^4.94.0",
+ "openai": "^5.16.0",
"pusher-js": "^8.4.0",
"semver": "^7.7.2",
"uuid": "^11.1.0",
diff --git a/ts/packages/core/src/provider/OpenAIProvider.ts b/ts/packages/core/src/provider/OpenAIProvider.ts
index c73a55038..47e91fbc1 100644
--- a/ts/packages/core/src/provider/OpenAIProvider.ts
+++ b/ts/packages/core/src/provider/OpenAIProvider.ts
@@ -175,7 +175,7 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
*/
async executeToolCall(
userId: string,
- tool: OpenAI.ChatCompletionMessageToolCall,
+ tool: OpenAI.ChatCompletionMessageFunctionToolCall,
options?: ExecuteToolFnOptions,
modifiers?: ExecuteToolModifiers
): Promise<string> {
@@ -240,7 +240,7 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
): Promise<OpenAI.ChatCompletionToolMessageParam[]> {
const outputs: OpenAI.ChatCompletionToolMessageParam[] = [];
for (const message of chatCompletion.choices) {
- if (message.message.tool_calls) {
+ if (message.message.tool_calls && message.message.tool_calls[0].type === 'function') {
const toolResult = await this.executeToolCall(
userId,
message.message.tool_calls[0],
@@ -263,12 +263,15 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
* This method processes tool calls from an OpenAI Assistant run,
* executes each tool call, and returns the tool outputs for submission.
*
+ * @deprecated Assistant API is deprecated, please use responses or chat completions instead. This method will be removed in the next major version.
+ *
* @param {string} userId - The user ID for authentication and tracking
* @param {OpenAI.Beta.Threads.Run} run - The Assistant run object containing tool calls
* @param {ExecuteToolFnOptions} [options] - Optional execution options
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
* @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
*
+ *
* @example
* ```typescript
* // Handle tool calls from an OpenAI Assistant run
@@ -319,7 +322,7 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
// Execute each tool call and get the response
const tool_response = await this.executeToolCall(
userId,
- tool_call as OpenAI.ChatCompletionMessageToolCall,
+ tool_call as OpenAI.ChatCompletionMessageFunctionToolCall,
options,
modifiers
);
@@ -342,6 +345,8 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
* that require action, and yields each event from the stream. It's designed
* for streaming Assistant responses while handling tool calls in real-time.
*
+ * @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
+ *
* @param {string} userId - The user ID for authentication and tracking
* @param {OpenAI} client - The OpenAI client instance
* @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The Assistant run stream
@@ -350,6 +355,8 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
* @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} Generator yielding stream events
*
+ *
+ *
* @example
* ```typescript
* // Process an OpenAI Assistant stream with tool calls
@@ -410,7 +417,8 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
);
// Submit the tool outputs
- await client.beta.threads.runs.submitToolOutputs(thread.id, runId, {
+ await client.beta.threads.runs.submitToolOutputs(runId, {
+ thread_id: thread.id,
tool_outputs: toolOutputs,
});
}
@@ -433,19 +441,24 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
}
// Handle any final actions after the stream ends
- let finalRun = await client.beta.threads.runs.retrieve(thread.id, runId);
+ let finalRun = await client.beta.threads.runs.retrieve(runId, {
+ thread_id: thread.id,
+ });
while (['queued', 'in_progress', 'requires_action'].includes(finalRun.status)) {
if (finalRun.status === 'requires_action') {
const toolOutputs = await this.handleAssistantMessage(userId, finalRun, options, modifiers);
// Submit tool outputs
- finalRun = await client.beta.threads.runs.submitToolOutputs(thread.id, runId, {
+ finalRun = await client.beta.threads.runs.submitToolOutputs(runId, {
+ thread_id: thread.id,
tool_outputs: toolOutputs,
});
} else {
// Update the run status
- finalRun = await client.beta.threads.runs.retrieve(thread.id, runId);
+ finalRun = await client.beta.threads.runs.retrieve(runId, {
+ thread_id: thread.id,
+ });
await new Promise(resolve => setTimeout(resolve, 500)); // Wait before rechecking
}
}
@@ -458,6 +471,8 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
* handles any tool calls, and returns the final run object. It's designed for
* non-streaming Assistant interactions.
*
+ * @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
+ *
* @param {string} userId - The user ID for authentication and tracking
* @param {OpenAI} client - The OpenAI client instance
* @param {OpenAI.Beta.Threads.Run} run - The initial run object
@@ -509,11 +524,14 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
// logger.debug(
// `Submitting tool outputs for run ID: ${run.id} in thread ID: ${thread.id}`
// );
- run = await client.beta.threads.runs.submitToolOutputs(thread.id, run.id, {
+ run = await client.beta.threads.runs.submitToolOutputs(run.id, {
+ thread_id: thread.id,
tool_outputs: tool_outputs,
});
} else {
- run = await client.beta.threads.runs.retrieve(thread.id, run.id);
+ run = await client.beta.threads.runs.retrieve(run.id, {
+ thread_id: thread.id,
+ });
await new Promise(resolve => setTimeout(resolve, 500));
}
}
diff --git a/ts/packages/core/test/provider/openai-provider.test.ts b/ts/packages/core/test/provider/openai-provider.test.ts
index 4f2f07781..830782836 100644
--- a/ts/packages/core/test/provider/openai-provider.test.ts
+++ b/ts/packages/core/test/provider/openai-provider.test.ts
@@ -74,8 +74,10 @@ describe('OpenAIProvider', () => {
const wrapped = provider.wrapTools(tools);
expect(wrapped).toHaveLength(2);
- expect(wrapped[0].function.name).toBe(mockTool.slug);
- expect(wrapped[1].function.name).toBe(anotherTool.slug);
+ expect((wrapped[0] as OpenAI.ChatCompletionFunctionTool).function.name).toBe(mockTool.slug);
+ expect((wrapped[1] as OpenAI.ChatCompletionFunctionTool).function.name).toBe(
+ anotherTool.slug
+ );
});
});
@@ -89,7 +91,7 @@ describe('OpenAIProvider', () => {
name: 'test-tool',
arguments: JSON.stringify({ input: 'test-value' }),
},
- } as OpenAI.ChatCompletionMessageToolCall;
+ } as OpenAI.ChatCompletionMessageFunctionToolCall;
const result = await provider.executeToolCall(userId, toolCall);
@@ -115,7 +117,7 @@ describe('OpenAIProvider', () => {
name: 'test-tool',
arguments: JSON.stringify({ input: 'test-value' }),
},
- } as OpenAI.ChatCompletionMessageToolCall;
+ } as OpenAI.ChatCompletionMessageFunctionToolCall;
const options = {
connectedAccountId: 'conn-123',
@@ -419,19 +421,18 @@ describe('OpenAIProvider', () => {
undefined,
undefined
);
- expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith(
- 'thread-123',
- 'run-123',
- {
- tool_outputs: [
- {
- tool_call_id: 'call-123',
- output: JSON.stringify({ result: 'success' }),
- },
- ],
- }
- );
- expect(client.beta.threads.runs.retrieve).toHaveBeenCalledWith('thread-123', 'run-123');
+ expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith('run-123', {
+ thread_id: 'thread-123',
+ tool_outputs: [
+ {
+ tool_call_id: 'call-123',
+ output: JSON.stringify({ result: 'success' }),
+ },
+ ],
+ });
+ expect(client.beta.threads.runs.retrieve).toHaveBeenCalledWith('run-123', {
+ thread_id: 'thread-123',
+ });
expect(result).toEqual(completedRun);
});
});
@@ -543,18 +544,15 @@ describe('OpenAIProvider', () => {
undefined,
undefined
);
- expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith(
- 'thread-123',
- 'run-123',
- {
- tool_outputs: [
- {
- tool_call_id: 'call-123',
- output: JSON.stringify({ result: 'success' }),
- },
- ],
- }
- );
+ expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith('run-123', {
+ thread_id: 'thread-123',
+ tool_outputs: [
+ {
+ tool_call_id: 'call-123',
+ output: JSON.stringify({ result: 'success' }),
+ },
+ ],
+ });
});
});
});
diff --git a/ts/packages/providers/openai-agents/package.json b/ts/packages/providers/openai-agents/package.json
index 210dfe052..4d2057d18 100644
--- a/ts/packages/providers/openai-agents/package.json
+++ b/ts/packages/providers/openai-agents/package.json
@@ -31,7 +31,7 @@
"packageManager": "[email protected]",
"peerDependencies": {
"@composio/core": "0.1.47",
- "@openai/agents": "^0.0.7"
+ "@openai/agents": "^0.0.17"
},
"devDependencies": {
"@composio/core": "workspace:*",
diff --git a/ts/packages/providers/openai/package.json b/ts/packages/providers/openai/package.json
index b22ede9fb..9c9d80f8d 100644
--- a/ts/packages/providers/openai/package.json
+++ b/ts/packages/providers/openai/package.json
@@ -31,7 +31,7 @@
"packageManager": "[email protected]",
"peerDependencies": {
"@composio/core": "0.1.47",
- "openai": "^4.3.8"
+ "openai": "^5.16.0"
},
"devDependencies": {
"@composio/core": "workspace:*",
diff --git a/ts/packages/providers/openai/src/OpenAIResponsesProvider.ts b/ts/packages/providers/openai/src/OpenAIResponsesProvider.ts
index f13d9b1fa..9e9c35b2e 100644
--- a/ts/packages/providers/openai/src/OpenAIResponsesProvider.ts
+++ b/ts/packages/providers/openai/src/OpenAIResponsesProvider.ts
@@ -42,7 +42,7 @@ export interface OpenAIMcpServerResponse {
export class OpenAIResponsesProvider extends BaseNonAgenticProvider<
OpenAiToolCollection,
OpenAiTool,
- OpenAIMcpServerResponse[]
+ OpenAiMcpTool[]
> {
readonly name = 'openai';
private strict: boolean | null;
diff --git a/ts/packages/providers/openai/test/openai.test.ts b/ts/packages/providers/openai/test/openai.test.ts
index be32dd6c6..fb9d766d2 100644
--- a/ts/packages/providers/openai/test/openai.test.ts
+++ b/ts/packages/providers/openai/test/openai.test.ts
@@ -10,10 +10,10 @@ vi.mock('openai', () => {
beta: {
threads: {
runs: {
- retrieve: vi.fn().mockImplementation((threadId, runId) => {
+ retrieve: vi.fn().mockImplementation((runId, options) => {
return { id: runId, status: 'completed' };
}),
- submitToolOutputs: vi.fn().mockImplementation((threadId, runId, options) => {
+ submitToolOutputs: vi.fn().mockImplementation((runId, options) => {
return { id: runId, status: 'completed' };
}),
},
@@ -172,7 +172,7 @@ describe('OpenAIProvider', () => {
name: 'test-tool',
arguments: JSON.stringify({ input: 'test-value' }),
},
- } as OpenAI.ChatCompletionMessageToolCall;
+ } as OpenAI.ChatCompletionMessageFunctionToolCall;
const result = await provider.executeToolCall(userId, toolCall);
@@ -218,7 +218,12 @@ describe('OpenAIProvider', () => {
afterExecute: vi.fn(({ result }) => result),
};
- await provider.executeToolCall(userId, toolCall, options, modifiers);
+ await provider.executeToolCall(
+ userId,
+ toolCall as OpenAI.ChatCompletionMessageFunctionToolCall,
+ options,
+ modifiers
+ );
expect(mockExecuteToolFn).toHaveBeenCalledWith(
'test-tool',
@@ -500,7 +505,8 @@ describe('OpenAIProvider', () => {
const result = await provider.waitAndHandleAssistantToolCalls(userId, client, run, thread);
expect(handleAssistantMessageSpy).toHaveBeenCalledWith(userId, run, undefined, undefined);
- expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith(thread.id, run.id, {
+ expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith(run.id, {
+ thread_id: thread.id,
tool_outputs: [
{
tool_call_id: 'tool-call-123',