Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: 工具结果过长导致前端拦截

samast8caf52931384
diff --git a/jiuwenclaw/agentserver/react_agent.py b/jiuwenclaw/agentserver/react_agent.py
index 866b1bf847..e8c27e6861 100644
--- a/jiuwenclaw/agentserver/react_agent.py
+++ b/jiuwenclaw/agentserver/react_agent.py
@@ -663,6 +663,7 @@ class JiuClawReActAgent(ReActAgent):
async def _emit_tool_result(self, session: Session, tool_call: Any, result: Any) -> None:
"""Emit tool_result OutputSchema, notify frontend of tool execution result."""
try:
+ # todo 工具结果待优化
await session.write_stream(
OutputSchema(
type="tool_result",
@@ -671,7 +672,7 @@ class JiuClawReActAgent(ReActAgent):
"tool_result": {
"tool_name": getattr(tool_call, "name", "") if tool_call else "",
"tool_call_id": getattr(tool_call, "id", "") if tool_call else "",
- "result": str(result) if result is not None else "",
+ "result": str(result)[:1000] if result is not None else "",
}
},
)