DOC: Manually updating the state causes a bad request error #70

Closed
opened 2026-02-20 17:24:44 -05:00 by yindo · 3 comments
Owner

Originally created by @TVScoundrel on GitHub (Apr 26, 2024).

Issue with current documentation:

In this section: https://langchain-ai.github.io/langgraph/tutorials/introduction/#what-if-you-want-to-overwrite-existing-messages

events = graph.stream(None, config)
for event in events:
    for value in event.values():
        if isinstance(value["messages"][-1], BaseMessage):
            print("Assistant:", value["messages"][-1].content)

The tutorial is using Claude 3 haiku but, using any of the claude 3 models, Claud 3 returns a bad request:

"name": "BadRequestError",
"message": "Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.2: Did not find 1 tool_result block(s) at the beginning of this message. Messages following tool_use blocks must begin with a matching number of tool_result blocks.'}}"

gpt-4 is working as expected though.

Idea or request for content:

gpt-4 is doing it correctly but is less verbose so the first part of the tutorial gives less interesting feedback so it should probably be updated so that the expectations of Claude are met.

Originally created by @TVScoundrel on GitHub (Apr 26, 2024). ### Issue with current documentation: In this section: https://langchain-ai.github.io/langgraph/tutorials/introduction/#what-if-you-want-to-overwrite-existing-messages ``` events = graph.stream(None, config) for event in events: for value in event.values(): if isinstance(value["messages"][-1], BaseMessage): print("Assistant:", value["messages"][-1].content) ```` The tutorial is using Claude 3 haiku but, using any of the claude 3 models, Claud 3 returns a bad request: "name": "BadRequestError", "message": "Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.2: Did not find 1 `tool_result` block(s) at the beginning of this message. Messages following `tool_use` blocks must begin with a matching number of `tool_result` blocks.'}}" gpt-4 is working as expected though. ### Idea or request for content: gpt-4 is doing it correctly but is less verbose so the first part of the tutorial gives less interesting feedback so it should probably be updated so that the expectations of Claude are met.
yindo closed this issue 2026-02-20 17:24:44 -05:00
Author
Owner

@hinthornw commented on GitHub (May 7, 2024):

Should be fixed by this update to serialization: https://github.com/langchain-ai/langchain/pull/21342

@hinthornw commented on GitHub (May 7, 2024): Should be fixed by this update to serialization: https://github.com/langchain-ai/langchain/pull/21342
Author
Owner

@AtmehEsraa commented on GitHub (May 14, 2024):

@TVScoundrel how did you solve it ?

@AtmehEsraa commented on GitHub (May 14, 2024): @TVScoundrel how did you solve it ?
Author
Owner

@ikergalarza commented on GitHub (Jul 2, 2024):

i'd also know how to fix it!

@ikergalarza commented on GitHub (Jul 2, 2024): i'd also know how to fix it!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#70