block / goose

Goose is a developer agent that operates from your command line to help you do the boring stuff.
https://block.github.io/goose/
Apache License 2.0
109 stars 17 forks source link

Improve error handling when choosing not to execute a potentially unsafe command #130

Open adhintz opened 2 weeks ago

adhintz commented 2 weeks ago

When choosing not to execute an unsafe command, an exception is thrown that doesn't appear to be what we want:

We flagged the command: git push as potentially unsafe, do you want to proceed? [y/n] (y): n
Traceback (most recent call last):
  File "/Users/hintz/goose/src/goose/cli/session.py", line 162, in run
    self.reply()  # Process the user message.
    ^^^^^^^^^^^^
  File "/Users/hintz/goose/src/goose/cli/session.py", line 198, in reply
    response = self.exchange.generate()
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hintz/goose/packages/exchange/src/exchange/exchange.py", line 76, in generate
    message, usage = self.provider.complete(
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hintz/goose/packages/exchange/src/exchange/providers/google.py", line 147, in complete
    message = self.google_response_to_message(response)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hintz/goose/packages/exchange/src/exchange/providers/google.py", line 82, in google_response_to_message
    return Message(role="assistant", content=content)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<attrs generated init exchange.message.Message>", line 17, in __init__
    __attr_validator_content(self, __attr_content, self.content)
  File "/Users/hintz/goose/packages/exchange/src/exchange/message.py", line 23, in validate_role_and_content
    raise ValueError("Assistant message must include a Text or ToolUsage")
ValueError: Assistant message must include a Text or ToolUsage

The error above was an exception we were not able to handle.

These errors are often related to connection or authentication
We've removed the conversation up to the most recent user message - depending on the error you may be able to continue