Repository navigation
Description
Summary
A Harbor multi-step task ([[steps]]) run with turn_sessions: fresh starts a new agent session per step. Each step's evidence is complete on its own turn (HarborEpisodeResult.turns[i].agent_observations, plus the per-turn trajectory the server keeps), but the episode-level fields that rollout collection, the health checks and the ATIF exporter read, ng_trajectory and ng_agent_observations, held only the LAST step's session. A consumer of a 3-step episode saw one session's conversation, tool calls and tokens with nothing marking it as partial (CI review thread on #4819, "Aggregate all turns into canonical rollout evidence").
Decision for the PR stack (Adil, 25 Oct 2026): keep it simple and honest. For a fresh-mode episode with more than one step, the episode-level ng_trajectory and ng_agent_observations are left empty; the per-step evidence stays on turns[i], which is Harbor's own shape (steps/<name>/agent/ holds one trajectory per step). Single-step tasks and turn_sessions: continue are unchanged (one session, one cumulative record). The health checks then report these rows as having no episode-level trajectory evidence rather than a misleading partial one.
What to revisit
Whether to build the episode-level record from the per-step ones. TrajectoryRecord already models several invocations per episode (invocations[], each with its own conversation; turns[], model_calls[], tool_calls[], gaps[] keyed by invocation_id), and a continue-mode episode already appears as one invocation entry per activation. So a fresh-mode merge would be the union of the per-step records: invocations = [session of step 1, session of step 2, ...], turns/tool_calls/model_calls/gaps concatenated, ids kept distinct per session (they already are), nothing fabricated across sessions. Health checks and the ATIF exporter would then see every step's tokens and calls.
A first implementation exists (round 35 of the review work, branch r35-4819 in the authors' worktrees; not merged): a merge helper beside TrajectoryRecord plus per-turn namespacing of invocation ids. The refuter found one defect to fix before reuse: it added AgentInvocation.validate_timing (completed_at >= started_at) while stamping turns with two raw time.time() reads, so a wall clock stepping backwards during a turn makes the merge raise a pydantic ValidationError out of _run_turns.
Related, larger question raised in the same review: Gym's result contract is SingleAgentTurnResult; a continue-mode multi-step episode is one multi-turn conversation (n user prompts into one agent session), and a fresh-mode one is n single-turn invocations tied together by sandbox state. A multi-turn episode type (ordered per-step prompts, responses and rewards, the cumulative trajectory, turn_sessions) would represent both without overloading the single-turn fields; HarborEpisodeResult (which extends the single-turn result with turns) would be its first client. Also worth pinning down the three uses of "turn" (Gym episode contract, Harbor step record, trajectory assistant message) and "step" (Harbor sub-task vs agent-loop round).
References
- Review thread: PR feat(harbor): multi-turn tasks, Harbor [[steps]] as turns (M34) #4819, CI bot, "Aggregate all turns into canonical rollout evidence".
- Code:
environment_servers/harbor/app.py(_run_turns, the episode'sng_*assignment),nemo_gym/rollout_observability.py(TrajectoryRecord,AgentInvocation,TrajectoryTurn),nemo_gym/rollout_health.py,nemo_gym/atif_export.py. - Docs:
environment_servers/harbor/README.mdmulti-step section;fern/versions/latest/pages/data/multi-step-tasks.mdx.
🤖 Generated with Claude Code
Activity