Repository navigation
fix(interactive_browser): drop a browser's record only after it closes - #6412
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
0e18a88 to
7c30750
Compare
ff2e211 to
4886429
Compare
4886429 to
77078c1
Compare
7c30750 to
0d0324f
Compare
77078c1 to
bd640ef
Compare
0d0324f to
0aa8151
Compare
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
The close endpoints have one correctness RISK, reported inline.
RISK: Provide the required model-backed smoke evidence
The PR marks rollouts N/A, but this changes environment lifecycle behavior. The protected AGENTS.md quality bar requires representative real smoke rollouts with a model and inspection of agent and verifier behavior. Unit tests cover the failure paths, but they do not supply that integration evidence.
Could you run representative bundled tasks through the configured pairing and add the commands, model/configuration, rollout outcomes and inspected artifacts to the PR? The README provides the rollout commands. Proposed acceptance: inspect a navigation task and a form-submission task for meaningful browser tool calls, correct task rewards and completed cleanup. Keep the cancellation and failed-close regression tests; a successful model rollout does not replace those checks. This addresses missing validation evidence, not a demonstrated normal-rollout failure.
I inspected both changed files and traced the affected lifecycle callers and backend teardown contracts. One delegated report was unavailable, so I covered its test, dependency and validation-policy scope directly. This was static review; I did not execute tests.
Inline comments (escaped v1):
-
resources_servers/interactive_browser/app.pyline 276: ### RISK: Do not acknowledge and fence a close while its browser is still heldThe new _release failure branch keeps the browser but returns normally. This caller then clears its episode identity, fences the session and returns 200. A repeated typed close takes the fenced early return, so it never retries teardown.
The retained record also introduces an observable regression after that acknowledged close. Seed with
answer_equals: "42", finish with42, and use a backend whose firstclose()raises./close_sessionreturns 200, but/verifywith the saved cookie still finds the record and returns reward 1 without masking. In the base implementation, the record was removed, so verification after the acknowledged close reported maskedsession_lost. This affects backends that surface close exceptions, including registered extensions; the shipped backends swallow ordinary teardown failures.Could both branches of
close_resources_sessionreject the close when_releaseleaves a record? Insert this immediately after eachawait self._release(session_id), before clearing identity, fencing or acknowledging closure:if session_id in self._session_id_to_state: raise HTTPException(503, "The session's browser could not be closed; close it again to retry")
The invariant is that a successful close acknowledgement means the session holds no browser. Failed teardown must keep its ownership and remain retryable. This insertion leaves verification's score handling and shutdown's best-effort cleanup unchanged. Verify the suggested code before adopting it.
Proposed regression checks, not executed: use a backend whose first close raises and second succeeds. The first typed close must return 503, keep the browser and episode identity, and install no fence. Another episode's close must still return 409. The owner's second close must return 200 and remove the record; a third close must remain idempotent. Verification with the saved cookie after successful closure must return reward 0 with
mask_sample=Trueandfailure_kind=session_lost. Cover failure/retry through the empty-body cookie close too. Retain the existing close-before-seed refusal, successful-close behavior, failed-reseed refusal and replacement-state identity assertions in the session tests.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
bd640ef to
ec990ad
Compare
0aa8151 to
1de460e
Compare
hemildesai
left a comment
There was a problem hiding this comment.
SHIP
The record is kept until the close succeeds, and the is st check stops a close from dropping a browser that a re-seed installed meanwhile. The unbounded shield is fine, because each teardown step has its own time limit (_CLOSE_STEP_TIMEOUT_S in page.close, _RELEASE_TIMEOUT_S in lexmount release). The 503 on re-seed is right. Session tests pass locally (33 passed). One non-blocking NOTE inline.
ec990ad to
caa0d8b
Compare
c8b292c to
5131416
Compare
3d60596 to
44b3b7e
Compare
5131416 to
3c6f2b6
Compare
|
On the automated review's close RISK: fixed in 3c6f2b6, as suggested. Both close paths answer 503 when
|
|
On the automated review's request for smoke evidence: I ran model-backed rollouts of 3c6f2b6 on a cluster node, with headless Chromium through the local Playwright backend and the hosted
The details are in the PR description's Rollouts section. The failure paths this PR changes do not occur in a healthy run, so the unit tests remain their coverage. |
3c6f2b6 to
bb422bb
Compare
44b3b7e to
33aba16
Compare
hemildesai
left a comment
There was a problem hiding this comment.
Re-approving after the retarget to main (6411 merged). The PR's own change is the one I approved, including the 503-without-fence retry fix, and CI is green on bb422bb.
interactive_browser's _release dropped the session's record before awaiting the browser's close. A close that failed, or that a cancelled request cut short, left a running browser that nothing tracked. It now drops the record only once the close succeeded, and only the record of the browser it closed. A browser whose close failed stays with its session: - A close of the session answers 503 and is not fenced, so its retry closes the browser again. A close is acknowledged only once the session holds no browser, so a verify after it is a lost session. - A re-seed of the session closes it first and answers 503 rather than replace one that is still running. - The shutdown stops it otherwise. The close is shielded from the request's cancellation, without an overall time limit, because each of its teardown steps already has its own. The real backends report no close failure, so there the shield is what changes; the kept record covers a backend that does raise. opencode_search, which this change also covered, already keeps an agent run's sandbox until its stop succeeds and stops what is left at shutdown on main. Signed-off-by: Ananth Subramaniam <[email protected]>
bb422bb to
1e19e37
Compare
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44583552463 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44584339679 |
What does this PR do?
interactive_browser's
_releasedropped the session's record before awaiting the browser's close, so a close that failed, or that a disconnect cut short, left a browser that nothing tracked.The close is shielded from the request's cancellation, without an overall time limit, because each of its teardown steps already has its own. Its real backends report no close failure, so there the shield is the change that matters; the kept record covers a backend that does raise.
This PR used to cover opencode_search too. #6211 has since moved opencode_search onto environment server sessions, which already keep an agent run's sandbox until its stop succeeds and stop what is left at shutdown, so only interactive_browser remains.
How it works
The release of a session's browser:
flowchart LR subgraph before["Before"] direction TB a1["release"] --> a2["pop the session's record"] a2 --> a3["await the close"] a3 -->|"cancelled or fails"| a4["running browser<br/>that nothing tracks"] end subgraph after["After"] direction TB b1["release"] --> b2["read the session's record"] b2 --> b3["await the close, shielded"] b3 -->|"succeeds"| b4["drop the record,<br/>if it still names what was closed"] b3 -->|"fails"| b5["keep the record"] b5 --> b6["the close answers 503, unfenced;<br/>its retry or a re-seed closes it again,<br/>or the shutdown does"] end before ~~~ afterWhere this sits in the stack
This is one PR in a stack of PRs that implement Milestone 1 of the sandbox ownership design: every sandbox has one owner, the server that starts it, which stops it on every path, and every other user borrows it. Each PR is one commit, so each diff shows only that PR's change.
maindirectly.mainwhen it resumes.The highlighted box is this PR.
ananthsub/sandbox-stop-keep-record): fix(interactive_browser): drop a browser's record only after it closes (this PR)ananthsub/owned-sandboxes): feat(sandbox): make the sandbox checkpointer the public OwnedSandboxesananthsub/owned-sandboxes-lifecycle): feat(sandbox): stop, start and export owned sandboxes safely under loadananthsub/owned-sandboxes-network): feat(sandbox): typed network rule and provider capabilities for ownersananthsub/sandbox-borrow): feat(agents): borrow lent sandboxes and type the agent's own sandboxValidation
pre-commit run --files <changed files>on the unit's diff (ruff, ruff-format, import-linter, guardwords).pytest -n 16 tests/unit_tests, in a venv with CI's extras, with the same failures as onmain.Rollouts
Smoke rollouts of this PR's head (3c6f2b6) with a model, as Slurm job 2074708 on a CPU node:
resources_servers/interactive_browser/configs/interactive_browser.yamlwithinteractive_browser_simple_agent, the local Playwright backend (headless Chromium) and the hostedeccn-gpt-6-lunamodel throughopenai_model.data/example.jsonl: navigating to the about and index pages, the login form (dom_contains: Welcome neo), the form page, and an answer task (answer_equals: ALPHA-42).gym eval runexited 0, with no missing, masked or unscored rollouts.The failure paths this PR changes (a failed close, a close cut short by cancellation, a re-seed over a failed close) do not occur in a healthy run, so the unit tests cover them.
Compatibility and benchmark impact
A re-seed of a session whose previous browser could not be closed now gets a 503 instead of silently replacing it and leaking the old one.
Checklist
git commit -s).