agentscope-ai / agentscope-ai/agentscope-java

[Bug]: FileSystemTool 没有正确返回ToolResultState.ERROR

未關閉
#2,745 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area/core/tool bug
主要語言
Java
星號
5.6k
分支
1.3k
平均合併
4 天 12 小時
30 天內合併 PR
77

描述

**AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.**

**Describe the bug**
FileSystemTool调用失败,例如write_file,返回字符串"Error: " + r.error(),不符合ReActAgent.determineToolResultState的判断,返回的仍然是ToolResultState.SUCCESS

[FilesystemTool.java (line 88)]
@Tool(
name = "write_file",
description = "Write content to a new file, creating parent directories if needed.")
public String writeFile(
RuntimeContext runtimeContext,
@ToolParam(name = "path", description = "Target file path") String path,
@ToolParam(name = "content", description = "File content to write") String content) {
WriteResult r = abstractFilesystem.write(runtimeContext, norm(path), content);
return r.isSuccess() ? "Written to " + r.path() : "Error: " + r.error();
}

[ReActAgent.java (line 2883)]
private ToolResultState determineToolResultState(ToolResultBlock result) {
if (result.isSuspended()) {
return ToolResultState.RUNNING;
}
if (result.getState() != null && result.getState() != ToolResultState.RUNNING) {
return result.getState();
}
if (result.getOutput() != null
&& result.getOutput().stream()
.anyMatch(
b ->
b instanceof TextBlock tb
&& tb.getText() != null
&& tb.getText().startsWith("[ERROR]"))) {
return ToolResultState.ERROR;
}
return ToolResultState.SUCCESS;

**Expected behavior**
WriteResult r.isSuccess() == false 时,返回ToolResultState.ERROR

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。