mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-03 06:12:14 +08:00
- Backend: Convert non-string content (lists, dicts) to JSON strings in _create_event_stream_message to ensure frontend always receives string content - Frontend: Add type guard before calling startsWith() on toolCall.result for defensive programming This fixes the TypeError: toolCall.result.startsWith is not a function when tools return complex objects.
This commit is contained in:
@@ -157,6 +157,10 @@ def _create_event_stream_message(
|
||||
message_chunk, message_metadata, thread_id, agent_name
|
||||
):
|
||||
"""Create base event stream message."""
|
||||
content = message_chunk.content
|
||||
if not isinstance(content, str):
|
||||
content = json.dumps(content, ensure_ascii=False)
|
||||
|
||||
event_stream_message = {
|
||||
"thread_id": thread_id,
|
||||
"agent": agent_name,
|
||||
@@ -166,7 +170,7 @@ def _create_event_stream_message(
|
||||
"langgraph_node": message_metadata.get("langgraph_node", ""),
|
||||
"langgraph_path": message_metadata.get("langgraph_path", ""),
|
||||
"langgraph_step": message_metadata.get("langgraph_step", ""),
|
||||
"content": message_chunk.content,
|
||||
"content": content,
|
||||
}
|
||||
|
||||
# Add optional fields
|
||||
|
||||
@@ -105,7 +105,7 @@ const ActivityListItem = React.memo(({ messageId }: { messageId: string }) => {
|
||||
if (message) {
|
||||
if (!message.isStreaming && message.toolCalls?.length) {
|
||||
for (const toolCall of message.toolCalls) {
|
||||
if (toolCall.result?.startsWith("Error")) {
|
||||
if (typeof toolCall.result === "string" && toolCall.result?.startsWith("Error")) {
|
||||
return null;
|
||||
}
|
||||
if (toolCall.name === "web_search") {
|
||||
|
||||
Reference in New Issue
Block a user