|
|
@@ -333,6 +333,13 @@ class ToolRegistry:
|
|
|
if isinstance(result, ToolResult):
|
|
|
ret = {"text": result.to_llm_message()}
|
|
|
|
|
|
+ # Runner 消费的控制字段与业务文本分离,不能靠解析 output 猜测终止。
|
|
|
+ if result.terminate_run:
|
|
|
+ ret["_control"] = {
|
|
|
+ "terminate_run": True,
|
|
|
+ "result_summary": result.result_summary or result.long_term_memory or result.output,
|
|
|
+ }
|
|
|
+
|
|
|
# 保留images
|
|
|
if result.images:
|
|
|
ret["images"] = result.images
|
|
|
@@ -341,7 +348,7 @@ class ToolRegistry:
|
|
|
if result.tool_usage:
|
|
|
ret["tool_usage"] = result.tool_usage
|
|
|
|
|
|
- # 向后兼容:只有text时返回字符串
|
|
|
+ # 向后兼容:只有 text 时返回字符串;有控制信息时必须保留 dict。
|
|
|
if len(ret) == 1:
|
|
|
return ret["text"]
|
|
|
return ret
|