fix: surface Desktop Agent OS errors to the agent instead of crashing - #305
Closed
philipph-askui wants to merge 1 commit into
Closed
fix: surface Desktop Agent OS errors to the agent instead of crashing#305philipph-askui wants to merge 1 commit into
philipph-askui wants to merge 1 commit into
Conversation
DesktopAgentOsError inherited from BaseException, so the tool-calling loop's `except Exception` handler never caught it. When a tool (e.g. reading a remote file/directory that does not exist) failed, the error propagated all the way up and crashed the run instead of being returned to the agent as a tool error result, as we do everywhere else. Make DesktopAgentOsError inherit from Exception so the existing error handling catches it and reports it back to the agent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| @@ -1,5 +1,9 @@ | |||
| class DesktopAgentOsError(BaseException): | |||
| class DesktopAgentOsError(Exception): | |||
Contributor
There was a problem hiding this comment.
I thought we wanted to have two types: DesktopAgentOsError for errors that aren’t fixable, and DesktopAgentOsException for errors that are recoverable by the agent.
Contributor
Author
There was a problem hiding this comment.
You are right. I guess then I'll just close this PR?
mlikasam-askui
approved these changes
Aug 12, 2026
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.
Problem
When trying to read a remote file or list a directory that does not exist the whole agent run crashed with an unhandled error, instead of the failure being reported back to the agent as a tool error (the way every other tool failure is handled).
The reason: the Desktop Agent OS error type inherited from
BaseExceptionrather thanException. The tool-calling loop catches tool failures with anexcept Exceptionhandler and converts them into an error result the agent can see and react to. Becauseexcept Exceptiondoes not catchBaseExceptionsubclasses, this error slipped past the handler and propagated all the way up, crashing the run.By convention,
BaseExceptionis reserved for system-level signals (likeKeyboardInterrupt/SystemExit); application errors should subclassException.Fix
Make the Desktop Agent OS error type inherit from
Exception. No other changes are needed — the existing error-handling logic now catches it and returns it to the agent as a tool error result, consistent with how the rest of the codebase handles tool failures.Testing
pdm run qa:fixpasses (typecheck, format, lint).🤖 Generated with Claude Code