Architecture
Let's take a look how SWE-ReX works:
- Your central entry point is one of the
Deployment
classes, depending on where your code should run. - 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! - After the
Deployment
has started your container somewhere, you are handed aRemoteRuntime
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.
Looking closer at the internals:
-
Within the container, we have a fastapi Server that transfers all request from the
RemoteRuntime
to theLocalRuntime
. TheLocalRuntime
has the exact same interface as theRemoteRuntime
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 theLocalRuntime
directly! Both classes are absolutely interchangeable, in fact we even transfer any exceptions happening in theLocalRuntime
to theRemoteRuntime
transparently, so you can easily catch and ignore certain errors. -
The
Runtime
class provides several methods for reading/writing files, anexecute
method for running arbitrary commands, but the most important one isrun_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!