Skip to content

feat(nemo_fabric_agent): run Fabric through agent sessions - #5538

Draft
yaoyu-33 wants to merge 11 commits into
mainfrom
codex/fabric-agent-sessions
Draft

yaoyu-33 wants to merge 11 commits into
mainfrom
codex/fabric-agent-sessions

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Fabric can now run through the agent-session interface inside the task sandbox supplied by Resources. Environment Server owns seed, activation, close, and verification; Fabric supplies only the agent. This updates the integration to NeMo Fabric 0.6.1, following #5057 at 15ad05a47d0e09170973f4e7fad30f660f83cfbe.

This is an experimental Evaluation integration. Keep it draft for architectural review. It does not expand benchmark allowlists or qualify training, full SWE/Terminal-Bench runs, or parity with native harnesses. No separate issue is needed for this bounded follow-up to #5057.

Changes:

  • Agent sessions use the shared SandboxSession supervisor, a private runtime, one idempotent activation, confirmed termination before verification, and explicit observation gaps. Required remote grants, static MCP/skills, task-specific users, continuation, unsupported request controls, and token-ID capture are refused.
  • Host dependencies and sandbox profiles pin Fabric 0.6.1. The managed host project retains the sandbox extra and OpenHands 1.50.0 dependencies; its lock is regenerated. Other adapters use Python 3.13.14.
  • Hermes v0.22.7 (b200f5bc60e31588ba2cb60e288029c4a54ba5fa) runs in an isolated Python 3.14 environment with Relay 0.11.1 and its own dependency overrides. The existing Anthropic preset also installs Hermes' Anthropic extra. Sandbox Python is checksum-pinned to 3.14.9. The optional host path installs its Python 3.14 worker on first use, shares concurrent installation, surfaces failures, and permits retry.
  • mini-SWE's preset uses fabric_config.models.default.settings.cost_tracking: disabled with a positive runtime.max_turns. Fabric 0.6.1 ignores the old MSWEA_COST_TRACKING variable; custom configurations using it must migrate. OpenClaw's documented CLI requirement is updated to 2026.9.34.

Compatibility and limits:

  • Unbound presets compose through sessions; the task needs a borrowed sandbox or an agent-owned sandbox_provider. Host /run remains available with an explicit resources_server binding and legacy_agent environment. Custom host Hermes configs must set adapter_project: hermes_env.
  • The 0.2.0-to-0.6.1 upgrade also reaches AnySWE, AnyTerminal, and presets embedding this agent. Their full benchmark behavior is not qualified here. Turn/step-limit results are incomplete rollouts that can be verified and scored.
  • Sandbox transitive dependencies and the separate host Hermes environment are not locked. Python archives and staged runtime specifications are checksum-verified. Hermes' upstream adapter redirects HOME; its effects on SWE home-directory behavior remain unqualified.
  • Invocation ownership, normalized turns, compaction, and some usage remain unavailable. Strict conformance stays not_fulfilled. No native harness, Resources Server, Environment Server, task data, or verifier is modified relative to main.

Current repair at bb0b0386c11ce88133b5409274e48b8ac9f28553 (November 6), merging main 9135278961525a4529f9369dc066a2f121a8e01a:

  • Preserve main's tool-result pairing by call ID and the private lazy Hermes runtime while resolving the merge conflicts.
  • Concrete structured Claude API failures carry their actual HTTP status through the session outcome policy: permanent 400/413/422 failures can be verified; 429/503 remain retryable and 401 fails. Unknown worker/setup failures still raise. Host /run and AnySWE callers retain exceptions for non-verifiable outcomes, so retries cannot become graded samples.
  • Cache/reasoning token inclusion follows Fabric's detailed usage metadata. Cache-exclusive Claude input is summed only when the required dimensions are known; ambiguous or partial totals remain unknown. Inclusive totals are recomputed without double counting.

Validation ran on the Linux workstation with Python 3.13.14 and locked component dependencies. All-files pre-commit run --all-files, whitespace checks, and DCO passed; the workstation source tree matches this commit. gym env test +entrypoint=responses_api_agents/nemo_fabric_agent +should_validate_data=true ++skip_venv_if_present=true: 209 passed. The earlier component + typed-outcome + dependency-policy run passed 222 tests, before the three additional host compatibility regressions. Original-source reproduction fails 17 of 18 selected new cases. The merged component lock resolves cleanly and remains unchanged.

One Reasoning Gym sages/fools task used an agent-owned debian:bookworm-slim sandbox, NIM nvidia/nemotron-3.5-super-vl-120b-a12b, temperature 0, top_p 1, max_tokens 4096, thinking disabled, a 240-second budget, and the unchanged verifier. Fabric 0.6.1 mini-SWE completed with original reward 1; health/profile commands passed. Strict evidence remains not_fulfilled: invocation/turn/tool ownership and sandbox identity are unavailable, and the legacy result omits evaluation_completed. Usage is explicitly unknown. This smoke exercised the repaired session/usage path before the final host-only failure guard; that guard is covered by the final component regressions. Servers and sandbox were cleaned up. This is not full conformance or benchmark qualification.

Historical validation for 1df46ff97c01d6335f8284334a5c92f844be034a, based on main 3a19fead7:

  • Fresh Linux Python 3.13.14 / uv 0.13.4 uv sync --locked and uv lock --check: passed.
  • gym env test +entrypoint=responses_api_agents/nemo_fabric_agent +should_validate_data=true ++skip_venv_if_present=true: 180 passed.
  • Session contract, environment composition, component dependency policy, and locked-install checks: 181 passed.
  • pytest tests/unit_tests/tooling/test_component_dependencies.py responses_api_agents/harness_agent/tests -q -o addopts= -o log_cli=false: 69 passed.
  • pre-commit run --all-files, whitespace checks, and DCO: passed. Fern npm run check: 0 errors, 1 warning.
  • Linux validation tree matches the committed tree: 4546c47d703858f14aff0d01b801f57d658047fd.

Real-model smoke on 2026-11-05 used the same Reasoning Gym task, Nemotron model, sampling settings, Docker image, budgets, and unchanged verifier. Version-specific adapter prompts and dependencies differ, and the baseline has an older Gym base; this is a compatibility smoke, not a causal performance comparison.

Path Completion Original reward
Fabric 0.5.0 mini-SWE baseline Completed 1
Fabric 0.5.0 Hermes baseline Completed 0
Fabric 0.6.1 mini-SWE session Completed 1
Fabric 0.6.1 Hermes session, Relay off Completed 0
Fabric 0.6.1 Hermes session, Relay on Completed 0
Fabric 0.6.1 Hermes host /run, Relay on Completed 0

Hermes outputs included additional prose; the 0.6.1 session with Relay also gave the wrong final assignment. The session without Relay and the host with Relay ended at the correct assignment after initially stating the wrong one. The unchanged scorer gave 0 for all Hermes cases. All three final session cases closed before verification, and all eight final-version model calls returned HTTP 200. Host Relay retained one ATIF trajectory. The three session health verdicts are unobserved, and strict evidence inspection is not_fulfilled, consistent with the Evaluation limitation. No task-owned server or sandbox remains.

The initial failed attempts are retained: mini-SWE failed price lookup with the obsolete environment flag, Hermes lacked its optional Anthropic SDK, and the host uv version could not select Python 3.14.9. The final runs above use the corresponding configuration/dependency fixes. Earlier Claude, TB, and cluster smoke receipts predate this upgrade and do not qualify 0.6.1.

Historical full CI for 1df46ff97c01d6335f8284334a5c92f844be034a: run 42257147997 completed with a failure in Core tests shard 3; it is not a passing result for the new head. Full CI for the new head has not been triggered through a trust comment.

Port the Fabric 0.5.0 upgrade and output conversion from Christian Munley's unmerged PR #5057 (63d4ed9), then add a sandboxed Evaluation session bridge. Resources and Environment Servers retain ownership of task setup, verification, and sandbox lifetime.

Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33 yaoyu-33 added feature New capabilities, enhancements, or enablement work area:agent Agent harnesses and Responses API agent behavior labels Nov 3, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 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.

yaoyu-33 and others added 2 commits November 3, 2026 14:36
… in-sandbox import

Fixes from the team review of #5538 (Linear GYMINT-145):

- Seed: refuse token-ID capture, a loopback model URL on a remote sandbox
  provider, and deterministic sandbox configuration errors (bad sandbox_config,
  undefined provider, unsupported platform) with a final 422 instead of a
  retried 500. An agent-owned sandbox gets a finite ttl_s.
- Activation: an adapter "timeout" result is an incomplete rollout that is
  verified, not a 500. Fabric stops Claude and Codex ten seconds before Gym's
  deadline and they report that error. Reject an empty input.
- Import cached_download lazily, so harness_agent's in-sandbox bundle (nemo_gym
  plus this package) still imports app.py.
- Install nemo-gym[dev,sandbox] on the host, as the other session agents do.
- Hash the Python archive once off the event loop; build the health check from
  FABRIC_VERSION; keep a malformed Relay ATIF file from stopping the worker.
- Docs: state what the runtime checksums cover, the install tools and egress,
  the preset and host-path behavior changes, and show timeout and max_turns
  overrides in the SWE-bench Pro example.
- Tests: lifecycle, release, timeout, validation and runtime-install cases,
  and a guard that fails if the import needs another agent package.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test eec420e

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

@yaoyu-33

yaoyu-33 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ce46731

@yaoyu-33

yaoyu-33 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ff9e727

@AdamRajfer AdamRajfer 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.

I would keep this as a draft for now. The adapter has no outcome typing: app.py has no classify_outcome, never calls report_outcome, and the diff imports no failure_kinds, so model-side endings and harness faults are indistinguishable to the outcome policy. Details inline.

Mergeable once model-side endings are typed, the deadline contract is explicit and tested, and the cross-adapter version bump is split out or comes with a comparison.

details = {k: v for k, v in error_mapping.items() if k != "message" and v not in (None, {}, [])}
if details:
error = f"{error} ({json.dumps(details, default=str, sort_keys=True)})"
raise RuntimeError(f"NeMo Fabric invocation failed: {error}")

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.

Blocking: _response_from_result raises RuntimeError("NeMo Fabric invocation failed") for every failed Fabric result outside the three-item _MODEL_STOPS set. Context limits, model request errors and transport errors become a retryable 500, indistinguishable from a harness crash, and a resumed run resamples them. Type them (model_context_limit, model_request_error, model_transport_error) and end them as the model's zero or a final typed outcome; infrastructure faults stay raised.

cleanup = state.session.cleanup
timed_out = bool(cleanup and cleanup["timed_out"])
# The adapter stopped itself at its own deadline: an incomplete rollout to verify, like a supervisor timeout.
adapter_timeout = failure is None and _mapping(_mapping(result).get("error")).get("code") == "timeout"

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.

Blocking: adapter_timeout trusts the adapter's own "timeout" code and returns incomplete. Fabric stops ten seconds before Gym, so this is the normal path, and it cannot tell "model never answered" from an agent timeout. The deadline contract needs one explicit answer with a test for the no-reply case.

"nemo-gym[dev]",
"nemo-fabric[claude,codex,deepagents,hermes-agent,mini-swe-agent]==0.2.0",
"nemo-gym[dev,sandbox]",
"nemo-fabric[claude,codex,deepagents,hermes-agent,mini-swe-agent,nooa,openclaw,openhands,relay]==0.5.0",

@AdamRajfer AdamRajfer Nov 6, 2026 •

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.

Blocking: the 0.2.0 to 0.5.0 bump also changes anyswe_agent, anyterminal_agent and the harness_agent presets. Split the bump into its own PR or add a before/after comparison for them; the host /run change that scores turn limits belongs in the same split.

_MODEL_API_KEY_ENV = "NEMO_GYM_FABRIC_MODEL_API_KEY" # pragma: allowlist secret
# Adapter failures that are the model's own outcome, as (error code, metadata subtype): the model ran out of turns or
# its step budget, so the rollout is verified and scored.
_MODEL_STOPS = frozenset(

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.

Non-blocking: the _MODEL_STOPS incompletes carry no kind (same gap as #5654; follow-up for all).

if cleanup:
access = state.request.sandbox_access
state.observations.records.append(
SandboxObservation(

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.

Non-blocking: SandboxObservation has no sandbox_id; list what each unobserved health check was missing.

tar -xzf "$scratch/source.tar.gz" -C "$generation/source"
# Installed console scripts reference this permanent path, so never rename the generation.
# The installer alone owns the lock; an orphaned pip process cannot retain it after a kill.
"$generation/python/bin/python3" -I -B -m pip --isolated install --no-cache-dir \

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.

Non-blocking: no network_access for owned sandboxes; the in-sandbox pip install is unpinned beyond the Python archive, so the runtime is not reproducible across a resume.

@yaoyu-33

yaoyu-33 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1df46ff

This branch was previously deployed

1 inactive (outdated) deployment
public — 1df46ff9 Deployed Nov 6, 2026 by copy-pr-bot[bot] via release / finalize / notify #10670
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior feature New capabilities, enhancements, or enablement work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants