fix: MCP node display nesting issue (#3822)
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run

This commit is contained in:
shaohuzhang1 2025-08-05 19:23:48 +08:00 committed by GitHub
parent f61a567bc3
commit ec12ad0c2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,13 +33,25 @@ tool_message_template = """
<strong>Called MCP Tool: <em>%s</em></strong>
</summary>
```json
%s
```
</details>
"""
tool_message_json_template = """
```json
%s
```
"""
def generate_tool_message_template(name, context):
if '```' in context:
return tool_message_template % (name, context)
else:
return tool_message_template % (name, tool_message_json_template % (context))
def _write_context(node_variable: Dict, workflow_variable: Dict, node: INode, workflow, answer: str,
reasoning_content: str):
@ -110,7 +122,7 @@ async def _yield_mcp_response(chat_model, message_list, mcp_servers):
response = agent.astream({"messages": message_list}, stream_mode='messages')
async for chunk in response:
if isinstance(chunk[0], ToolMessage):
content = tool_message_template % (chunk[0].name, chunk[0].content)
content = generate_tool_message_template(chunk[0].name, chunk[0].content)
chunk[0].content = content
yield chunk[0]
if isinstance(chunk[0], AIMessageChunk):