← Engineering blog

Open your mainbrella with two hands

An OpenHands agent can lose access to its machine while the machine is still running. The unfinished report is on disk, Agent Server is alive, and the conversation remembers the work. The URL has expired. Starting another machine would turn a connection problem into lost work.

That’s one of the cases our Mainbrella prototype brings to OpenHands’ discussion of sandbox providers for Agent Canvas. We connected the published SDK to a Mainbrella machine through OpenHands’ existing remote-workspace protocol. The connection works, but the prototype can’t yet renew an expired endpoint. A provider interface needs to account for that before a marketplace gives users a menu of machines.

A mechanical assistant uses one hand to hold an umbrella's shaft and the other to push its runner upward, sheltering a computing machine and an unfinished report.

Run the existing Agent Server

OpenHands’ file tools and terminal already work through its Agent Server, and the SDK can connect to a server running elsewhere. We can supply the machine without rebuilding those tools.

That takes less translation than our Deep Agents and Mastra adapters, which implement command execution and file transfers beneath each framework’s tools. Here, OpenHands continues to own the protocol all the way into the guest.

The prototype creates a Mainbrella Python machine, installs Agent Server 1.53.0 inside it, and exposes port 18000 through a protected preview. A MainbrellaWorkspace class extends OpenHands’ RemoteWorkspace. Commands, files, conversation requests, and WebSocket events then use OpenHands’ existing protocol. Mainbrella provisions the machine; Agent Server handles the work inside it.

The file editor and terminal see the same /workspace, so a script written by one tool is available to the other. Conversation requests and events reach that same server. The adapter pins the SDK, server, and tools to matching versions.

Each new machine installs the server at startup. That’s wasted setup for repeated use; a prepared image would avoid it. We haven’t measured startup speed in this prototype.

Provisioning and conversation access use different credentials. The Mainbrella account key stays with the provisioner. The guest receives a separately generated Agent Server session key and encryption key. Model credentials follow OpenHands’ remote-conversation behavior and go to Agent Server. The guest still holds secrets, just not the key that can provision more machines.

The next connection must find the same machine

Suppose the agent has written half a report and an administrator changes the instance’s default provider. On the next turn, following that new default would give the agent an empty disk alongside a transcript describing its unfinished report. The default is fine for new work. Applying it to an existing conversation is a bug.

Our feedback on the proposal asks for an instance default with per-conversation and per-automation overrides. Once work starts, save its chosen provider, profile, and runtime identity alongside the conversation. Later turns need to use that saved choice.

Mainbrella’s identity includes a slot ID and a creation timestamp. A slot can be reused; the pair names the exact generation. The prototype’s attach() checks that this generation is still running. When the prototype creates a workspace, it stops that machine on cleanup. When it attaches to one, it leaves the machine running after the connection closes. Closing an inspection session shouldn’t delete the machine you came to inspect.

We also record each attempt to create a machine. The caller supplies an idempotency key, and the adapter’s recording callback saves it before the creation request. If the reply disappears, that key lets the caller reconcile the attempt. Shell commands don’t get that protection. If a command appended a report row before its reply disappeared, replaying it may append the row twice.

A machine and its endpoint have different clocks

The saved runtime handle also contains the preview endpoint, its session key, and its expiration. These are sensitive connection details, separate from the generation identity. In this prototype, a preview lasts at most one hour, shortened when the machine’s hard lease ends sooner.

A hypothetical timeline shows a machine and its files continuing beyond the expiration of its preview endpoint. Renewed access would connect to the same generation; starting a new machine would produce a separate disk.

The machine may still be running when access expires, as the diagram shows. That dotted renewal path is what the provider contract needs to support; this adapter hasn’t implemented it. Until it can refresh access, it has to report that the workspace is unavailable. Creating a replacement would discard access to the work we were trying to resume.

A connect(handle) result should include credentials and their expiration so the caller knows when it needs fresh access. Authentication has another wrinkle here: preview ingress strips application cookies. Session-key HTTP and WebSocket authentication passed the local checks, but we haven’t qualified the browser tools or embedded editor.

Stopping the machine discards its unsaved files. A filesystem snapshot can preserve those files, but it won’t preserve a running process’s memory. Renewing access, saving the filesystem, and pausing a process need separate capability flags. A single “supports persistence” checkbox is too vague to trust with unfinished work.

The timeout lost part of the output

Local checks with OpenHands SDK 1.53.0 and Mainbrella SDK 0.1.0 found a second problem: a timed-out command could leave useful output behind without returning it to the caller. The saved report includes the transport checks and this failure.

The high-level execute_command() call reported a timeout but omitted the final buffered stdout. A second probe split starting the command from reading its result, using start_command() and get_command_output(). That probe received the partial output:

Wait for the whole command

First probe, execute_command(): timeout reported; the expected partial output was absent.

Inspect the retained command result

Second probe, start_command() / get_command_output(): the verifier received partial and exit code -1 after timeout.

The prototype README attributes the missing output to the polling deadline coinciding with the process deadline in SDK 1.53.0. The client stops waiting just when the process is producing its final result. A provider test needs to check that the caller can recover that result, not just that it receives a timeout.

These checks exercised local transport without making model requests. The WebSocket check sent a user message, but no model ran. Canvas UI, hosted production, and delegated workers still need qualification before we can claim they work through this provider.

The interface we’d want to implement

I’d put four operations in the SDK/Agent Server layer and have Canvas call them. These are proposed names, not an upstream API:

OperationThe question it answers
create_or_reconcile(spec, key)Which machine belongs to this creation attempt?
inspect(handle)Is that generation alive, and what limits and capabilities apply?
connect(handle)How do I authenticate to its Agent Server, and until when?
stop(handle)Did that exact generation stop, or is cleanup still uncertain?

With those operations tested, a provider picker can show what users need to know: who runs the service, which credentials it needs, how long a machine lives, what it costs, and what survives a stop. Network policy and unsupported capabilities belong there too. A slick selector won’t help anyone discover that “persistent” meant only the chat history.

As of October 8, the OpenHands issue was still an early discussion. This prototype runs at the SDK layer and adds no Canvas runtime option; upstream hasn’t accepted it. We’ve offered the implementation as something the maintainers can test their proposed interface against.

Try the transport before adding a model

To inspect the same implementation and run its checks, start with the pinned commit:

git clone https://github.com/mainbrella/OpenHands.git
cd OpenHands
git checkout 6f3ab7771a915a5af23db6b58c49afc77e535d4a
cd examples/mainbrella
uv sync --locked
uv run --locked pytest
# Configure MAINBRELLA_API_KEY in your environment.
uv run --locked python verify.py

The README covers Python 3.12+, Node 24+ for its environment-file launcher, local setup, and credential handling. The verifier consumes two machine starts and needs allowance for two simultaneous Small machines. For a local service, use its credential and set MAINBRELLA_API_URL=http://localhost:8787; local accounts and compute access are separate from production.

Run the verifier before adding a model. Write a file, reconnect, and read it back from the same machine. The next piece of work is making that connection survive an expired preview URL while leaving the file exactly where it is.