Skip to content

fix(conformance): prefer agent sessions - #4489

Merged
lafrancef merged 3 commits into
mainfrom
flafrance/conformance-native-agent-sessions
Oct 14, 2026
Merged

lafrancef merged 3 commits into
mainfrom
flafrance/conformance-native-agent-sessions

Conversation

@lafrancef

@lafrancef lafrancef commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Prefer the agent session interface in the harness conformance runner, with legacy agent /run fallback when session setup/close are unimplemented. Follow-up to #3766.

Detect implementations through the shared agent contract, including inherited handlers, and reuse single_agent_turn_legacy EnvironmentServer orchestration. Migrating an adapter to that contract automatically switches its probes. Agent session setup, activation, and cleanup failures remain visible and never trigger legacy fallback. CI preserves the pinned uv executable on PATH for Hermes session setup in later steps.

Validation

Reproduction commands for the Linux probes:

python scripts/run_harness_conformance.py \
  --harness codex --harness pi --harness opencode \
  --timeout 300 --output results/conformance-sessions
python scripts/run_harness_conformance.py \
  --harness hermes --scenario tool_success --scenario tool_failure \
  --timeout 300 --output results/conformance-hermes

Rollouts

All four real harnesses produced agent session rollouts with verification and Resources cleanup. Pi and Hermes tool-success/failure probes passed P0. The measurements retain Codex trajectory/ownership gaps, Pi retry ownership gaps, OpenCode local-sandbox identity gaps, and terminal model-error failure sidecars.

Compatibility and benchmark impact

Probes using agent sessions require Linux and install pinned harness runtimes during session setup. Legacy probes retain their preinstalled runtime requirement. Runtime metadata records the selected interface and resolved version pins. Probe expectations and benchmark scoring remain unchanged.

Signed-off-by: Frederic Lafrance <flafrance@nvidia.com>
@lafrancef lafrancef added feature New capabilities, enhancements, or enablement work area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters labels Oct 12, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ananthsub ananthsub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't use "native" terminology - this is really vague and hard to understand. #4070 updated the codebase at the time to move away from this terminology. please do the same here

Signed-off-by: Frederic Lafrance <flafrance@nvidia.com>
@lafrancef lafrancef changed the title fix(conformance): prefer native agent session interfaces fix(conformance): prefer agent sessions Oct 12, 2026
@lafrancef

Copy link
Copy Markdown
Contributor Author

/ok to test 0b68751

Signed-off-by: Frederic Lafrance <flafrance@nvidia.com>
@lafrancef
lafrancef requested a review from a team as a code owner October 12, 2026 19:39
@lafrancef

Copy link
Copy Markdown
Contributor Author

/ok to test 0bab21d

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 12, 2026 19:46
@yaoyu-33 yaoyu-33 added complexity:medium Single-domain change with interacting parts or a moderate review surface needs-review PR is ready for code review and waiting on a reviewer labels Oct 12, 2026
pachmu pushed a commit to pachmu/Gym that referenced this pull request Oct 13, 2026
The harness conformance checks (NVIDIA-NeMo#4489) exposed a gap in observability:
when an agent turn failed, the failure record carried none of the
agent's observations, so a model-error episode left no agent evidence to
check. The agent session was closed only in the final unwind, and its
observations were discarded.

This PR closes the agent session when the agent stage fails and carries
its observations on `SingleAgentTurnFailure` (verification failures
too). They reach the collected failure record as
`ng_agent_observations`, which then gets the capture join and trajectory
like a successful row. It also adds the `NG_AGENT_OBSERVATIONS_KEY`
constant for that key.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Marta Stepniewska-Dziubinska <martas@nvidia.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@zyzhou5 zyzhou5 added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed needs-review PR is ready for code review and waiting on a reviewer labels Oct 13, 2026
@zyzhou5
zyzhou5 enabled auto-merge October 13, 2026 19:11
@zyzhou5
zyzhou5 added this pull request to the merge queue Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38452985512

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 13, 2026
@lafrancef
lafrancef added this pull request to the merge queue Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38531566635

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 14, 2026
@lafrancef
lafrancef added this pull request to the merge queue Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38542378021

Merged via the queue into main with commit dc2c341 Oct 14, 2026
48 of 54 checks passed
@lafrancef
lafrancef deleted the flafrance/conformance-native-agent-sessions branch October 14, 2026 09:43
mk-0 added a commit that referenced this pull request Oct 14, 2026
Sandbox sessions:
- A run that times out before any model call completed (for example an
  unreachable model server) now fails instead of being graded as a zero;
  the error carries the tail of Kilo's log, which names the cause.
- A retried close no longer cancels an activation that is already cancelling.
- The runner records its hostname and PID; responses report them with the
  Kilo version, and the sandbox record carries the sandbox id.

Local runs:
- Output is file-backed and the process group is killed on timeout and on
  request cancellation, so partial events survive and Kilo never outlives
  its request.
- CLI errors, nonzero exits and timeouts before any model call return a
  failed response with the reason; /run reads Kilo's session database and
  returns agent observations.

Shared:
- Use opencode_agent's session parser (maps bash outcomes from exit codes)
  instead of the deprecated opencode_sandboxed_agent.
- Disable Kilo's auxiliary session-title call by default for Gym-managed
  providers.
- Register Kilo in the harness conformance suite; rename setup_kilo to
  setup_kilocode to follow the setup_<harness> convention.
- Add a read-only AsyncSandbox.sandbox_id property.

Conformance (session mode, Linux): all checks pass in 6 of 7 scenarios;
model_error shows the session-mode gap shared by all harnesses (#4489).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marat Kitov <mkitov@nvidia.com>
@marta-sd marta-sd mentioned this pull request Oct 15, 2026
7 tasks
giuliolovisotto added a commit that referenced this pull request Oct 20, 2026
Preserve agent-owned sandbox identity and grade initial HTTP 400
rejections through agent sessions after the conformance runner switch.
Keep infrastructure and partial-generation failures exceptional.

Refs #4489

Signed-off-by: Giulio Lovisotto <glovisotto@nvidia.com>
giuliolovisotto added a commit that referenced this pull request Oct 20, 2026
Restore native call identity, ownership and bounded 429 retries on the
agent-session path selected by conformance since #4489. Grade an initial
HTTP 400 rejection only after clean execution with no generated output.

Signed-off-by: Giulio Lovisotto <glovisotto@nvidia.com>
ekellbuch pushed a commit to ekellbuch/Gym that referenced this pull request Oct 20, 2026
* feat(kilocode): run Kilo in task sandboxes

Add native sandbox sessions to the KiloCode agent so it composes with any
Resources server through single_agent_turn_legacy, as Pi and Codex do.

- Session setup installs a checksum-verified Node 22 and the pinned
  @kilocode/cli into a private per-session directory (glibc and musl);
  task images need only Linux and Python 3.8+.
- The CLI runs under the shared SandboxSession supervisor in the task
  workdir with isolated HOME/config/database and no repo-level config.
- Close returns observations from a snapshot of Kilo's SQLite database
  (root and child sessions, tool timing, usage), annotated with the run
  outcome; CLI/API errors fail the episode instead of scoring zero.
- Kilo's stream watchdog (chunkTimeout) follows the harness timeout,
  since the Gym model server returns completions only once finished.
- Host installation becomes lazy, on the first local invocation.
- kilocode_sandboxed.yaml, SWE-bench Pro allowed_agents, and the legacy
  environment-server migration entry.

Validated on SWE-bench Pro with the stock Resources server: 5-task smoke
across Ubuntu/Node/Go/Python/Alpine images, and 731x3 at 51.30% mean
pass@1 (Nemotron 3.5 Super).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marat Kitov <mkitov@nvidia.com>

* docs(kilocode): trim sandbox README to the shared harness layout

Keep the sections other native harnesses document; move run results and
limitations to the PR description.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marat Kitov <mkitov@nvidia.com>

* fix(kilocode): align sandbox sessions with the reference harnesses

Address review and match Pi, Codex, OpenCode and OpenClaw.

- Classify a run from the supervisor cleanup receipt. A runner exit,
  supervision error or missing exit status without a timeout fails the
  episode instead of returning an empty incomplete response. Supervised
  timeouts and length stops stay gradable.
- Run a POSIX sh bootstrap before the Bash installer, and check in the
  sandbox that the task workdir and session storage do not overlap after
  resolving symlinks.
- Return 422 for unsupported setup, require direct SandboxAccess, and
  return 409 for activation of a closing session or /run with a session.
- Snapshot the Kilo database only after confirmed cleanup, and report a
  gap when the receipt has no exit code.
- Add bootstrap, lifecycle-contract and exec-transport tests from the
  reference harness templates.

Validated on 250 SWE-bench Pro tasks with the stock Resources server:
250/250 graded, no agent or infrastructure failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marat Kitov <mkitov@nvidia.com>

* fix(kilocode): surface failed runs and pass harness conformance

Sandbox sessions:
- A run that times out before any model call completed (for example an
  unreachable model server) now fails instead of being graded as a zero;
  the error carries the tail of Kilo's log, which names the cause.
- A retried close no longer cancels an activation that is already cancelling.
- The runner records its hostname and PID; responses report them with the
  Kilo version, and the sandbox record carries the sandbox id.

Local runs:
- Output is file-backed and the process group is killed on timeout and on
  request cancellation, so partial events survive and Kilo never outlives
  its request.
- CLI errors, nonzero exits and timeouts before any model call return a
  failed response with the reason; /run reads Kilo's session database and
  returns agent observations.

Shared:
- Use opencode_agent's session parser (maps bash outcomes from exit codes)
  instead of the deprecated opencode_sandboxed_agent.
- Disable Kilo's auxiliary session-title call by default for Gym-managed
  providers.
- Register Kilo in the harness conformance suite; rename setup_kilo to
  setup_kilocode to follow the setup_<harness> convention.
- Add a read-only AsyncSandbox.sandbox_id property.

Conformance (session mode, Linux): all checks pass in 6 of 7 scenarios;
model_error shows the session-mode gap shared by all harnesses (NVIDIA-NeMo#4489).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marat Kitov <mkitov@nvidia.com>

* fix(kilocode): keep the task's HOME for tool shells and retain setup state

Kilo's tool shells inherited the HOME and XDG directories that keep Kilo's own
state private, so files that tools wrote under the home directory landed in the
session directory and were deleted by agent close before verification. A plugin
now restores the task's HOME and XDG directories for every shell command through
Kilo's shell.env hook, as OpenCode does. Sandbox runs no longer pass --pure, which
would skip that plugin; codebase indexing stays off because kilo.json names no
indexing plugin. Kilo only logs a plugin that fails to load, so a run without the
plugin's receipt fails instead of being verified.

Also from review:
- A cancelled local caller no longer releases another caller to start a second
  installer; one shielded installation task is shared, as in Pi.
- An owned sandbox is retained in the session before start(), so close can stop a
  sandbox that start() allocated but failed to finish setting up.
- A child invocation that stopped on the output limit is reported as incomplete,
  not completed (require_terminal_finish=True).

Validation: Kilo tests pass locally, including the plugin loaded by the pinned
Kilo 7.4.15 binary; the Linux unit suite on AGA shows no new failures; a 5-task
SWE-bench Pro smoke returned and graded 5/5 (4 solved), with the plugin confirmed
in every run and no tool output referring to Kilo's private home.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marat Kitov <mkitov@nvidia.com>

* fix(kilocode): read kilo_version in conformance install and fix musl docs

Conformance CI install looked up kilocode_version, but Kilo's configs only
define kilo_version, so setup raised KeyError for the newly registered
harness. Map kilocode to kilo_version.

The README claimed musl support on aarch64, but install_kilo_runtime.sh
rejects it (the pinned Node musl build is x86_64 only). Document that.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>

* test(kilocode): align exec transport tests with main's termination semantics

Main now leaves detached tools from a natural CLI exit for the sandbox owner
to tear down, and treats a negative cleanup receipt as final: close releases
the borrowed session instead of staying retryable. Update the KiloCode exec
transport tests to match, as main did for Codex and OpenCode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>

---------

Signed-off-by: Marat Kitov <mkitov@nvidia.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: yaoyu-33 <yaoyu.094@gmail.com>

This branch was previously deployed

1 inactive deployment
public — 0bab21d7 Deployed Oct 12, 2026 by copy-pr-bot[bot] via release / finalize / notify #5084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants