OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Incorrect API key does not fail gracefully.

Open CakeCrusher opened this issue 1 year ago • 3 comments

Describe the bug If incorrect LLM_API_KEY passed then the agent loops endlessly. Steps to Reproduce

  1. Pass in incorrect API key
  2. Submit a chat message
  3. See failure message loop

Expected behavior Toast suggesting incorrect API key. Actual behavior Agent loops endlessly. Additional context image image

CakeCrusher avatar Apr 01 '24 04:04 CakeCrusher

Also tracked here: https://github.com/OpenDevin/OpenDevin/issues/326

enyst avatar Apr 01 '24 08:04 enyst

@enyst Although in the frontend the UI suggests that this is a similar issue, they should not be handled similarly.

Currently the error is handled as if it is an error that the agent made, whereas this is a user error and should be handled completely differently.

I tried to send an error using https://github.com/OpenDevin/OpenDevin/blob/main/opendevin/server/session.py#L45 by throwing an error if the generation failed https://github.com/OpenDevin/OpenDevin/blob/main/opendevin/controller/agent_controller.py#L93

        except Exception as e:
            observation = AgentErrorObservation(str(e))
            print_with_indent("\nAGENT ERROR:\n%s" % observation)
            traceback.print_exc()
            raise Exception("Error during action generation")

this unfortunately would lead to the program crashing without any UI feedback. Ideally the controller should be able to send an error back to the session.

To avoid further issues like these I think the scalable solution here is to create clear division between agent errors and system errors.

CakeCrusher avatar Apr 01 '24 22:04 CakeCrusher

I see your point on user error. I think you're right that it's worth tracking separately.

The worst thing that happens for the user experience, and which IMHO we need to fix first though, is similar: the infinite loop part.

enyst avatar Apr 01 '24 22:04 enyst