400 Missing required parameter: 'messages[3].content[0].type' on tool execution #70

Closed
opened 2026-02-15 17:15:23 -05:00 by yindo · 7 comments
Owner

Originally created by @khakra on GitHub (Aug 24, 2024).

We have a plan and execute workflow that was working fine on previous versions of the langchain / langgraph libraries -

"langchain": "^0.2.5",
"@langchain/community": "^0.2.6",
"@langchain/core": "^0.2.6",
"@langchain/langgraph": "^0.0.21",
"@langchain/openai": "^0.1.1",

We updated the libraries to the latest versions so we could add support for a custom Redis checkpoint.
But after updating the libraries to the below versions, the workflow started to fail at executeStep() -

"langchain": "^0.2.17",
"@langchain/community": "^0.2.31",
"@langchain/core": "^0.2.28",
"@langchain/langgraph": "^0.1.1",
"@langchain/openai": "^0.2.7",

The full error dump is below -

BadRequestError: 400 Missing required parameter: 'messages[3].content[0].type'.
    at APIError.generate (webpack-internal:///(rsc)/./node_modules/.pnpm/openai@4.56.0_zod@3.23.8/node_modules/openai/error.mjs:60:20)
    at OpenAI.makeStatusError (webpack-internal:///(rsc)/./node_modules/.pnpm/openai@4.56.0_zod@3.23.8/node_modules/openai/core.mjs:304:65)
    at OpenAI.makeRequest (webpack-internal:///(rsc)/./node_modules/.pnpm/openai@4.56.0_zod@3.23.8/node_modules/openai/core.mjs:347:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@langchain+openai@0.2.7_langchain@0.2.17_@langchain+community@0.2.31_ignore@5.3.1_openai@4.56.0_zod@3.23.8__/node_modules/@langchain/openai/dist/chat_models.js:1322:29)
    at async RetryOperation.eval [as _fn] (webpack-internal:///(rsc)/./node_modules/.pnpm/p-retry@4.6.2/node_modules/p-retry/index.js:50:12) {
  status: 400,
  request_id: 'req_xxx',
  error: {
    message: "Missing required parameter: 'messages[3].content[0].type'.",
    type: 'invalid_request_error',
    param: 'messages[3].content[0].type',
    code: 'missing_required_parameter'
  },
  code: 'missing_required_parameter',
  param: 'messages[3].content[0].type',
  type: 'invalid_request_error',
  attemptNumber: 1,
  retriesLeft: 6,
  pregelTaskId: '12345678-1234-5678-0000-000000000000'
}
Originally created by @khakra on GitHub (Aug 24, 2024). We have a plan and execute workflow that was working fine on previous versions of the langchain / langgraph libraries - ``` "langchain": "^0.2.5", "@langchain/community": "^0.2.6", "@langchain/core": "^0.2.6", "@langchain/langgraph": "^0.0.21", "@langchain/openai": "^0.1.1", ``` We updated the libraries to the latest versions so we could add support for a custom Redis checkpoint. But after updating the libraries to the below versions, the workflow started to fail at `executeStep()` - ``` "langchain": "^0.2.17", "@langchain/community": "^0.2.31", "@langchain/core": "^0.2.28", "@langchain/langgraph": "^0.1.1", "@langchain/openai": "^0.2.7", ``` The full error dump is below - ``` BadRequestError: 400 Missing required parameter: 'messages[3].content[0].type'. at APIError.generate (webpack-internal:///(rsc)/./node_modules/.pnpm/openai@4.56.0_zod@3.23.8/node_modules/openai/error.mjs:60:20) at OpenAI.makeStatusError (webpack-internal:///(rsc)/./node_modules/.pnpm/openai@4.56.0_zod@3.23.8/node_modules/openai/core.mjs:304:65) at OpenAI.makeRequest (webpack-internal:///(rsc)/./node_modules/.pnpm/openai@4.56.0_zod@3.23.8/node_modules/openai/core.mjs:347:30) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@langchain+openai@0.2.7_langchain@0.2.17_@langchain+community@0.2.31_ignore@5.3.1_openai@4.56.0_zod@3.23.8__/node_modules/@langchain/openai/dist/chat_models.js:1322:29) at async RetryOperation.eval [as _fn] (webpack-internal:///(rsc)/./node_modules/.pnpm/p-retry@4.6.2/node_modules/p-retry/index.js:50:12) { status: 400, request_id: 'req_xxx', error: { message: "Missing required parameter: 'messages[3].content[0].type'.", type: 'invalid_request_error', param: 'messages[3].content[0].type', code: 'missing_required_parameter' }, code: 'missing_required_parameter', param: 'messages[3].content[0].type', type: 'invalid_request_error', attemptNumber: 1, retriesLeft: 6, pregelTaskId: '12345678-1234-5678-0000-000000000000' } ```
yindo closed this issue 2026-02-15 17:15:23 -05:00
Author
Owner

@jacoblee93 commented on GitHub (Aug 24, 2024):

Hey @krusadellc, sorry you're running into this - is this consistent? Or is there anything I can do to try to reproduce the issue?

@jacoblee93 commented on GitHub (Aug 24, 2024): Hey @krusadellc, sorry you're running into this - is this consistent? Or is there anything I can do to try to reproduce the issue?
Author
Owner

@khakra commented on GitHub (Aug 24, 2024):

It is consistent, I am trying to isolate this so I can share a code snippet that can help reproduce this issue.

If it helps, the issue happens at the executeStep node which basically calls createReactAgent with some custom tools.

@khakra commented on GitHub (Aug 24, 2024): It is consistent, I am trying to isolate this so I can share a code snippet that can help reproduce this issue. If it helps, the issue happens at the executeStep node which basically calls `createReactAgent` with some custom tools.
Author
Owner

@jacoblee93 commented on GitHub (Aug 24, 2024):

Ok. Keep me posted. If you have a LangSmith trace that would be helpful too.

@jacoblee93 commented on GitHub (Aug 24, 2024): Ok. Keep me posted. If you have a LangSmith trace that would be helpful too.
Author
Owner

@khakra commented on GitHub (Aug 24, 2024):

here's a LangSmith trace for the failure
https://smith.langchain.com/public/bdbd1df4-935e-4200-acbf-1c97910bdede/r

@khakra commented on GitHub (Aug 24, 2024): here's a LangSmith trace for the failure https://smith.langchain.com/public/bdbd1df4-935e-4200-acbf-1c97910bdede/r
Author
Owner

@jacoblee93 commented on GitHub (Aug 24, 2024):

So two things strike me as strange:

  1. Your input messages seem to be doubled - can you check your input format?
Screenshot 2024-08-24 at 5 56 10 PM
  1. The error message is caused by your get-all-rental-property-details tool returning an array, which is being improperly parsed into content blocks. Can you try calling JSON.stringify() on the tool return type?

If that doesn't fix it, please reopen and share your code with me.

@jacoblee93 commented on GitHub (Aug 24, 2024): So two things strike me as strange: 1. Your input messages seem to be doubled - can you check your input format? <img width="938" alt="Screenshot 2024-08-24 at 5 56 10 PM" src="https://github.com/user-attachments/assets/18c81ced-01d4-4e14-b0da-956c0e5327c4"> 2. The error message is caused by your `get-all-rental-property-details` tool returning an array, which is being improperly parsed into content blocks. Can you try calling `JSON.stringify()` on the tool return type? If that doesn't fix it, please reopen and share your code with me.
Author
Owner

@khakra commented on GitHub (Aug 24, 2024):

  1. The input messages are doubled since the agent is called with the below input as suggested in the official guide here
const input = {
    messages: ["user", task],
  };
 const { messages } = await agentExecutor.invoke(input, config);

image

This was confusing to me as well, but since I didn't know the internals of createReactAgent() I stuck with the guide.

  1. JSON.Stringify() on the output of the function helped. Thanks a lot!
    Can you please help me understand what was going on?
@khakra commented on GitHub (Aug 24, 2024): 1. The input messages are doubled since the agent is called with the below input as suggested in the [official guide here](https://langchain-ai.github.io/langgraphjs/tutorials/plan-and-execute/plan-and-execute/#re-plan-step) ```js const input = { messages: ["user", task], }; const { messages } = await agentExecutor.invoke(input, config); ``` ![image](https://github.com/user-attachments/assets/ded7a8cf-4890-4d8c-b738-5fac0dd540a9) This was confusing to me as well, but since I didn't know the internals of `createReactAgent()` I stuck with the guide. 2. `JSON.Stringify()` on the output of the function helped. Thanks a lot! Can you please help me understand what was going on?
Author
Owner

@jacoblee93 commented on GitHub (Aug 25, 2024):

  1. Oh dear we need to fix that! It's meant to be an array of [role, content] tuples.
  2. Models generally handle strings as message content, but can do complex types as well in some cases. I'm not exactly sure what happened but I think the prebuilt ToolNode you're using is interpreting your non-string return type as complex content.
@jacoblee93 commented on GitHub (Aug 25, 2024): 1. Oh dear we need to fix that! It's meant to be an array of `[role, content]` tuples. 2. Models generally handle strings as message content, but can do complex types as well in some cases. I'm not exactly sure what happened but I think the prebuilt `ToolNode` you're using is interpreting your non-string return type as complex content.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#70