Skip to content

fix: surface Desktop Agent OS errors to the agent instead of crashing - #305

Closed
philipph-askui wants to merge 1 commit into
mainfrom
fix/desktop-agent-os-error-inherit-exception
Closed

fix: surface Desktop Agent OS errors to the agent instead of crashing#305
philipph-askui wants to merge 1 commit into
mainfrom
fix/desktop-agent-os-error-inherit-exception

Conversation

@philipph-askui

@philipph-askui philipph-askui commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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 BaseException rather than Exception. The tool-calling loop catches tool failures with an except Exception handler and converts them into an error result the agent can see and react to. Because except Exception does not catch BaseException subclasses, this error slipped past the handler and propagated all the way up, crashing the run.

By convention, BaseException is reserved for system-level signals (like KeyboardInterrupt/SystemExit); application errors should subclass Exception.

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

  • Added a regression test that drives a tool raising a Desktop Agent OS error through the tool-calling loop and asserts an error result is returned rather than the exception propagating.
  • pdm run qa:fix passes (typecheck, format, lint).
  • New and related unit tests pass.

🤖 Generated with Claude Code

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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I guess then I'll just close this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants