Repository navigation
Conversation
matrix72c
force-pushed
the
feat/sandbox-environment-design
branch
from
October 15, 2026 03:04
b08a5d5 to
2db9f71
Compare
matrix72c
marked this pull request as ready for review
October 15, 2026 03:04
matrix72c
force-pushed
the
feat/sandbox-environment-design
branch
from
October 21, 2026 06:11
3225eaa to
eee2016
Compare
Agent loops that serve an external harness need to stop admitting model calls before the manager aborts inference, and reopen admission after it resumes; otherwise the abort cuts requests the harness is still waiting on. Add optional prepare_pause/resume hooks to AgentLoop, RouterAgentLoop and AgentLoopActor, and call them around pause_generation/continue_generation in both the colocated and disaggregated managers. A failed drain now prevents the global abort. Generalize the close helper into call_agent_loop_hook.
Drop the cancellation-proof cleanup helpers and the error-chaining machinery. The trainer closes managers through asyncio_run, which never cancels the cleanup, so await_cleanup, gather_cleanup and CleanupError guarded a path that does not occur. Close failures are now logged and no longer replace the training result. Also remove id()-based owner dedup and the optional-hook getattr guard, which cannot trigger, keep a single closing check in the sandbox loop, shrink the lifecycle doc to the extension contract, and revert formatting changes to untouched test lines.
This branch has not been deployed
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.
Problem
Resource-owning AgentLoops have no framework shutdown hook. When training finishes or raises, a loop can keep background work and external clients alive after the trainer has stopped. In the disaggregated trainer, a producer blocked on generation never observes the shutdown flag, so
fit()can hang before any owner is closed.Change
AgentLoop.close(), a no-op by default. Both RL trainers close their training and evaluation managers whenfit()exits, including on error. Managers forwardclose()to local loops, Ray actors and router workers; every loop is closed even if another one fails. Close failures are logged and do not replace the training result.finallyblocks to release their pools.AgentLoop.prepare_pause()andAgentLoop.resume(), both no-ops by default. Managers callprepare_pause()beforepause_generation()andresume()aftercontinue_generation(), in both the colocated and disaggregated managers. Loops whose model calls come from an external harness use them to drain in-flight calls before the abort. Ifprepare_pause()raises, the manager does not abort inference.The contract is documented in
docs/en/rl/agent_loop_shutdown.md. Existing loops,Runner, Judger andAgentInSandboxLoopConfigusage are unchanged.Test plan
86 passed on top of current
upstream/main. New tests cover normal/error/cancelled trainer exits, training and evaluation owners, local/actor/router dispatch, failure isolation, the sandbox Runner/Pool cleanup path, producer shutdown ordering, and pause/resume hook ordering. Ruff, docformatter andgit diff --checkpass; mypy reports no errors on changed lines. Tests use fake backends and do not exercise live sandbox deletion or GPU training.