OpenHands: Your AI Agent Tested the Wrong Checkout

Outline

Transcript

0:00 OpenHands says it fixed your failing test. The run is green. You open the checkout you're shipping, and the bug is still there. Where did that command actually run? And Git has nothing to show for it. I'd suspect another checkout. Let's find the files that terminal actually tested. For a concrete case, imagine Dana fixing a CSV importer. Her integration uses a Docker workspace, which starts an Agent Server container. That's where we'll follow the command. I've got the pinned OpenHands Software Agent SDK source open.

0:31 Links are in the description; Dana's investigation and results are invented. Her importer splits a quoted customer name at the comma. Take the comma case: a customer name comes back as two fields. The container's parser.py has the fix and a passing regression. Dana's release checkout still splits at that comma. Its diff is empty. So the patch exists, but the branch she's submitting doesn't contain it. We need the command's route and the files at its destination. How does OpenHands pick that destination?

1:02 The path starts at the SDK's conversation factory. The workspace you pass in chooses the route. A directory path takes the local route; a remote workspace produces a remote conversation client. And Docker workspace is one of those remote workspaces. It starts the container, exposes the server's port, and connects the client to it. Even on Dana's laptop. Remote names that client-to-server relationship. It doesn't mean the machine has to be somewhere else. The browser interface, Agent Canvas, sits outside that execution loop.

1:32 To trace the execution, we need to see what the server starts for the agent. Once we're across that boundary, which conversation runs the agent inside the server? A local conversation. The server constructs one in its own environment, with a local workspace. That owns the agent loop and tools that handle Dana's project. Hold on. I didn't realize it reused that implementation. The remote client leads to a local conversation, and local now means inside the container. Before that local loop starts, the server creates the working directory if it's missing and tries to initialize Git if it isn't already a repository.

2:08 Suppose the project copy never arrived. Dana could still see a valid path and a Git repository. What is that initialization trying to accomplish? Because the server's changes endpoint needs a repository for its diff, startup initializes Git. The terminal later checks that its working directory exists. Neither check verifies parser contents. Dana's importer did arrive as a separate copy. So what, if anything, connects that copy to the release checkout? That connection leads to Docker workspace's configuration: slash workspace by default, with an empty volumes list.

2:41 Specifying the directory doesn't itself mount Dana's laptop folder. She inspects the running container. In our setup, there's no bind mount connecting the release checkout to/workspace. The container is using its separate copy. Then she compares the actual parser files. The container version handles quoted fields; the release version still splits them incorrectly. Those findings explain the empty release diff. For example, a mount could point at yesterday's checkout. I'd inspect its actual source, destination, and whether it is writable before calling it the release copy.

3:13 So a mount entry alone is inconclusive. We've located both copies; can we trace Dana's test into the terminal that actually ran it? The execution path nearly fooled me. I followed the workspace's execute command method first. It offers direct programmatic execution, but the model's terminal tool doesn't call it. The workspace is still involved: terminal-tool creation reads the configured working directory. In Dana's server process, that's/workspace inside the container. Then the tool constructs Terminal Executor with that directory.

3:44 The executor owns the terminal session that will receive pytest. That's where I'd put the breakpoint. So we'd be staring at a perfectly good breakpoint in a method nobody called. The executor could finish pytest while we wonder why it never hit. Following that execution path keeps us in the container. The executor creates a terminal session, or uses a pool of terminal panes when tmux is available. A pool could sound like another execution service. Here it's terminal management inside that same environment.

4:13 It doesn't transport Dana's project back to the laptop checkout. Exactly. Her pytest argument reaches a session's execute method through the executor. The browser receives information about that work; displaying a terminal doesn't make it the browser machine's shell. That gives us a location. But the history also shows a proposed pytest call. Before we trust it, how do we know the shell received it? Before calling it executed, we need its result. Take Dana's request to fix the importer: her client sends the message, then separately starts the run.

4:45 That separation is explicit in the remote client. Sending the message posts to the events endpoint with running disabled. Calling run posts to the run endpoint. Ah, I'd be debugging the terminal before anything had asked it to work. I'd check that run request first. Once running, the server's local conversation drives the agent. The next boundary is between what the model proposes and what the tool executor can execute. With the remote run active, Dana sees a pytest request in the event history.

5:14 Has it reached the terminal? Not yet. The SDK validates the arguments and records an action before sending it to the tool. What can hold that saved action here? Before the proposed pytest can run, it meets Dana's confirmation policy. In our example, she configured approval for this run. The agent checks the action's risk and waits; pytest hasn't reached the shell. So the command in her history wasn't execution. She was waiting on herself. She approves the saved request. Does OpenHands run that same one, or get a fresh proposal from the model?

5:48 Once she approves, I'd expect another model call to choose what runs. No. Before another model request, OpenHands looks for a recorded action without a response. Dana's approved pytest matches, so it dispatches that saved call. Oh, it doesn't make the model reconstruct the test she just approved. Right. A later step can call the model with its result. From that pending-action check, the saved test now goes to the terminal tool. That's when the executor breakpoint would catch pytest, as its session runs the command inside/workspace.

6:19 With pytest running against the fixed container copy, the quoted-comma regression passes and the process exits zero. Now there is something to report. The terminal returns an observation linked to the action Dana approved. It carries the action ID and tool-call ID, plus command output and execution metadata. So she can attach this zero exit to her approved test, rather than trusting a nearby green sentence. But can a returned observation ever describe a test that hasn't finished? On the single-session path, a soft timeout can return an intermediate observation with exit code minus one.

6:54 The process isn't finished. Oh, so she'd have a response and still be waiting. How does she get more output? An empty command polls that same session. The tmux-pool path interrupts unfinished work before reusing a pane, so that continuation is single-session only. Dana's actual zero exit is final. Good. What does the model receive from her finished pytest? Next, the finished result becomes a tool message for the model, tied to the same call ID. The output can include/workspace and the Python interpreter, when that metadata is available.

7:28 That's useful evidence for Dana. It anchors the result to a command environment. But a slash-workspace label still doesn't identify the bytes in her separate release checkout. So the agent can be right about its test, and Dana can still be shipping the bug. That result only covers the tested files. Yes. I'd attach it to the container patch. Her shipping branch still needs a passing test. That container-only result leaves a choice about the patch. Imagine I'm the platform engineer. My first thought: “Just mount my checkout.

8:00 I want the fix where I'll ship it, without copying files back.” It would land there with the right writable mount. Dana instead reviews the container diff, transfers the parser and regression, and checks the branch she'll ship. Does the release checkout pass once she moves both files? Dana reruns the quoted-comma case in her release checkout. It passes, and her submission diff contains the parser fix and regression. Now the passing test and the submission diff point to the same files. Dana's passing release test closes this case.

8:31 On another agent run, I'd check whether the proposed command finished and which project copy it tested. A green badge alone wouldn't tell me. Our Pi deep dive picks up the question of what an agent does when it needs a tool it doesn't already have. Thanks for listening to Learning Podcasts.