🤖 fix: infer tool failure from error field #999
Merged
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.
Problem
When in Plan Mode, file edit tools (
file_edit_*) are disabled via tool policy. However, the model doesn't know about this policy and may still attempt to call these tools*.When this happens:
tool-errorevent with the error message{ error: "Model tried to call unavailable tool..." }hasFailureResult()only checked forsuccess === falsesuccessfield, the tool call showed "completed" status instead of "failed"This made it appear the edit succeeded when it actually failed, and the error wasn't visible in the dropdown.
Solution
Update
hasFailureResult()to infer failure from the presence of anerrorfield, not just explicitsuccess: false:This is more defensive and handles any tool error that includes an
errorfield, regardless of whethersuccessis explicitly set.*This only appears to happen when the context includes usage of those tools. I assume this isn't an easily solvable problem as an agent author, the model sees the tool is disabled, but it also sees it being used dozens of times in the context. How does it know it's really disabled?
Generated with
mux