Repository navigation
feat(harbor): turn_sessions, resume the agent across a task's steps (M34 follow-up) - #4998
Conversation
|
/ok to test ef299ec |
|
/ok to test 167a7a0 |
ef299ec to
167a7a0
Compare
167a7a0 to
9bacce4
Compare
|
/ok to test 9bacce4 |
|
/ok to test c883d3d |
|
/ok to test 69cd360 |
|
/ok to test f8a5b9c |
|
/ok to test 92aa104 |
|
/ok to test 479f4ee |
|
/ok to test 4945269 |
|
/ok to test b6e39ae |
|
/ok to test 9439797 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Thanks for fixing the final-step close ordering. I reproduced two remaining cases on 9439797b1: a constant-user task is rejected under continue, and an intermediate verifier failure loses evidence that cleanup subsequently retrieves. The inline comments describe both; the test and documentation suggestions are nonblocking.
One small PR-description clarification: default fresh runs with multiple sessions now leave episode-level ng_trajectory and ng_agent_observations empty, while retaining per-step records. #5063 explains the intentional tradeoff, but the current “fresh mode untouched” wording should call out the impact on consumers of those episode-level fields.
Validation here used local fixtures; a live continued rollout remains untested.
|
/ok to test 1f33365 |
|
/ok to test f690c35 |
|
/ok to test a32c826 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
LGTM, thanks for addressing the constant-user and intermediate-verifier evidence issues, and strengthening the tests and documentation. The focused regression checks pass. End-to-end RL testing on main, with any resulting fixes in separate PRs, remains the agreed follow-up.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40551688694 |
|
/ok to test cb737a3 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
LGTM. Rechecked against the current stack base: both PR commits are unchanged by the rebase, the earlier correctness fixes remain in place, and all 15 focused regression checks pass on this head. End-to-end RL testing on main, with any resulting fixes in separate PRs, remains the agreed follow-up.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40612814814 |
|
/ok to test 57e3b7d |
GET /v1/agent_sessions/capabilities on SimpleResponsesAPIAgent returns what a seed would confirm (the task-tool context and the multi-turn continuation this adapter supports) without seeding anything. An environment server reads it to refuse a run before provisioning: a multi-step task whose turns must continue one harness session needs continuation, as Harbor's multi-step trial refuses resume_trajectory for an agent without SUPPORTS_RESUME before any environment spend. One-activation adapters and agents without sessions answer with continuation null. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
…ask's steps Harbor's --resume-trajectory (a job or trial AgentConfig field, never task.toml) makes each step after the first resume the agent's native session. The server's equivalent is turn_sessions on the Harbor environment server, fresh (default, one session per step) or continue, set per run as a Hydra override. Under continue the first turn seeds one multi-turn continuation session (resume_harness_session) and every later turn is the next activation of it, named in the x-ng-agent-activation header, so the agent keeps its conversation across steps. Each step keeps its own instruction and [steps.agent].timeout_sec, is verified on its own between activations, and stops the episode as in fresh mode; the previous turn's grading files are still cleared before each turn. The session is closed once after the last turn (or the early stop) and its observations and cumulative trajectory are the episode's ng_agent_observations and ng_trajectory; per-turn results carry none. A classified failure of a continued turn closes the session for its evidence, then ends the episode by the outcome policy. The result reports turn_sessions. Refused before any sandbox, as Harbor's _validate_resume_support refuses before any environment spend: the agent server's capabilities are asked once per process (GET /v1/agent_sessions/capabilities; a 404 from an older agent server counts as none) and a harness without continuation fails the run at stage seed, terminally, naming the setting. A task whose steps switch the agent user is refused too, since the live session runs as the user it was seeded with. A single-step task is unaffected (Harbor's flag is a no-op below two steps). Documented divergence: the harness session stays alive in the sandbox while each step's verifier runs, where Harbor's resumed agent has exited between steps. _agent_turn is split into _open_agent_session, _activate_agent_session, _close_agent_session and _route_failed_response, which the fresh path and the continued path share. Only opencode_agent declares continuation today; Codex and Claude Code adapters are follow-ups. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
|
/ok to test 0007bcc |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
LGTM. Rechecked the latest head against the current stack base: both PR commits are unchanged by the rebase, the earlier fixes remain intact, and all 15 focused regressions pass on this head. End-to-end RL testing on main, with any resulting fixes in separate PRs, remains the agreed follow-up.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40730450076 |
What does this PR do?
Felipe's gap 5 / Adil's item 8 from the Harbor runtime review: resume across steps, Harbor's
--resume-trajectory, at the run level. New Harbor environment server settingturn_sessions: fresh | continue(defaultfresh, Harbor'sresume_trajectory = false), set per run as a Hydra override, never intask.toml, exactly where Harbor keeps it (a job or trialAgentConfigfield).Under
continuea[[steps]]task's first turn seeds one multi-turn continuation session (the agent-session contract'sresume_harness_sessionmode) and every later turn is the next activation of it, named in thex-ng-agent-activationheader, so the agent keeps its conversation across steps. Each step keeps its own instruction and[steps.agent].timeout_sec, is verified on its own between activations, and stops the episode as in fresh mode. The session is closed once after the last turn (or the early stop), before that step's verifier, and its observations and cumulative trajectory become the episode'sng_agent_observationsandng_trajectory; a failure that ends the episode on an intermediate step closes the session first and carries the same evidence. The result reportsturn_sessions.Default
freshruns are not untouched: a multi-step task whose agent ran on more than one step now leaves the episode-levelng_trajectoryandng_agent_observationsempty, while each step's own record stays on its turn (turns[].trajectory,turns[].agent_observations), one per step as Harbor keeps onesteps/<name>/agent/per step. A single fresh session still fills the episode-level slots, andcontinuefills them with the whole session's record. The tradeoff (several per-step records versus one merged episode record) is tracked in #5063.The run is refused before any sandbox when the harness cannot continue a session, as Harbor's
MultiStepTrial._validate_resume_supportfailsresume_trajectoryfast for an agent withoutSUPPORTS_RESUME: a new base-agent routeGET /v1/agent_sessions/capabilitiesdeclares the task-tool context and the continuation capabilities a seed would confirm, without seeding; the environment server asks it once per process. An agent server built before the route (404) is treated as declaring none. Onlyopencode_agentdeclares continuation today; Codex and Claude Code adapters are follow-ups (Harbor's resume-capable agents: Claude Code, Codex, Gemini CLI, Copilot CLI, Aider, Goose, Cortex Code).Commits:
feat(agent): declare session capabilities without seeding—AgentSessionCapabilitiesResponseand the GET route onSimpleResponsesAPIAgent, test intest_agent_sessions.py.feat(harbor): turn_sessions, one continued harness session across a task's steps— the env server (_open_agent_session/_activate_agent_session/_close_agent_session/_route_failed_responsesplit out of_agent_turn, thecontinuepath in_run_turns, the pre-flight), result field, fake-client support, seven multi-turn tests, README and the Fern multi-step page ("Resuming the agent across steps").Harbor parity check (Harbor 0.22.0
trial/multi_step.py,trial/trial.py,agents/installed/base.py)resume_trajectoryturn_sessions: continueAgentConfig.resume_trajectory, CLI--resume-trajectory; nevertask.tomlturn_sessions, Hydra override per run; nevertask.toml;test_server_config_holds_only_deployment_settingskeeps it a deployment setting_validate_resume_support: refuse before any environment spend whennot agent.SUPPORTS_RESUME; no-op whenlen(steps) <= 1_require_turn_continuationbefore_seed(no sandbox created); skipped for one step; testscreated == []_step_resumes(index): step 1 runs fresh, steps ≥ 2 callagent.resumeon the same native sessionactivation_headers() == ["1","2","3"])_step_agent_timeout_secagent_timeout_secmetadata (harness reads it per activation)_prepare_stepresets shared verifier dirs before every step;_reset_agent_logs_for_step(resume=True)keeps the agent dir (session state)_prepare_turnunchanged:/tests,/logs/verifierand the server's own ATIF export cleared; the harness's session state is its own and untouchedmin_reward, missing reward, step exception stop the trial; roll-upmulti_step_reward_strategytest_an_early_stop_closes_the_continued_session_before_the_result)[steps.agent].userstill applied around a resumed agent (relaunched as that user)SandboxSession._finish()). What the session retains across every step's verifier but the last's is its conversation state on disk in the sandbox and the borrowed connection the next activation reuses, both let go at close. Task-owned background services (anENTRYPOINT, a Compose service, a process a turn left behind) are not stopped between steps in either mode (documented)_archive_step_outputs(preserve_agent=True)copies rather than moves the agent dir between resumed stepsuser_agent(ACP bridge) refused for multi-step trialsValidation
Run on the login node from a git-archive copy (
-n 2, the stack's rebase venv with Harbor 0.22.0):environment_servers/harbor/tests+responses_api_agents/harbor_oracle_agent/tests+tests/unit_tests/test_agent_sessions.py(-k "not partial_eval and not buildah and not validate_ and not real_image and not test_verifier_filesystem"; the filesystem tests need a writable/tmp, which this node's sandbox denies): 563 passed.responses_api_agents/opencode_agent/tests(the one adapter with continuation; the base route is a pure addition): 527 passed, 16 skipped. Codex, Pi and Hermes suites collect cleanly (370 / 346 / 178).ruff check/ruff format --check: clean.test_the_capabilities_route_declares_continuation_without_seeding(base agent); intest_multi_turn.py: one session asked for continuation and seeded with the first step's budget, activations1,2,3with each step's instruction and budget, one close after the last turn, every step graded between activations, the session's evidence on the result and none on the turns, capabilities asked once before any sandbox; refusal before any sandbox for a harness declaring none and for an agent server without the route; single-step task and fresh mode untouched; early stop closes the session; steps switching the agent user refused; a classified failure of a continued turn closes the session for its evidence then ends the episode ungraded.continuerollout needs OpenCode on OpenSandbox and the compute node (the login node is not for that); planned on the next job alongside the Harbor-side comparison (harbor run --resume-trajectorywith Claude Code on the same two-step task).🤖 Generated with Claude Code