nemo_gym.agent_utils.sandbox_session
nemo_gym.agent_utils.sandbox_session
Agent-server lifecycle for one supervised harness activation.
Module Contents
Classes
Functions
Data
API
Harness argv and the installed interpreter used to launch its supervisor.
Execute, stop, capture, then release an owned or borrowed sandbox.
Runtime installation belongs in the adapter’s seed hook. stage_activation
stages input and returns a command; collect copies harness artifacts
to the agent server after cleanup is confirmed. It may run a bounded snapshot
command, but must not restart the harness. Parsing responses stays in the adapter.
A new session stages input and its supervisor, runs the harness process, then stops and collects artifacts. Execution retains the sandbox until close releases it. Missing termination evidence remains retryable. A final negative receipt skips capture, releases a borrowed connection and leaves teardown to Resources; an owned sandbox falls back to provider stop. Closed means release succeeded.
On timeout or close, the supervisor preserves previously adopted children outside the harness group and drains newly adopted children, including services orphaned by in-flight tools during the stop. Preserved children can also be unfinished background jobs; they remain until the sandbox owner destroys the sandbox. Natural CLI exit has no adoption cutoff, so detached unfinished tools may remain. Borrowed sandboxes stay available for Resources verification; owned sandboxes are stopped on close. Unconfirmed harness termination prevents capture and verification.
Each stop, collection and release phase is bounded by close_timeout (or
the timeout passed to close). Failed cleanup/release retains the handle
for retry. Failed capture is recorded separately and does not prevent release.
HTTP request binding and activation retries belong to the agent session layer.
Whether sandbox release completed successfully.
Whether close has been requested, including a failed attempt.
Marker path an adapter may pass to its harness for cancellation diagnostics.
Join finalization before release; concurrent/retried closes never duplicate capture.
Run once, preserving captured artifacts even when execution raises.
Cancellation stops the remote harness before releasing provider exec. Callers that merely stop waiting (such as disconnected HTTP requests) must shield their shared activation task.
Read combined supervisor/harness diagnostics without masking the original failure.
Confirm harness termination before capture and transport release.