Skip to content

Conversation

@Iamsdt
Copy link
Collaborator

@Iamsdt Iamsdt commented Nov 21, 2025

This pull request refactors and improves the graph agent's message handling and error resilience. The main focus is on cleaning up messages with empty tool calls in the graph state, introducing a robust filtering mechanism, and enhancing error handling. Additionally, unnecessary docstrings and comments are removed from graph/react.py for clarity.

Message Filtering and Graph State Management

  • Added a _has_empty_tool_call helper method to detect messages containing tool calls with empty content, improving the accuracy of context filtering.
  • Refactored the fix_graph method to remove all messages with empty tool calls, rather than just the last assistant message, and updated the logic to report the number of removed messages.

Error Handling Improvements

  • Wrapped the fix_graph operation in a try/except block to catch and log exceptions, returning an HTTP 500 error if the operation fails.

Code and Documentation Cleanup

  • Removed large explanatory docstrings and comments from graph/react.py to streamline the codebase and improve readability. [1] [2]

Minor Code Quality Updates

  • Ensured that message lists are properly copied when filtering, preventing unexpected side effects.
  • Removed an unnecessary list comprehension in the thread naming logic to avoid redundant string conversion.

@Iamsdt Iamsdt merged commit 79085f7 into main Nov 21, 2025
1 check passed
@Iamsdt Iamsdt deleted the 10-bug-attributeerror-str-object-has-no-attribute-text-during-stream_graph branch November 21, 2025 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: AttributeError: 'str' object has no attribute 'text' during stream_graph

2 participants