refactor(tool-engine): Optimize tool engine response handling (#14216)

Co-authored-by: xudong2.zhang <xudong2.zhang@zkh.com>
Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
Zhang Xudong 2025-02-25 09:58:43 +08:00 committed by GitHub
parent aa6c951e8c
commit ce545274a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -246,10 +246,11 @@ class ToolEngine:
+ "you do not need to create it, just tell the user to check it now."
)
elif response.type == ToolInvokeMessage.MessageType.JSON:
text = json.dumps(cast(ToolInvokeMessage.JsonMessage, response.message).json_object, ensure_ascii=False)
result += f"tool response: {text}."
result = json.dumps(
cast(ToolInvokeMessage.JsonMessage, response.message).json_object, ensure_ascii=False
)
else:
result += f"tool response: {response.message!r}."
result += str(response.message)
return result