Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Filter tool messages from LangGraphAdapter stream output#6

Open
farouk09 wants to merge 1 commit into
dqbd:mainfrom
farouk09:main
Open

Filter tool messages from LangGraphAdapter stream output#6
farouk09 wants to merge 1 commit into
dqbd:mainfrom
farouk09:main

Conversation

@farouk09
Copy link
Copy Markdown

Summary:
Adds filtering to prevent tool messages from being streamed to the LiveKit chat interface while preserving tool execution functionality.

Problem:
Currently, all LangGraph messages including tool messages are streamed to the chat interface, causing users to see intermediate tool execution messages that should remain internal to the agent workflow.

Solution:
Enhanced message filtering in LangGraphStream._run() to detect and skip tool messages
Added comprehensive tool message detection that handles:

Proper ToolMessage instances
Messages with type: 'tool' attribute
Dictionary-based messages with 'type': 'tool'

Tool execution continues normally, only the streaming output is filtered
Added debug logging for filtered messages

Changes:

Modified LangGraphStream._run() method to check message types before streaming
Added ToolMessage import from langchain_core.messages
Implemented multi-layered tool message detection for robust filtering

Testing:

Verified AI messages continue to stream normally to chat interface
Confirmed tool messages are filtered out while tools continue to execute
Tool execution results are properly processed and final AI responses are streamed

This change improves the user experience by showing only relevant AI assistant responses while maintaining full agent functionality.

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.

1 participant