Skip to content

local task run: keep going through a network blip; retry teardown and name what's left up - #997

Open
sarah-chitty-1 wants to merge 4 commits into
mainfrom
sarahchitty/local-run-teardown-retry
Open

sarah-chitty-1 wants to merge 4 commits into
mainfrom
sarahchitty/local-run-teardown-retry

Conversation

@sarah-chitty-1

@sarah-chitty-1 sarah-chitty-1 commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Symptom: a local agent-env task run dies when the laptop loses DNS mid-run (pymongo ServerSelectionTimeoutError / httpx ConnectError "nodename nor servname provided"). The runner logs "interrupted by shutdown", and teardown fails too, so every sandbox the run started (env VM, browser, agent, user sim, judge) stays up until its 6-hour TTL. It happened twice on one PSI task in a day, and 10 sandboxes had to be stopped by hand each time.

Fix:

  • The local runner keeps following a run through a short network blip instead of ending it.
  • Teardown retries on network errors, with backoff, for a bounded time.
  • When teardown still can't close a sandbox, it prints the ids it left up, with the command to stop them.

Hub runs aren't affected.

Tests: new unit tests fake the network errors. tst/unit/runner/local_runner_test.py and tst/unit/cli/submit_runs_test.py pass (47). The wider unit suite is still running locally; CI will run it too.

🤖 Generated with Claude Code

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge, with a non-blocking gap in step output after network recovery.

FindingsFix All in Cursor

  1. P2 Step details disappear after recovery ▶
Fix with agent prompt
### Issue 1
src/agent_env/cli/submitted_runs.py:102-103
If the network drops while `_step_context` reads a completed step's journal, this retry resumes polling but never prints that step's details. `_poll_run` adds the step to `run.steps` before `_echo_step` finishes, so later polls skip it. The command can report success without showing a deployed endpoint or verifier result.

Add the step to `run.steps` only after its output succeeds.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR keeps polling through brief network outages and retries sandbox cleanup with backoff.

  • The CLI keeps following runs through brief network outages.
  • Local runs retry failed sandbox cleanup and name anything left up.

Reviews (2) · Last reviewed commit: "local run: retry sandboxes concurrently ..." · Reviewed by Greptile

…rdown and name what's left up

A single failed read of the run index (a laptop losing DNS for a moment) made the CLI stop
following, which stopped the LocalRunner and cancelled runs that were still working; their
teardown then failed on the same outage and left every sandbox up until its TTL.

- submitted_runs: a failed poll is retried for up to OUTAGE_SECONDS (10 min) before giving up.
- LocalRunner: a sandbox the teardown couldn't terminate is tried again with backoff, and what
  is still up is logged with the agent-env task teardown command that removes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sarah-chitty-1
sarah-chitty-1 marked this pull request as ready for review December 3, 2026 01:09
@sarah-chitty-1
sarah-chitty-1 requested a review from a team as a code owner December 3, 2026 01:09
Comment thread src/agent_env/runner/local_runner.py Resolved
Comment thread src/agent_env/runner/local_runner.py Resolved
Comment on lines +102 to +103
await asyncio.sleep(POLL_SECONDS)
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Step details disappear after recovery

If the network drops while _step_context reads a completed step's journal, this retry resumes polling but never prints that step's details. _poll_run adds the step to run.steps before _echo_step finishes, so later polls skip it. The command can report success without showing a deployed endpoint or verifier result.

Add the step to run.steps only after its output succeeds.

Knowledge Base Used: Command-line workflows

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/cli/submitted_runs.py
Line: 102-103

Comment:
**Step details disappear after recovery**

If the network drops while `_step_context` reads a completed step's journal, this retry resumes polling but never prints that step's details. `_poll_run` adds the step to `run.steps` before `_echo_step` finishes, so later polls skip it. The command can report success without showing a deployed endpoint or verifier result.

Add the step to `run.steps` only after its output succeeds.

**Knowledge Base Used:** [Command-line workflows](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%2Fknowledge-base%2Fscaleapi%2Fagentenv-framework%2F-%2Fdocs%2Fcommand-line-workflows.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Cursor Fix in Claude Code Fix in Codex

This branch has not been deployed

No deployments
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.

1 participant