By Bernat Sampera 1 min read Follow:

Common langgraph errors and how to solve them.

Understand what each of these errors and learn how to fix it. This is a summary of all the error messages I get in langgrapgh and track how it's been solved to avoid doing the error again

  1. "Invalid parameter: messages with role \'tool\' must be a response to a preceeding message with \'tool_calls\'."
    Pretty self explanatory, an AI decides which tool will be called, and this happens by adding to the message list a new entry with x tool_calls, then the url is called and the results are added to the message list. If the message list doesn’t have something like add_messages, it can be that the tool response overwrites the original message with tool_calls which causes this error.

    Solution: Have a message list with [AI( with tool_calls X ), ToolOutput ( Response from Tool Call X ) ]

  2. An assistant message with \'tool_calls\' must be followed by tool messages responding to each \'tool_call_id\'. The following tool_call_ids did not have response messages:
    Similar as before but a bit different. This happens when there is an AI message with a tool call, and then there is no other message of the ToolOutput