mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-03 06:12:14 +08:00
fix: handle empty agent tuple in streaming workflow (#427)
Prevents IndexError when agent[0] is accessed on empty tuple, resolving display issues with Gemini 2.0 Flash model. Fixes #425
This commit is contained in:
committed by
GitHub
parent
b155e1eca6
commit
b04225b7c8
@@ -153,9 +153,13 @@ async def _astream_workflow_generator(
|
||||
message_chunk, message_metadata = cast(
|
||||
tuple[BaseMessage, dict[str, any]], event_data
|
||||
)
|
||||
# Handle empty agent tuple gracefully
|
||||
agent_name = "unknown"
|
||||
if agent and len(agent) > 0:
|
||||
agent_name = agent[0].split(":")[0] if ":" in agent[0] else agent[0]
|
||||
event_stream_message: dict[str, any] = {
|
||||
"thread_id": thread_id,
|
||||
"agent": agent[0].split(":")[0],
|
||||
"agent": agent_name,
|
||||
"id": message_chunk.id,
|
||||
"role": "assistant",
|
||||
"content": message_chunk.content,
|
||||
|
||||
Reference in New Issue
Block a user