Architecture

Let's take a look how SWE-ReX works:

  1. Your central entry point is one of the Deployment classes, depending on where your code should run.
  2. Your Deployment instances allows your to start your docker container, AWS instance, or whatever at the push of a button. That's right, no more fiddling with the AWS console!
  3. After the Deployment has started your container somewhere, you are handed a RemoteRuntime instance. This is your main interface for interacting with the environment. You can use it start new shell or interactive sessions, read and write files, execute one-off commands, etc.

architecture

Looking closer at the internals:

  1. Within the container, we have a fastapi Server that transfers all request from the RemoteRuntime to the LocalRuntime. The LocalRuntime has the exact same interface as the RemoteRuntime class and it is what actually executes the commands. In fact, if you want to run something locally (or your whole codebase runs in a sandboxed environment), you can just use the LocalRuntime directly! Both classes are absolutely interchangeable, in fact we even transfer any exceptions happening in the LocalRuntime to the RemoteRuntime transparently, so you can easily catch and ignore certain errors.

  2. The Runtime class provides several methods for reading/writing files, an execute method for running arbitrary commands, but the most important one is run_in_session. This method allows you to run a command in an existing shell session (or an interactive tool running inside of it) and return the output. In fact, you can have multiple sessions open at the same time, running different commands and tools in parallel!