https://linen.dev logo
not able to integrate with openai-agents-js
# 🖥│support-forum
r
Error: Error: Zod field at
#/definitions/SLACK_SEND_MESSAGE/properties/as_user
uses
.optional()
without
.nullable()
which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required
Copy code
import { Agent, tool, run } from "@openai/agents";
import dotenv from "dotenv";
import { Composio } from "@composio/client";
import { Composio as ComposioCore } from "@composio/core";
import { OpenAIAgentsProvider } from "@composio/openai-agents";

dotenv.config();

async function main() {
    console.log("Starting....");
    const composio = new Composio({
        apiKey: process.env.COMPOSIO_API_KEY!,
    });
    const composioCore = new ComposioCore({
        apiKey: process.env.COMPOSIO_API_KEY!,
        provider: new OpenAIAgentsProvider({
            strict: false,
        }),
    });
    const authConfigs = await composio.authConfigs.list({
        search: "slack_composio_managed_auth",
    });
    let exists = authConfigs.items.some(
        (cfg) => cfg.name === "slack_composio_managed_auth"
    );
    if (!exists) {
        throw new Error("Auth config does not exist");
    }
    let authConfig = authConfigs.items.find(
        (cfg) => cfg.name === "slack_composio_managed_auth"
    );
    if (!authConfig) {
        throw new Error("Auth config not found");
    }

    const tools = await composioCore.tools.get(
        "raj1234",
        {
            tools: [
                "SLACK_SENDS_A_MESSAGE_TO_A_SLACK_CHANNEL",
                "SLACK_SEND_MESSAGE",
            ],
        },
        {
            modifySchema: ({ toolSlug, toolkitSlug, schema }) => 
                let newSchema = { ...schema, strict: false };
                return newSchema;
            },
        }
    ); //
    console.log("Tools: ", tools);
}

main().catch((error) => {
    console.error("Error:", error);
    process.exit(1);
});
package.json
Copy code
"@composio/anthropic": "^0.1.50",
"@composio/core": "^0.1.50",
"@composio/openai-agents": "^0.1.50",
"@openai/agents": "^0.1.1",
"dotenv": "^17.2.2",
"express": "^4.19.2",
"zod": "^3.25.76"
c
Hi there, could you share your complete error logs? You can set
COMPOSIO_LOG_LEVEL=debug
in your env or export it in terminal to get complete logs.
r
first error which while using npm openai agents provider
Copy code
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @composio/openai-agents@0.1.50
npm error Found: @openai/agents@0.1.1
npm error node_modules/@openai/agents
npm error   @openai/agents@"^0.1.1" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @openai/agents@"^0.0.17" from @composio/openai-agents@0.1.50
npm error node_modules/@composio/openai-agents
npm error   @composio/openai-agents@"^0.1.50" from the root project
npm error
npm error Conflicting peer dependency: @openai/agents@0.0.17
npm error node_modules/@openai/agents
npm error   peer @openai/agents@"^0.0.17" from @composio/openai-agents@0.1.50
npm error   node_modules/@composio/openai-agents
npm error     @composio/openai-agents@"^0.1.50" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /Users/raj/.npm/_logs/2025-09-10T08_24_34_662Z-eresolve-report.txt
npm error A complete log of this run can be found in: /Users/raj/.npm/_logs/2025-09-10T08_24_34_662Z-debug-0.log
full error
Copy code
Error: Error: Zod field at `#/definitions/SLACK_SEND_MESSAGE/properties/as_user` uses `.optional()` without `.nullable()` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required
    at Object.entries.reduce.properties (/Users/raj/Code/pipedream/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/object.ts:55:17)
    at Array.reduce (<anonymous>)
    at parseObjectDef (/Users/raj/Code/pipedream/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/object.ts:33:36)
    at selectParser (/Users/raj/Code/pipedream/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts:181:28)
    at parseDef (/Users/raj/Code/pipedream/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts:102:22)
    at zodToJsonSchema (/Users/raj/Code/pipedream/node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts:26:13)
    at zodToJsonSchema (/Users/raj/Code/pipedream/node_modules/openai/src/helpers/zod.ts:16:26)
    at zodResponsesFunction (/Users/raj/Code/pipedream/node_modules/openai/src/helpers/zod.ts:145:19)
    at getSchemaAndParserFromInputType (/Users/raj/Code/pipedream/node_modules/@openai/agents-core/src/utils/tools.ts:51:51)
    at tool (/Users/raj/Code/pipedream/node_modules/@openai/agents-core/src/tool.ts:589:73) {
  errorId: '36eb066d-9dea-4a37-b0cc-1fc86fc2eadc'
}
c
Thanks for the information, we are checking this.
u
@rajnandan1 , it looks like your zod version is outdated. Could you try updating the ZOD to the latest, i.e. zod@4.1.5 and lmk if it works for you?
r
But openai agents works with zod3
c
i've forwarded the query to the team, they will be taking a look at this.
r
By when I can expect to hear back?
@Uday any luck?
c
Hey, let me check with the team and revert back.
u
Hey @rajnandan1, We've added a fix for the Issue. You can update the SDK version to
@composio/openai-agents@0.1.52
. This should support zod3. Also, please make sure the schema is not set to strict. Let me know if you face any issues.
r
Trying.
It worked đź’ź , But now I am getting this
Copy code
Using the first connected account for tool SLACK_SEND_MESSAGE. To change this behaviour please explicitly pass a connectedAccountId for the tool
the whole code I have attached https://cdn.discordapp.com/attachments/1415200359869059164/1415617033281863680/agents.ts?ex=68c3db99&is=68c28a19&hm=23ce93a2160678f294544faf16de9ec1c48dbb2b29cda1bb0c5dfb49b8c7596f&
It looks like you've mentioned the
user_id
. Let me quickly check this and revert back.
a
Hey @rajnandan1, this is not an issue per se, its just a info message we log. Connections can have the same
user_id
and if you specify the
user_id
while getting the tools // executing then the most recent connection would be used. You can override this by specifying the connected account ID in [before_execute](https://docs.composio.dev/docs/modifiers/before-execution)
Copy code
beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
   if (toolSlug === "GMAIL_FETCH_EMAILS") {
     params.connectedAccountId = "ca_..."
    }
   return params;
 },
r
Thanks. I have one last question when do I use @composio/core and @composio/client? or always use @composio/core?
a
You should be using the core, its built on top of client
l
Do you need developer?