Skip to content

I encountered an Error: 400 status code (no body) when using the creatReactAgent method #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
loverara opened this issue Mar 31, 2025 · 4 comments

Comments

@loverara
Copy link

library version

"langchain": "^0.3.19",
"@langchain/community": "^0.3.32",
"@langchain/core": "^0.3.40",
"@langchain/langgraph": "^0.2.49",
"@langchain/mcp-adapters": "^0.3.3",
"@langchain/openai": "^0.4.4"

The tools used are from the MCP server converted by @ langchain/mcp adapters

error messages
[NEST] 2025-03-31 16:26:46 error [AIFaucet.rootOutput] Error: 400 status code (no body) at Function.generate (/Users/loverara/Documents/code_workspace/vscode_workspace/ifuncun/agent_template/node_modules/openai/src/error.ts:72:14) at OpenAI.makeStatusError (/Users/loverara/Documents/code_workspace/vscode_workspace/ifuncun/agent_template/node_modules/openai/src/core.ts:443:21) at OpenAI.makeRequest (/Users/loverara/Documents/code_workspace/vscode_workspace/ifuncun/agent_template/node_modules/openai/src/core.ts:507:24) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /Users/loverara/Documents/code_workspace/vscode_workspace/ifuncun/agent_template/node_modules/@langchain/openai/dist/chat_models.cjs:1528:29

The error message I received when debugging to method completionWithRetry is
'{"object":"error","message":"\\"auto\\" tool choice requires --enable-auto-tool-choice and --tool-call-parser to be set","type":"BadRequestError","param":null,"code":400}'

@benjamincburns
Copy link
Collaborator

Hi @loverara - I think we're going to need more details on this. The error log and message you posted isn't familiar to me at all, and I don't think it comes this or any other langchain library, though I could be mistaken!

If you'd like help troubleshooting this could you please include a minimum reproducible example?

@phpmac
Copy link

phpmac commented Apr 8, 2025

Please provide code examples or change the model

@AyushNaptick
Copy link

AyushNaptick commented Apr 24, 2025

Hi team,

I am getting the below error during the createReactAgent function call with gpt-4o model. Can you please check and let me know what are the possible issues

 this.model = new ChatOpenAI({
      modelName: 'gpt-4o',
      openAIApiKey: // KEY,
      temperature: 0,
    });
const transport = new StdioClientTransport({
        command: "npx",
        args: ["-y", "mongodb-lens@latest", "MY_MONGO_DB_URL"]
      });
await this.clientMongo.connect(transport);
      const tools = await loadMcpTools("MongoDBMCP", this.clientMongo, {
        // Whether to throw errors if a tool fails to load (optional, default: true)
        throwOnLoadError: true,
        // Whether to prefix tool names with the server name (optional, default: false)
        prefixToolNameWithServerName: false,
        // Optional additional prefix for tool names (optional, default: "")
        additionalToolNamePrefix: "",
      });


 const agent = createReactAgent({ llm: this.model, tools });   
      const agentResponse = await agent.invoke({               // after calling this function I am getting the below error.
        messages: [{ role: "user", content: body.content }],
      });
TypeError: Cannot read properties of undefined (reading 'typeName')
    at parseDef (/Users/LangchainNest/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts:102:53)
    at zodToJsonSchema (/Users/LangchainNest/node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts:26:13)

@benjamincburns
Copy link
Collaborator

Closing this as the original poster has not replied. @AyushNaptick you are experiencing a different problem to the original poster. Please do not post comments on issues unrelated to your problem. Instead, open new issues. In your case I believe your problem is very likely resolved with the latest versions of @langchain/core, @langchain/mcp-adapters, and @langchain/openai. Please make sure that you have updated to latest versions of ALL of these libraries and retest. Then if you are still having issues, please open a new issue with a complete description and minimal reproducible example.

@benjamincburns benjamincburns closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants