new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

LangChain · LangGraph · all subjects

errors

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

INVALID_CHAT_HISTORY error definition

The INVALID_CHAT_HISTORY error is raised in the prebuilt create_agent (Python) or createAgent (JavaScript) when the call_model or callModel graph node receives a malformed list of messages. The messages are malformed when there are AIMessages with tool_calls (LLM requesting to call a tool) that do not have a corresponding ToolMessage (result of a tool invocation to return to the LLM).

INVALID_CHAT_HISTORY caused by manually passing malformed messages

One cause of INVALID_CHAT_HISTORY is manually passing a malformed list of messages when invoking the graph. Example: graph.invoke({'messages': [AIMessage(..., tool_calls=[...])]}) in Python or graph.invoke({messages: [new AIMessage({..., tool_calls: [...]})]}) in JavaScript.

INVALID_CHAT_HISTORY caused by graph interrupt before tools node

Another cause is when the graph is interrupted before receiving updates from the tools node (a list of ToolMessage) and you invoke it with an input that is not None (Python) or null (JavaScript) or a ToolMessage. Example: graph.invoke({'messages': [HumanMessage(...)]}, config) in Python or graph.invoke({messages: [new HumanMessage(...)]}, config) in JavaScript.

Graph interrupt triggers for INVALID_CHAT_HISTORY

An interrupt can be triggered by: (1) manually setting interrupt_before = ['tools'] in create_agent (Python) or interruptBefore: ['tools'] in createAgent (JavaScript), or (2) one of the tools raising an error that wasn't handled by the ToolNode ('tools').

Resolve INVALID_CHAT_HISTORY by providing ToolMessage objects

To resolve INVALID_CHAT_HISTORY after an interrupt, provide ToolMessage objects that match existing tool calls and call graph.invoke({'messages': [ToolMessage(...)]}) in Python or graph.invoke({messages: [new ToolMessage(...)]}) in JavaScript. NOTE: this will append the messages to the history and run the graph from the START node.

Resolve INVALID_CHAT_HISTORY by manually updating state and resuming

To resolve INVALID_CHAT_HISTORY by manually updating state: (1) get the list of most recent messages from the graph state with graph.get_state(config) in Python or graph.getState(config) in JavaScript, (2) modify the list of messages to either remove unanswered tool calls from AIMessages or add ToolMessage objects with tool_call_ids (Python) or toolCallId (JavaScript) that match unanswered tool calls, (3) call graph.update_state(config, {'messages': ...}) in Python or graph.updateState(config, {messages: ...}) in JavaScript with the modified list of messages, (4) resume the graph by calling graph.invoke(None, config) in Python or graph.invoke(null, config) in JavaScript.

Simple solution to INVALID_CHAT_HISTORY

The simplest way to resolve INVALID_CHAT_HISTORY is to avoid invoking the graph with a malformed list of messages in the first place.

Fixed protocol v2 runs on JS graphs failing silently

Protocol v2 runs on JS graphs were failing silently because the sidecar rejected streamEvents with a 400 due to strict stream-mode validation, errors were swallowed, and runs falsely reported success with 0 nodes executed. This was fixed by relaxing stream-mode validation at the HTTP boundary and raising clear errors on non-2xx sidecar responses instead of masking failures.

Give your agent this brain