OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

First pass at a control loop

Open rbren opened this issue 11 months ago • 6 comments

This is very rough, but it works for simple examples.

See README.md for usage, and TODO.md for what's next.

Sample usage:

mkdir -p `pwd`/workspace
docker build -t control-loop .

docker run \
  -e OPENAI_API_KEY=$OPENAI_API_KEY \
  -v `pwd`/workspace:/workspace control-loop python /app/main.py /workspace \
  "write a bash script that prints 'hello world'"

rbren avatar Mar 17 '24 21:03 rbren

Wow @rbren , this is great!

Could you elaborate a little bit on how you're expecting this to interface with the frontend?

For instance, the user enters a chat request into the frontend, end then what happens?

neubig avatar Mar 18 '24 00:03 neubig

Thanks!

Here's what I think the user flow should be:

  • User loads a repo, or starts the app in the dir they want to work in
  • We start a docker container with that directory mounted
  • User types in a prompt into the chat window
  • Control loop kicks off
  • At each turn of the control loop:
    • We send a message back to the web client (e.g. via websocket, or the client polls the backend)
    • For edit/read actions, put a chat message that says "editing $FILE..." or "reading $FILE...", and show the file being read/edited in the file pane
    • for browse actions, put a chat message that says "browsing $URL..." and show the page in the browser pane
    • for think actions, put the thought into the chat directly
    • for run actions, put a chat message that says "running $COMMAND", and show the command being run
    • for finish actions, put a friendly "Done" message

At any point, as the agent is working, the user should be able to type in a message to give it a hint or redirect it. That message will be added to short-term memory

rbren avatar Mar 18 '24 00:03 rbren

nice work. i'm gonna impl a multi-llm interface for langchain

z-zeechung avatar Mar 18 '24 02:03 z-zeechung

I've added a couple simple test cases in ./agent/regression/cases, so you can see how it performs for some basic tasks.

rbren avatar Mar 18 '24 04:03 rbren

FWIW--I fully expect (and hope!) for this code to get deleted and replaced with something better. But getting this merged would at least give the frontend and backend folks something to code against.

rbren avatar Mar 18 '24 12:03 rbren

@rbren Thank you for your contribution! I will review the code, please give me some time.

huybery avatar Mar 18 '24 12:03 huybery