Skip to content

Conversation

@SrijanShovit225
Copy link

@SrijanShovit225 SrijanShovit225 commented Nov 7, 2025

… dictionary replaced with LangChain Human Message

As per the docs live officially, in the rewrite_question node, the response of the model for rewriting the query is returned in dictionary format to messages in the state.

return {"messages": [{"role": "user", "content": response.content}]}

I understand this has been done keeping in mind to modify the message's role from ai/assistant to user in the state. While this is not critical for the time being, it might cause errors while printing graph's streaming updates.

for node, update in chunk.items():
print("Update from node", node)
update["messages"][-1].pretty_print()
print("\n\n")

This might have been skipped due to running an example where rewrite node was not required.

However, if the rewrite node comes into play, it would push the dictionary-based format of messages and not the standard Messages class format. The pretty print function is valid only on Message classes and not a dictionary; this would lead to an attribute error: AttributeError: 'dict' object has no attribute 'pretty_print'

For AI learners, especially those who have been exploring LangChain v1.0 docs might get blocked due to this while following the tutorial.

Please merge this one so that it adds to the quality and trust for LangChain docs.

Overview

Type of change

Type: [Replace with: New documentation page / Update existing documentation / Fix typo/bug/link/formatting / Remove outdated content / Other]

Related issues/PRs

  • GitHub issue:
  • Feature PR:
  • Linear issue:
  • Slack thread:

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally using docs dev
  • All code examples have been tested and work correctly
  • I have used root relative paths for internal links
  • I have updated navigation in src/docs.json if needed
  • I have gotten approval from the relevant reviewers
  • (Internal team members only / optional) I have created a preview deployment using the Create Preview Branch workflow

Additional notes

… dictionary replaced with LangChain Human Message

As per the docs live officially, in the rewrite_question node, the response of the model for rewriting the query is returned in dictionary format to messages in the state.

return {"messages": [{"role": "user", "content": response.content}]}

I understand this has been done keeping in mind to modify the message's role from ai/assistant to user in the state. While this is not critical for the time being, it might cause errors while printing graph's streaming updates.

for node, update in chunk.items():
        print("Update from node", node)
        update["messages"][-1].pretty_print()
        print("\n\n")

This might have been skipped due to running an example where rewrite node was not required.

However, if the rewrite node comes into play, it would push the dictionary-based format of messages and not the standard Messages class format. The pretty print function is valid only on Message classes and not a dictionary; this would lead to an attribute error: 
AttributeError: 'dict' object has no attribute 'pretty_print'

For AI learners, especially those who have been exploring LangChain v1.0 docs might get blocked due to this while following the tutorial. 

Please merge this one so that it adds to the quality and trust for LangChain docs.
@github-actions github-actions bot added langgraph For docs changes to LangGraph oss labels Nov 7, 2025
@SrijanShovit225
Copy link
Author

Hi @lnhsingh Could you check this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

langgraph For docs changes to LangGraph oss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant