fix toolResult Prefix Check#2174
Open
BG0527 wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
|
不好意思哈,我觉得这样改更好。而且应该同时关联那两个 Issue。 |
Contributor
Author
好的我了解了,非常感谢您的评论。^_^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 issue
AgentScope-Java Version
v2.0.0
Description
Background
MCP 工具执行超时后,
ToolExecutor重试 2 次均失败,最终错误结果被标记为state=SUCCESS而非state=ERROR,导致 Agent 推理循环无法感知工具失败,继续基于错误数据进行推理。Root Cause
错误处理存在两条路径,使用了不同的错误前缀:
ReActAgent.buildErrorToolResult()使用"[ERROR] "前缀 — 能被determineToolResultState()识别ToolExecutor.executeWithInfrastructure()通过ToolResultBlock.error()产生"Error: "前缀 —— 不能被determineToolResultState()识别determineToolResultState()仅检查startsWith("[ERROR]"),当state字段为 null 时作为 fallback 文本检测。由于ToolResultBlock.error()返回的state=null(默认为RUNNING)且前缀为"Error: ",导致该方法始终返回SUCCESS。Changes
ToolResultBlock.error(...)to explicitly useToolResultState.ERROR.ToolResultState.ERROR.ToolResultBlock.error(...)carrying structuredERROR.ToolResultEndEvent.state = ERRORfor tools returningToolResultBlock.error(...).Checklist
mvn spotless:applymvn test)