Repository navigation
feat(computer): a boot stops when its sandbox does and says what it last wrote - #629
Merged
Merged
Conversation
…ast wrote A computer's boot asks the sandbox running it whether its container, or the launcher booting its disk, still runs. Within seconds of it exiting, the boot fails with ComputerStopped, naming the exit status and the sandbox's last lines: the guest init's agentenv-init: and the launcher's launch: lines, then the last few. A boot that times out ends its error with those lines too. Sandbox gains optional exit_status() and output_tail(), defaulting to nothing, which local Docker answers from its container and Modal from its sandbox's process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l of each stream The output a failed boot reads of a Modal sandbox is read a chunk at a time, keeping the last lines of its output and of its errors apart, and its tail gives each stream at least half of the lines asked for, so a long log isn't held whole and the guest's console isn't crowded out by the launcher's errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…628) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… build of it Two test workers composing the same computer, each in stores of its own, build the same tag on one Docker daemon, and the second to finish fails with "image ... already exists". The computer tests' builds of a tag now take turns across workers, as the bootstrap images' builds do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…treams When one stream's read failed, gather returned at once and the other's later lines, the guest's reason among them, never reached the boot's error. Both reads now finish within the timeout, and each failure is logged on its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of FD-5171.
What
A computer's boot no longer waits out its readiness timeout (180 s by default) once the sandbox has stopped running the computer. Within seconds of the computer's container, or the launcher booting its disk, exiting, the boot fails with
ComputerStopped(aComputerFailed). The error names the exit status, and the signal for a kill, then what the sandbox last wrote: the guest init'sagentenv-init:lines, the launcher'slaunch:lines and the last few lines of all. A boot that does time out, as a hung guest does, now ends itsTimeoutErrorwith those lines too.Before:
After, a disk whose image's user isn't in its
/etc/passwd, after 7 s on local Docker with KVM and 10 s on modal_vm:A launcher that can't forward the driver's port, after 0.4 s:
How
Sandboxgets two optional methods,exit_status()andoutput_tail(lines). Their defaults,Noneand[], keep plugin providers working, and those still get today's timeout.LocalSandboxanswers them for the container it was made to run (a computer's, or the launcher booting a disk), fromdocker container inspectanddocker logs --tail.ModalSandboxandModalVmSandboxanswer frompoll(). Once the process has exited, they read its stdout and stderr once and keep them.boot.readytakes the sandbox (boot()and a reset pass it), asks every 2 s whether the sandbox still runs the computer, and stops as soon as it doesn't.said_whypicks the lines that go into the error.sandbox_providers/AGENTS.mddocuments the two methods for provider authors.Verified
tst/unit/env/envs/test_computer_boot_stops.pyandtst/unit/providers/sandbox_providers/sandbox_exit_test.py.tst/integration/computer/launcher_test.py: the guest-init refusal and the port refusal above, and the existing burst-and-reset test.disk_boot_test.py: the full deploy, probe and reset of the desktop's disk, which runs the reset path that now passes the sandbox.tst/integration/computer/container_stopped_test.py. A computer's container that exits with 4 fails its boot within seconds, naming its status and its last lines, and its container is removed.tst/integration/computer/disk_boot_failure_modal_vm_test.pycovers both disk cases under nested virtualization on Modal. It runs by hand, as the other modal_vm tests do.Notes for review
launch:lines and the guest's console can come in either order.said_whykeeps the reason lines wherever they fall.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; the previous output-loss finding is fixed and no new actionable issues were found.Summary
Computer boots now detect stopped sandboxes and include recent output in failure messages.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Boot or reset] --> B[Wait for computer readiness] B --> C{Computer ready?} C -->|Yes| D[Return computer card] C -->|No| E{Sandbox stopped?} E -->|Yes| F[Read recent output] F --> G[Raise ComputerStopped] E -->|No| H{Readiness timeout?} H -->|No| B H -->|Yes| I[Read available output] I --> J[Raise TimeoutError]Reviews (5) · Last reviewed commit: "fix(computer): a Modal sandbox's ended o..." · Reviewed by Greptile