Skip to content

fix: blame the runtime, not the harness, when the box dies mid-rollout - #2156

Merged
mikasenghaas merged 1 commit into
mainfrom
fix/dead-runtime-blame
Jul 28, 2026
Merged

fix: blame the runtime, not the harness, when the box dies mid-rollout#2156
mikasenghaas merged 1 commit into
mainfrom
fix/dead-runtime-blame

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Not every runtime raises when the box is gone — some surface it as exec's own non-zero result, indistinguishable from the harness program failing. A sandbox that died mid-rollout was therefore recorded as HarnessError ("harness exited 137"), blaming the agent program for an infrastructure death.
  • Adds Runtime.alive(): one trivial probe exec (true) that tells the two apart, and uses it at the single shared blame site — Harness.run's non-zero-exit path. Probe fails → SandboxError ("runtime died under harness ..."); probe succeeds → the program genuinely failed and the existing HarnessError stands.

Fixes RES-1195.

Verification

Real eval rollouts (bash harness, sleeper task whose agent runs sleep 63), killing the box manually mid-rollout:

  • docker (docker rm -f <container> mid-rollout)
    • before: trace.error = HarnessError: harness 'bash' exited 137
    • after: trace.error = SandboxError: runtime died under harness 'bash' (exit 137)
  • subprocess (workdir removed + harness process group SIGKILLed)
    • before: trace.error = HarnessError: harness 'bash' exited -9
    • after: trace.error = SandboxError: runtime died under harness 'bash' (exit -9)

Controls: a program exiting non-zero in a live box still records HarnessError on both runtimes. uv run pytest tests/v1 -n auto -m "not e2e" passes.

🤖 Generated with Claude Code


Note

Low Risk
Narrow failure-path change with an extra probe exec; genuine program failures in a live runtime still raise HarnessError unchanged.

Overview
When a harness segment exits non-zero, the framework now probes the runtime with Runtime.alive() (true exec) before assigning blame. If the box no longer runs commands, the trace gets SandboxError (“runtime died under harness …”) instead of HarnessError (“harness exited …”), so infra kills (e.g. exit 137 / -9) are not attributed to the agent program.

alive() is a default on the Runtime base class (success on exit 0, False on exec failure). The only call site is the shared non-zero exit path in Harness.run.

Reviewed by Cursor Bugbot for commit de4ada9. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Raise SandboxError instead of HarnessError when the runtime dies mid-rollout

  • Adds Runtime.alive() in base.py, an async method that runs true and returns False if any exception occurs.
  • When a program exits with a non-zero code, the rollout handler in harness.py now calls runtime.alive() to distinguish a dead sandbox from a program failure, raising SandboxError if the runtime is gone and HarnessError otherwise.
  • Behavioral Change: callers that previously caught HarnessError for all non-zero exits must now also handle SandboxError when the runtime has died.
📊 Macroscope summarized de4ada9. 2 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

Not every runtime raises when the box is gone — some surface it as exec's
own non-zero result, indistinguishable from the program failing. One probe
(Runtime.alive) on Harness.run's failure path tells the two apart, so a
dead sandbox records SandboxError instead of HarnessError.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread verifiers/v1/runtimes/base.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit de4ada9. Configure here.

Comment thread verifiers/v1/harness.py
@macroscopeapp

macroscopeapp Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This is a focused error-attribution fix that adds a runtime health check to distinguish between command failures and runtime deaths, raising the appropriate error type. The change is small, self-contained to diagnostic logic, and authored by the primary maintainer of these files.

You can customize Macroscope's approvability policy. Learn more.

@mikasenghaas
mikasenghaas requested a review from hallerite July 28, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants