Skip to content

feat(agents): let OpenCode, Hermes and Pi take Harbor tasks that declare skills_dir - #6351

Open
adil-a wants to merge 26 commits into
adasif/gym-1268-task-skills-cli-harnessesfrom
adasif/gym-1268-task-skills-opencode-hermes-pi
Open

adil-a wants to merge 26 commits into
adasif/gym-1268-task-skills-cli-harnessesfrom
adasif/gym-1268-task-skills-opencode-hermes-pi

Conversation

@adil-a

@adil-a adil-a commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Depends on the task-skills PR for Claude Code and Codex (#6293) and is stacked on its branch. Until that PR
merges, this diff includes its commits. Only the commits after it are new: 606cb466e through 0bb22e5d6, the
merges dd4067a36 (task-skills head 09c0ff566), ce1585877 (origin/main at a7bc8ceeb) and be5feec58
(task-skills head 0a7de79f5, which includes main at 51630ce4f), then 4249940de (Hermes test fit to main),
fc26806de (docs), 77cca30e9 and e07a2acd5 (OpenCode task skills across a checkpoint restore), and the merge
e0755fc23 (task-skills head 6406bf6a6, which includes main at 15adc2254). Head: e0755fc23. Merge after the
task-skills PR (#6293).

What does this PR do?

OpenCode, Hermes and Pi now run Harbor tasks that declare [environment] skills_dir, and the model finds the skills
through the runtime's own skill mechanism. Before, the harbor Environment Server refused these tasks for all three.
It reuses the supports_task_skills seed capability from the task-skills PR (#6293) and its stage_task_skills, which
copies the folder that /tmp/.nemo-gym/task.json names.

Refs #5639 (Harbor tasks that declare skills_dir are refused for Claude Code, Codex and OpenCode; Linear GYM-1268).
Together with the task-skills PR (#6293) it covers every harness the issue names.

  • OpenCode 1 copies the skills to <XDG_CONFIG_HOME>/opencode/skills. The default profile denies the skill
    tool. By design, only a session whose task declares skills_dir gets skill: allow, added last because OpenCode
    applies the last matching rule; every other task keeps the deny. OpenCode 2 discovers skills another way, so it
    declares nothing and still refuses these tasks.
  • Hermes copies the skills to <HERMES_HOME>/skills and turns on its skills toolset for that session only (a
    Harbor run otherwise keeps just terminal), so Hermes lists the skills in its system prompt.
  • Pi copies the skills to <PI_CODING_AGENT_DIR>/skills and passes the folder with --skill; discovery stays off
    (--no-skills). Pi lists skills only when its read tool is on, so it declares nothing with enable_tools: false.
  • Only a task sandbox the Environment Server lent is staged. A failed copy, a bad task.json or a missing folder
    refuses the seed (422) and releases the sandbox.
  • OpenCode checkpoints. A session's partial-rollout checkpoint (added on main) carries its task_skills, so a
    restored session keeps skill: allow. A re-bind that finds the fork without the session's files copies the skills
    again from the folder the checkpoint names (a new skills_dir keyword of stage_task_skills), not from task.json,
    which is under /tmp too and usually gone from such a fork. Hermes and Pi join checkpoints as restart-only, so they
    seed, and stage the skills, again after a crash. The harbor Environment Server, the only one that writes
    task.json today, is itself restart-only, so a Harbor episode starts over after a restore and does not reach this
    path yet; it matters for an Environment Server that checkpoints in exported mode.
  • Docs: a per-harness table on the Agent Skills page, plus the Harbor server README and pairing page
    (task_mcp_grants row), the task-folder and SkillsBench pages and the three harness READMEs. The Harbor admission
    comment and two Harbor test docstrings now name any harness that declares supports_task_skills.

Validation

At the head e0755fc23 (main at 15adc2254 merged in through the Claude Code/Codex task-skills PR (#6293)), with
gym env test (serial) and root tests at -n 2:

  • opencode_agent: 1164 passed, 25 skipped
  • hermes_agent: 416 passed, in a venv built fresh for the merged tree
  • pi_agent: 419 passed, 32 skipped
  • claude_code_agent: 304 passed
  • codex_agent: 635 passed, 9 skipped, 1 failed: test_close_confirms_cleanup_before_provider_cancellation read the child's children.json before the child had written it (an empty file, JSONDecodeError), a timing race in a test this PR does not touch; it passed 3 of 3 reruns on this head and 3 of 3 on main 15adc22542
  • environment_servers/harbor: 732 passed
  • root tests/unit_tests/agents: 856 passed, 5 failed; all 5 also fail on main 15adc22542 in a dev venv built from the same lock: 3 outcome-policy upload-evidence tests need cloudpickle and 2 sandbox_python archive-owner tests depend on the host's gid mapping
  • Merge be5feec58. Conflicts from main's Hermes v0.23.2 update, OpenCode checkpoint pauses and crash resume,
    and Pi's activation refactor. Hermes: main moved payload building into _worker_payload(), which now takes a
    task_skills keyword from the sandbox episode; this PR's skills-toolset block runs there. OpenCode: this PR's
    task-skills staging follows main's new _install_session_files() call. Pi: --skill <folder> follows
    --no-skills in main's _sandbox_payload(). 4249940de runs the Hermes staged-skill test with Hermes' own host
    interpreter, as main's Hermes update requires. e0755fc23 (main at 15adc2254) merged with no conflicts.
  • Fixes 77cca30e9 and e07a2acd5. The two tests 77cca30e9 added to opencode_agent/tests/test_checkpoint.py
    fail without it (OpenCode suite: 2 failed, 1161 passed, 25 skipped). On 77cca30e9, the re-bind test, now run with
    task.json kept and lost, fails in both cases, and the two new skills_dir tests in
    tests/unit_tests/agents/test_task_skills.py fail (3 failed, 19 passed); all pass with e07a2acd5.

The counts below were measured before that update; none at the head ce1585877.

  • Merges. dd4067a36 merged cleanly. In ce1585877, responses_api_agents/hermes_agent/app.py conflicted;
    both independent constant blocks are kept (this branch's _SKILLS_TOOLSET, main's _OUTPUT_LIMIT_ERRORS). A
    scratch merge of 0bb22e5d6, 09c0ff566 and origin/main 3d4fb51f4 (same Hermes resolution; same harness,
    Harbor and nemo_gym/agents code as ce1585877) passed with -n 8: Hermes suite 414; OpenCode sandbox-session
    and continuation tests 323; Pi skill tests 6; Harbor 401; root task-skills and agent-session tests 58.
  • 0bb22e5d6 (docs, comments, test docstrings), -n 8 on a loaded node: Hermes 409 passed; OpenCode 981
    passed, 4 failed; Pi 363 passed, 25 failed; Harbor test_app.py and test_multi_turn.py 400 passed, 1 failed
    (test_a_deadline_during_the_next_steps_preparation_reports_the_agent_stage_without_the_previous_response, which
    this PR does not change; it passes in the scratch merge and passed in a full Harbor-suite run at 05be6c5bb, where
    a different slow-seed timing test failed instead); root (task-skills, agent-session, public-API and
    session-contract tests) 1059 passed. Each OpenCode and Pi failure was a timeout or wall-clock assertion that passed
    serially or alone. pre-commit run --files on the commit's five files, and ruff check, ruff format --check and
    git diff --check on all touched files: clean.
  • The working tree later committed as 05be6c5bb: pre-commit run --files <touched files> passed. Root venv,
    pytest tests/unit_tests/{agents,tooling,data/tasks/harbor} tests/unit_tests/test_session_contract_repo.py tests/unit_tests/test_public_api_facades.py -n 8: 3816 passed, 8 skipped, 11 failed; ten also fail at the base
    commit (cloudpickle, jinja2 missing from the venv; a host uid/gid), one passes serially.
  • The new tests fail without the source change; the no-skills controls pass either way. Changed existing tests:
    OpenCode's seed reply gains supports_task_skills, and the OpenCode and Hermes seeds run one more exec. One test
    runs Hermes's own prompt builder and skill_view on a skill staged in the runner's HERMES_HOME.

Rollouts

A hosted GPT model behind an OpenAI-compatible endpoint (openai_model), on OpenSandbox; OpenCode 1.17.11, Hermes
at its pin, Pi 0.80.2. All six runs were at 05be6c5bb with model-call capture on, not rerun after the docs-only
0bb22e5d6 or the merges. The demo skill says "The magic word is pineapple."; test.sh scores the answer.

Case Reward Observed
OpenCode, skills 1.0 skill among the tools; <available_skills> lists demo and customize-opencode; one skill {"name": "demo"}
OpenCode, control 0.0 No skill tool (denied); answered "Abracadabra"
Hermes, skills 1.0 Tools gain skills_list, skill_view, skill_manage; prompt lists demo; one skill_view {"name": "demo"}
Hermes, control 0.0 Tools process, terminal; no skills in the prompt
Pi, skills 1.0 <available_skills> gives the staged SKILL.md; one read of it
Pi, control 0.0 No skills in the prompt; said it found no demo skill

Skills runs: gym eval run <dir>/skillsreal --agent <opencode_agent|hermes_agent|pi_agent> --sandbox opensandbox --model-type openai_model --model <model> --model-url <url> ++observability_enabled=true ++model_call_capture_dir=<dir>. Controls: the same command on <dir>/skillsctrl, the same task without
skills_dir and environment/skills/. No harness overrides.

Claude Code and Codex. Their task-skills code in this diff comes from #6293 (task skills for Claude Code and
Codex), which this PR stacks on; it is not changed here. The Claude Code/Codex task-skills PR (#6293) ran the same
demo task with the same hosted model on
OpenSandbox (Claude Code 2.1.292 through Gym's model server, Codex 0.144.4):

Case Reward Observed
Claude Code, skills 1.0 One call, Skill {"skill": "demo"}; answered pineapple
Claude Code, no skills 0.0 Searched with Bash; answered Abracadabra
Codex, skills 1.0 Read <CODEX_HOME>/skills/demo/SKILL.md from its skill listing; answered pineapple
Codex, no skills 0.0 Said the skill is not available
Two steps, each harness; step two's setup.sh moves /tmp/.nemo-gym away 1.0 per step Step two sees a rewritten task.json and uses the skill

Compatibility and benchmark impact

  • Scores of existing tasks are unchanged. A task without skills_dir runs as before, apart from one more seed exec.
  • On OpenCode and Hermes only the with-skill arm gets the skill tool, which brings more than the task's skills:
    OpenCode's built-in customize-opencode skill and any .claude/skills or .agents/skills folders between the
    working directory and the repository root (OpenCode README), and Hermes's skill_manage. The SkillsBench README
    names customize-opencode and skill_manage.
  • A missing skills folder or a ~/$ path now fails these harnesses' seed. No new configuration.

The rollouts above ran before the main update. After it, a combined branch of this PR with the other
SkillEvaluator-related PRs on main 51630ce4f ran SkillEvaluator's calculator, task-list and magic-mcp tasks: the
staged skill path appeared in 7 of 7 with-skill rows on each of OpenCode, Hermes and Pi (OpenCode called skill,
Hermes skill_view, Pi read SKILL.md), and the baseline rows' skills folders were empty.

Not tested: OpenCode 2 (left out, documented), multi-step tasks on these harnesses, skills with MCP servers on this
PR alone (covered only on the combined branch with the MCP PRs), a restore from a real checkpoint (unit tests only;
a Harbor episode starts over after a restore), a non-root [agent].user, the full core unit suite.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally (failures above are outside this change).
  • Documentation added or updated.
  • Pre-commit checks pass locally (on the touched files).
  • New source files include the required Apache-2.0 SPDX header (no new files).
  • All commits have DCO sign-off (git commit -s).

🤖 Generated with Claude Code

adil-a and others added 7 commits November 17, 2026 21:17
OpenCode 1 now declares supports_task_skills. At seed, in a task sandbox
the Environment Server lent, it copies the task's skills_dir into
<XDG_CONFIG_HOME>/opencode/skills, a skills folder OpenCode scans, and that
session's runs allow the skill tool with a last `skill: allow` rule. The
default permission profile keeps denying the tool for every other task.
OpenCode 2 discovers skills elsewhere and declares nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
Hermes now declares supports_task_skills. At seed, in a task sandbox the
Environment Server lent, it copies the task's skills_dir into
<HERMES_HOME>/skills, and that session's activation turns on Hermes'
skills toolset (a Harbor run keeps only `terminal`), so Hermes lists the
skills in its system prompt and the model loads one with skill_view.
Every other task keeps the configured toolsets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
Pi now declares supports_task_skills when its tools are on. At seed, in a
task sandbox the Environment Server lent, it copies the task's skills_dir
into <PI_CODING_AGENT_DIR>/skills and passes that folder with --skill;
discovery stays off (--no-skills), so Pi lists only the task's skills in
its system prompt and the model reads one with its read tool.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
…k skills

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
…mcp_grants row

The Harbor pairing page's `task_mcp_grants` row still said a skills_dir task
needs `supports_task_tool_context` or `supports_task_skills` "as Claude Code
and Codex do". OpenCode 1, Hermes and Pi now declare `supports_task_skills`
too, so the row names all five, as the Harbor server README already does.

The comments that state the same admission rule (the per-step task.json
rewrite in the Harbor server, two Harbor test docstrings) now speak of a
harness that declares `supports_task_skills` instead of naming two
harnesses, and the task_skills module docstring lists each harness's
configuration folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves hermes_agent/app.py: keeps this branch's _SKILLS_TOOLSET and main's
_OUTPUT_LIMIT_ERRORS (#6204), which are independent.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@copy-pr-bot

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

@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ce15858

@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP WITH CARE

RISK: Include Claude Code and Codex task-skills smoke evidence

The supplied real-model rollouts cover OpenCode, Hermes and Pi, but not Claude Code or Codex. This changeset also adds their task-skills admission paths: Claude Code stages skills and disables --bare, and Codex stages skills into its private home. Their new adapter tests use mocked sandbox copying and CLI execution, so they do not show either runtime advertising and loading the staged skill. This is a validation gap, not a confirmed runtime defect. The review rubric and repository quality bar require representative real-model rollouts for behavior-changing agent work.

Could you link matching evidence from the stacked task-skills PR, or supply one representative skills rollout for each harness? A minimal acceptance setup is a Harbor task declaring skills_dir = "/skills", a demo/SKILL.md containing a distinctive answer, and a verifier that checks that answer. Record the runtime version and revision, inspect captured model calls for native skill discovery and loading, and report the verifier result. Both runs should load demo and receive reward 1.0; successful copying alone does not validate this contract.

Keep the neighboring cases intact: without skills_dir, neither adapter should stage task skills, and Claude Code with bare: true should keep --bare. A declared empty skills folder must still count as declared, so Claude Code should drop --bare for that case. Retain those assertions in the Claude Code tests, the Codex no-skills and owned-sandbox tests, and the shared empty-folder test. These are proposed acceptance checks; I did not execute them. No implementation change is indicated unless the rollouts expose a failure.

I completed the broad static review of all changed files and their directly affected paths. I found no confirmed code defects. I could not run tests or independently verify the reported rollout results in this read-only environment.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. The Claude Code and Codex task-skills code in this diff is #6293's (this PR is stacked on it and does not change it), and #6293 has the real-model evidence you asked for: on the same demo task, Claude Code 2.1.292 called Skill {"skill": "demo"} and scored 1.0, Codex 0.144.4 read <CODEX_HOME>/skills/demo/SKILL.md from its skill listing and scored 1.0, both controls without skills_dir scored 0.0, and a two-step task where step two's setup.sh removes /tmp/.nemo-gym scored 1.0 per step for each harness. I added that table to this PR's description under Rollouts. The neighboring cases you list (no staging without skills_dir, bare: true kept otherwise, an empty declared folder still dropping --bare) are kept by the tests you linked.

@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

I completed the broad static review of all 40 changed files and their directly affected paths. No qualifying issues found.

I checked skills admission separately from MCP grants, traced staging into each harness's runtime configuration, and checked failed-seed cleanup. The per-step context rewrite runs after setup and before the next fresh session seeds. The changes keep the no-skills controls and declared-empty-folder behavior.

The updated description supplies the previously requested Claude Code and Codex smoke evidence from #6293, including native skill loading, rewards, no-skills controls and the two-step case. That addresses the prior validation request.

I did not execute tests or independently verify rollout artifacts. The reported validation was not rerun at the latest commit.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:agent Agent harnesses and Responses API agent behavior labels Nov 18, 2026
adil-a and others added 6 commits November 22, 2026 22:53
…ode, Hermes and Pi task-skills branch

The base branch now includes origin/main (51630ce), so this brings
main in: its Hermes v0.23.2 update, OpenCode checkpoint pauses and crash
resume, and Pi's activation refactor. Conflicts and how they were
resolved:

- hermes_agent/app.py: main moved payload building into
  _worker_payload(), which has no session state, so it takes a
  task_skills keyword that the sandbox episode passes from
  state.task_skills; this branch's skills-toolset block runs there. The
  _SKILLS_TOOLSET constant sits before main's reworded comment.
- hermes_agent/sandbox.py: main's runtime imports plus this branch's
  HERMES_HOME_FOLDER import.
- hermes_agent/tests: main's runtime asserts and glibc tests, and this
  branch's seed cwd list (["/", "/"]) and task-skills tests.
- opencode_agent/app.py: main moved runtime and plugin setup into
  _install_session_files(); this branch's stale copy of the old inline
  code is dropped and its task-skills staging follows that call.
- opencode_agent README and tests: both sides kept, main's first.
- pi_agent/app.py: main's _sandbox_payload() now builds the argv; the
  --skill folder goes in right after --no-skills there.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… host interpreter

Main's Hermes v0.23.2 update runs Hermes from its own host environment
(runtime.host_python()), not the Agent Server's venv, so the task-skills
test can no longer import Hermes with sys.executable.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ake a task's skills_dir

The Harbor task-folder paragraph of integrate-existing-agents.mdx still
named only Claude Code and Codex.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… restore

export_agent_sessions did not save task_skills and restore_agent_sessions
did not set it, so a session restored from a checkpoint had no task
skills: its next launch left the skill tool to the profile's rule, which
denies it, and the task's skills could not be used for the rest of the
episode. The checkpoint now carries task_skills (an older checkpoint
without it restores none, as before). When the re-bind finds the fork
without the session's files and installs them again, it copies the
task's skills into OpenCode's skills folder again as well.

Hermes and Pi join checkpoints as restart-only, so their episodes seed
again after a crash and stage the skills then; they have no restore path.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eckpointed folder

When a re-bind finds the fork without the session's files, it copied the
task's skills again by reading /tmp/.nemo-gym/task.json. That file is under
/tmp like the session's files, so a fork that lost them has usually lost it
too: stage_task_skills then returned None, the re-bind stored None in
task_skills, and the next launch denied the skill tool again.

stage_task_skills takes a keyword skills_dir that names the folder to copy
and skips the task.json read. The re-bind passes the folder the checkpoint
saved and no longer overwrites task_skills. The re-bind test now runs with
task.json kept and lost, and asserts the copy runs from the checkpointed
folder without reading task.json; two root tests cover the keyword.

Reach: only the harbor Environment Server writes task.json today, and it
runs restart_only (the default checkpoint_mode), so a Harbor episode is
seeded again after a restore and never takes this re-bind path. This fix
and the restore fix before it close the gap for an Environment Server that
checkpoints in exported mode; neither was hit in a real Harbor run.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…penCode, Hermes and Pi task-skills branch

The Claude Code and Codex task-skills branch now includes origin/main
(15adc22), so this brings that main as well. No conflicts.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adil-a

adil-a commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Updated with main at 15adc22542 through the Claude Code/Codex task-skills PR this one stacks on (#6293), and
fixed a checkpoint restore bug. New head e0755fc23e:

  • be5feec586 merges the updated task-skills head (0a7de79f59, which includes main at 51630ce4f2).
  • 4249940de5 fits a Hermes test to main's Hermes update.
  • fc26806dec lists OpenCode, Hermes and Pi in integrate-existing-agents.mdx, which still named only Claude Code and
    Codex.
  • 77cca30e95 and e07a2acd5e fix OpenCode task skills across a checkpoint restore (below).
  • e0755fc23e merges the task-skills head again (6406bf6a62, which includes main at 15adc22542); no conflicts.

Conflicts in be5feec586, from main's Hermes v0.23.2 update, OpenCode checkpoint pauses and crash resume, and
Pi's activation refactor:

  • hermes_agent/app.py: main moved payload building into _worker_payload(), which has no session state, so it
    takes a task_skills keyword that the sandbox episode passes from state.task_skills; this PR's skills-toolset
    block runs there. _SKILLS_TOOLSET sits before main's reworded comment.
  • hermes_agent/sandbox.py: main's runtime imports plus this PR's HERMES_HOME_FOLDER import.
  • hermes_agent/tests: main's runtime asserts and glibc tests, this PR's seed cwd list and task-skills tests.
  • opencode_agent/app.py: main moved runtime and plugin setup into _install_session_files(); this PR's stale copy
    of the old inline code is dropped and its task-skills staging follows that call.
  • opencode_agent README and tests: both sides kept.
  • pi_agent/app.py: main's _sandbox_payload() now builds the argv; --skill <folder> goes in right after
    --no-skills there.

Test fix (4249940de5): test_hermes_lists_and_loads_a_skill_staged_in_its_home ran Hermes with
sys.executable, but after main's Hermes update Hermes runs from its own host environment, not the Agent Server's
venv; the test now uses runtime.host_python(). The pinned source (ae2a81ccc00e) still has the skills toolset.
Without this commit, that test fails on the merged tree in a freshly built agent venv.

Bug fix (77cca30e95, e07a2acd5e): main added checkpoint export and restore for OpenCode sessions.
export_agent_sessions did not save task_skills and restore_agent_sessions did not set it, so a restored session
lost its task skills: its next launch left the skill tool to the profile's rule, which denies it, for the rest of the
episode. The checkpoint now carries task_skills (an older checkpoint without it restores none, as before). When the
re-bind finds the fork without the session's files and installs them again, it copies the skills again from the
folder the checkpoint names: stage_task_skills takes a skills_dir keyword that skips the task.json read.
task.json is under /tmp like the session's files, so such a fork has usually lost it too; reading it there, as
77cca30e95 did, stored None and brought the deny back. Hermes and Pi join checkpoints as restart-only: their
episodes seed again after a crash and stage the skills then, so they have no such gap.

Reach: the harbor Environment Server, the only one that writes task.json today, is restart-only too, so a Harbor
episode starts over after a restore and does not take this path yet; the fix matters for an Environment Server that
checkpoints in exported mode. No real run restored a session; the bug was found by reading the code and a unit repro.

Tests that fail without the fix: before 77cca30e95, its two new restore tests failed (OpenCode suite: 2 failed, 1161
passed). On 77cca30e95, the re-bind test, now run with task.json kept and lost, fails in both cases (kept: the
re-bind read task.json; lost: no copy ran and task_skills became None), and the two new root tests of the
skills_dir keyword fail (test_task_skills.py: 3 failed, 19 passed). All pass on the new head.

The merge resolutions are the ones the combined end-to-end branch used (all nine SkillEvaluator-related PRs on main
51630ce4f2), where the staged skill path appeared in 7 of 7 with-skill rows on each of OpenCode, Hermes and Pi.

Tests on the new head (gym env test serial; root tests -n 2; no env.yaml in the tree):

  • opencode_agent: 1164 passed, 25 skipped
  • hermes_agent: 416 passed, in a venv built fresh for the merged tree
  • pi_agent: 419 passed, 32 skipped
  • claude_code_agent: 304 passed
  • codex_agent: 635 passed, 9 skipped, 1 failed: test_close_confirms_cleanup_before_provider_cancellation read the child's children.json before the child had written it (an empty file, JSONDecodeError), a timing race in a test this PR does not touch; it passed 3 of 3 reruns on this head and 3 of 3 on main 15adc22542
  • environment_servers/harbor: 732 passed
  • root tests/unit_tests/agents: 856 passed, 5 failed; all 5 also fail on main 15adc22542 in a dev venv built from the same lock: 3 outcome-policy upload-evidence tests need cloudpickle and 2 sandbox_python archive-owner tests depend on the host's gid mapping

@adil-a

adil-a commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e0755fc

@adil-a

adil-a commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:high Autobot PR risk: high label Nov 23, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP WITH CARE

I found one RISK: staging preserves relative symlinks while moving the skills tree, so a readable skill can become unreadable even though seeding succeeds. See the inline finding.

I reviewed all 41 changed files and their affected consumers, including Harbor admission, failed-seed cleanup, runtime configuration and OpenCode checkpoint restoration. I compared against the reachable previous-review commit. That review had no outstanding findings; the description still supplies the requested real-model smoke evidence, which I did not independently reproduce.

CI: On e0755fc23ea5ebe63c38a49352433945d8543abf, I relied on the successful Unit tests / Test, Unit tests / Server suite and Lint check checks. The overall workflow is red because non-blocking conformance and compliance diagnostics failed. The conformance summary has matching failures on the admitted base; the compliance findings concern unchanged run() methods. Skipped jobs were not counted as passes.

Probes: I used Python 3.13.14 in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:main-offline, with imports bound to the admitted checkout:

  • staging_edges.py passed executable-helper, quoted-path, dotfile, missing-context, explicit-restore-path and failed-destination checks.
  • delegated-hermes-pi.py, opencode-skills-roundtrip.py and claude-codex-skills-seed.py passed their focused checks of session isolation, tool settings, checkpoint round-tripping, skill bytes and cleanup. Provider connections and runtime installation were mocked.
  • staging_symlink_admitted.py reproduced the inline defect: task loading accepted the input, the source SKILL.md was readable, staging succeeded, and the destination SKILL.md was unreadable. A dereferenced copy preserved its contents.

I did not rerun repository suites already covered by CI or execute the external agent CLIs locally.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_gym/agents/utils/task_skills.py Outdated
source, target = shlex.quote(declared), shlex.quote(destination)
copied = await sandbox.exec(
f"[ -d {source} ] || {{ echo 'not a folder in the sandbox' >&2; exit 2; }}; "
f"mkdir -p -- {target} && cp -R -- {source}/. {target}/",

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.

RISK — Preserve readable skill targets when relocating symlinks

cp -R preserves relative symlink text, but this helper moves the tree. For example, an image can provide /app/skills/demo/SKILL.md -> ../../shared.md with readable /app/shared.md. Harbor explicitly keeps image-provided skills (upload contract). After this copy, the link resolves relative to the session's configuration directory instead of /app, so the staged skill is unreadable while stage_task_skills returns success. This affects all five adapters using the helper, including OpenCode restaging after restore.

I reproduced this with PYTHONDONTWRITEBYTECODE=1 python /workspace/review-probes/staging_symlink_admitted.py: source readable True, staging success, destination readable False.

Could you materialize readable symlink targets during relocation, for example with cp -RL, rather than copying links whose meaning changes? Preserve quoting, executable modes, dotfiles and declared-empty-folder behavior. Add regression checks for a linked SKILL.md and a linked helper whose targets sit outside skills_dir: their staged contents should match the readable source, and dangling or unreadable targets should fail seeding rather than silently leave broken skills.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9a33cec1f9 on the Claude Code/Codex task-skills PR (#6293), merged here in 3d3c4162ef. The copy uses cp -RL, so a link is staged as its target's contents, and a dangling or unreadable link fails the copy and refuses the seed. Tests: test_symlinks_to_files_outside_the_folder_are_staged_as_their_readable_contents, test_a_symlink_whose_target_is_missing_is_refused_instead_of_staged_broken and test_a_symlink_whose_target_cannot_be_read_is_refused in tests/unit_tests/agents/test_task_skills.py.

…encode-hermes-pi

Brings in 9a33cec (fix(agents): follow symlinks when staging a task's skills) from the Claude Code/Codex
task-skills branch. task_skills.py keeps this branch's refactor (skills_dir keyword, _declared_skills_dir) with the
copy switched to cp -RL; the OpenCode, Hermes and Pi tests match the new command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the RISK in 3d3c4162e. The copy in stage_task_skills now follows symlinks (cp -RL), so a skill whose SKILL.md or helper links outside skills_dir is staged as the targets' readable contents with their modes, and a link whose target is missing or unreadable fails the copy and refuses the seed. The fix is 9a33cec1f9 on the Claude Code/Codex task-skills PR (#6293), where the helper comes from, merged here; this branch's refactor (skills_dir keyword) keeps the same command.

New tests in tests/unit_tests/agents/test_task_skills.py (a linked SKILL.md and a linked executable helper outside the folder, a dangling link, an unreadable target); all three fail with cp -R and pass now. Root task-skills tests 25 passed; skill tests on OpenCode 14, Hermes 11, Pi 6, Claude Code 14, Codex 67 passed. ruff clean.

…0698) into adasif/gym-1268-task-skills-opencode-hermes-pi

Conflicts with main, each resolved keeping both sides:
- opencode_agent/app.py: this branch's stage_task_skills import next to main's stop_and_confirm_cleanup import.
  The rest merged on its own: the checkpoint keeps this branch's task_skills and task_skills_pending next to
  main's keeps_processes, relay_gen and adoption fields, and a re-bind that installs the session files again
  still stages the skills again before main's restored-launch check.
- opencode_agent/tests/test_checkpoint.py: both new re-bind tests, this branch's skills re-staging test and main's
  test of a restored-launch check that did not finish.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Updated with main at 66a0698b3c through the PR this one stacks on: merged the updated Claude Code/Codex
task-skills head (#6293, b952949386, which merges main 66a0698b3c) into this branch. Merge commit 4f6f23ac9c,
now the head.

Conflicts, both from main's OpenCode resume in place on sandboxes whose snapshots keep processes:

  • opencode_agent/app.py, the nemo_gym.agents imports: this PR's stage_task_skills next to main's
    stop_and_confirm_cleanup. The rest of the file merged on its own: the checkpoint keeps this PR's task_skills and
    task_skills_pending next to main's keeps_processes, relay_gen and adoption fields, and a re-bind that has to
    install the session files again still stages the skills again, before main's check of a restored launch.
  • opencode_agent/tests/test_checkpoint.py: both sides added a re-bind test at the same place, this PR's skills
    re-staging test and main's test of a restored-launch check that did not finish. Both kept.

The trial merge of main alone also conflicted in nemo_gym/agents/__init__.py; through the updated
Claude Code/Codex task-skills head that file takes that PR's resolution, which this PR does not change.

Tests on the head (gym env test, serial; root tests -n 2; no env.yaml in the tree):

  • environment_servers/harbor: 752 passed
  • opencode_agent: 1268 passed, 28 skipped
  • hermes_agent: 435 passed
  • pi_agent: 438 passed, 38 skipped
  • root tests/unit_tests/agents: 936 passed, 26 skipped, 5 failed; the same 5 fail on main 66a0698b3c in the same
    venv: 3 outcome-policy upload-evidence tests need cloudpickle and 2 sandbox_python archive-owner tests depend on
    the host's gid mapping

@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4f6f23a

@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

LGTM. No concerns found. I reviewed all 29 changed files, affected callers and consumers, tests, documentation and prior feedback, with separate OpenCode, Hermes and Pi reviews.

The earlier symlink and OpenCode retry issues stay fixed. Focused probes confirmed that linked skill files remain readable after copying, failed restoration stays pending across retries and JSON checkpoint round-trips, and successful restoration avoids unnecessary copying. Permission and toolset changes stay scoped to the task session.

CI: I relied on successful head-associated Lint check, Unit tests / Test, Unit tests / Server suite, combined core coverage, all four core shards, all eight server shards, sandbox tests and LongMT scoring tests. Inspected job logs checked out merge commit 5d9abf82429a6bc1a9012f9a14410a10a7b2bbb5, which includes this head, rather than the standalone head. Changed-server and session-routing checks were skipped, not passed. Non-blocking conformance is red; its reported failures match the comparison run tested at 1dbc5847ca44b55897060fc6529b850651fd01ff. Compliance flags pre-existing Hermes and Pi run() methods.

Local execution: Using Python 3.13.14 in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:main-offline, with imports verified against the admitted checkout, all focused probes passed: shared staging, quoting and symlink handling; OpenCode fresh-seed and checkpoint/retry recovery; Hermes staging, cleanup, toolset isolation and runner forwarding; Pi capability, argument consistency, isolation and failed-seed cleanup. Initial dependency-import failures were resolved using packages already in the image.

Provider connections and runtime installation were mocked. Filesystem-copy probes executed real shell commands. I did not rerun CI-covered suites, execute external agent CLIs, reproduce model rollouts or restore a real remote checkpoint. The PR supplies representative model-rollout evidence from earlier revisions and states its validation limits.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

…ls branch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Merged the capabilities-reply fix from the Claude Code/Codex task-skills PR (#6293) below it: supports_task_skills is sent only when true, so an environment server that predates the field still reads the reply of a harness that stages no skills. Session tests 41 passed.

@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7a50d6d

@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

LGTM. No concerns found. I reviewed all 29 changed files, affected callers, tests and documentation, with separate OpenCode, Hermes and Pi reviews.

The earlier symlink and OpenCode retry fixes stay intact. Probes confirmed readable symlink targets after copying, pending restoration across failed retries and JSON checkpoint round-trips, and no unnecessary copying after successful recovery. Skill permissions, toolsets and private directories stay scoped to each session. Invalid declarations refuse seeding, while provider timeouts stay retryable.

CI: I relied on successful head-associated Lint check, Unit tests / Test, Unit tests / Server suite, all four core shards, all eight server shards, combined coverage, sandbox tests and LongMT scoring. Inspected job logs tested merge commit a35b1cab30faafa0293e4033ee1167d7bfdadb61, which includes this head, rather than the standalone head. Changed-server and session-routing checks were skipped, not passed. Non-blocking compliance and conformance are red: compliance flags pre-existing Hermes/Pi run() methods; OpenCode/Pi conformance diagnostics also occur on main, and the other reported failures or unavailable harnesses also appear in the previous review's run.

Local execution: Focused staging, capability-serialization, checkpoint-retry, payload, isolation and cleanup probes passed in Python 3.13.14 using 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:e27be8e644b414501fe6eb9b905386a07685a2f6, a successful default-branch CI image. Imports were verified against the admitted checkout. Copy and cleanup probes executed real shell commands; provider connections and runtime setup were mocked. I did not rerun CI-covered suites.

I did not execute external agent CLIs, model rollouts or a real remote checkpoint restore. The image lacked the external runtimes, so runtime discovery was not independently validated locally. The PR supplies representative rollout evidence from earlier revisions and states its validation limits.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

adil-a and others added 3 commits November 27, 2026 15:54
…kills branch

Brings in 0f55ba1: stage_task_skills makes its copy readable and
writable by its owner after the copy, and after a copy that failed part
way, so a session whose task ships its skills read-only to a non-root agent
user can still be closed.

task_skills.py keeps this branch's skills_dir keyword and
_declared_skills_dir, with the same copy command as the merged branch.
The OpenCode, Hermes and Pi tests that matched the end of the copy command
now match its destination before the permission fix-up that follows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
A re-bound OpenCode session copies its task's skills again over what the
fork kept, which can be the copy its seed made. Before the copy was made
owner-writable, a second copy of skills shipped read-only failed with
"Permission denied", so the re-bind kept failing. The test stages the same
read-only folder twice through skills_dir, then closes the session.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
A run as root reads and writes files whatever their modes, so the copy succeeding
does not show the second copy left its session owner access.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

I merged the read-only skills fix from the Claude Code/Codex task-skills PR (#6293, 0f55ba11f1) into this branch.
The merge commit is 22d04764ed. Two test commits follow it, and f8d4274a3e is now the head. The fix runs
chmod -R u+rwX on the staged copy, after the copy and after a copy that failed part way. A task can ship its skills
read-only to a non-root agent user, and the close can now still remove the session in that case.

Conflict in nemo_gym/agents/utils/task_skills.py. I kept this PR's skills_dir keyword and
_declared_skills_dir() and used the copy command from 0f55ba11f1: cp -RL, then chmod -R u+rwX on the
destination, then exit with cp's status. The new docstring paragraph merged without a conflict.

Copy-command matchers. These tests checked that the copy command ends with the destination:

  • OpenCode: test_sandbox_sessions.py, and two tests in test_checkpoint.py
  • Hermes: test_sandbox.py
  • Pi: test_sandbox.py

They now check for the destination followed by ;. The same change to the Codex test came in with the merge.

OpenCode's re-stage after a restore calls the same stage_task_skills(), so it gets the fix too. It also copies
over whatever the fork kept, which can be the copy the seed made. Before the fix, copying read-only skills a second
time failed with "Permission denied": cp cannot write into the 0555 folder or over the 0444 file it made the first
time. That re-bind kept failing as a result. 8cb11de02c adds
test_read_only_skills_copied_again_over_an_earlier_copy_are_staged. It stages the same read-only folder twice
through skills_dir and then closes the session. The test fails on 7a50d6d50c with that error and passes now. f8d4274a3e also has it check the modes of the second copy, because a test run as root writes over read-only files anyway. With the chmod left out, the test fails again.
Hermes and Pi copy only at seed, into a new folder.

The limit from the other PR applies here as well. Suppose a copy times out and the provider kills it before the chmod
runs. Read-only folders can then remain, and a retried re-bind over them would still fail.

Tests (no env.yaml in the tree, -n 2):

  • tests/unit_tests/agents/test_task_skills.py: 28 passed. The 3 read-only tests fail on 7a50d6d50c.
  • OpenCode, -k skill: 16 passed.
  • Hermes, -k skill, with uv on PATH: 11 passed.
  • Pi, -k skill: 6 passed.
  • The OpenCode, Hermes and Pi results are from 22d04764ed. The two test commits after it change only the core test file.
  • claude_code_agent/tests/test_sandbox.py with codex_agent/tests/test_sandbox_sessions.py: 439 passed, 1 failed.
    The failure is test_close_confirms_cleanup_before_provider_cancellation, in code this PR does not touch. The test
    reads children.json as soon as the file exists, which can be before the writer finishes, and then fails with
    JSONDecodeError. Run on its own 9 times, it passed 7 times and failed twice, both times with that error at that
    read.
  • Root tests/unit_tests/agents: 941 passed, 26 skipped, 5 failed. These are the same 5 failures as in the previous
    update:
    • 3 outcome-policy upload-evidence tests need cloudpickle, which this venv does not have.
    • 2 sandbox_python archive-owner tests depend on the host's gid mapping.
  • pre-commit run passes on the changed files.

@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f8d4274

@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP WITH CARE

One RISK: an interrupted read-only skills copy can turn OpenCode checkpoint recovery into a terminal seed refusal. No BLOCKERs found.

I reviewed all 29 changed files, affected callers, tests and documentation, with separate OpenCode, Hermes and Pi reviews. I also compared against the previous review at 7a50d6d50ca7507a9b1c976c6321a84ed0ba717d, which reported no findings.

CI: I relied on successful Lint check, Unit tests / Test, Unit tests / Server suite, all four core shards, all eight server shards, combined coverage, sandbox tests and LongMT scoring in run 46087474150. Inspected logs tested merge commit 364f399cdb29067689b4c64f5bce4cf2d6034228, which includes the admitted head, rather than the standalone head. Changed-server and session-routing checks were skipped, not passed. Non-blocking compliance and conformance checks are red: compliance flags existing run() methods, and the conformance diagnostics also appear on main at ba3eeeb0a60df9a7cd3bb9d2c1f36cabb0a493b5.

Local execution: Probes ran with Python 3.13.14 in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:e27be8e644b414501fe6eb9b905386a07685a2f6, a verified successful default-branch CI image; no head CI container was found. Shared staging, symlink, shell-quoting, capability, session-isolation, payload and cleanup probes passed. Ordinary checkpoint retries passed, but the non-root interrupted-copy probe reproduced the RISK below. I independently reproduced it and verified that a scratch-only pre-copy permission repair lets the first retry succeed. Imports resolved to the admitted checkout.

Provider connections and external agent runtimes were mocked where needed; copying, chmod, local provider timeout and cleanup used real shell execution. I did not rerun CI-covered suites, execute external agent CLIs, run model rollouts or perform a remote checkpoint restore. The PR supplies representative rollout evidence from earlier revisions and records its limits.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

# Copied again from the folder the checkpoint names. task.json is under /tmp too, so the fork has
# usually lost it, and reading it would leave the session without its skills. A copy that timed out
# may have copied only some of them, so only one that succeeds settles what is owed.
await stage_task_skills(sandbox, f"{root}/config/opencode/skills", skills_dir=state.task_skills)

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.

RISK: Repair leftover permissions before retrying the skills copy

This retry can reject a valid restored session with HTTP 422. If a timeout or cancellation kills an earlier copy after it creates a read-only skill but before the helper's trailing chmod, task_skills_pending stays true and this call copies into the same destination. Under a non-root user, cp cannot overwrite those leftovers. The helper then raises terminal AgentSeedRejectedError rather than recovering from the transient failure.

I reproduced this using the real local provider at UID 65532: a forced timeout before chmod left the copied directory/file at 0550/0440; the first retry returned cp: cannot create regular file .../demo/SKILL.md: Permission denied and HTTP 422. The integrated seed probe failed at this line too. This affects non-root OpenCode 1 exported-session recovery; the PR notes that current Harbor episodes restart on restore.

Could you make an existing session-owned destination owner-accessible before recopying, while keeping the post-copy repair in stage_task_skills? A scratch-only pre-copy repair made the first retry succeed. Keep the source unchanged, preserve executable scripts, and clear pending only after a successful copy.

Acceptance: as a non-root user, interrupt staging of 0555 directories and 0444 files before chmod, then retry the same restored seed, including after a JSON checkpoint round-trip. The first retry should succeed without 422, leave readable skills and removable session files, and preserve source modes. The existing read-only repeat test starts from a successful copy whose chmod already ran, so it misses this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed. The repair is in the shared helper on the Claude Code/Codex task-skills PR (#6293): c76735324d, with a test follow-up in 45c7a5d2ba. This branch takes both through the merges b07dad6534 and 0aee3074aa, the new head.

Change (nemo_gym/agents/utils/task_skills.py). The copy now makes an existing destination owner-accessible before cp runs, and still repairs the copy after it:

mkdir -p -- DEST && { chmod -R u+rwX -- DEST 2>/dev/null; cp -RL -- SRC/. DEST/; }; copy_status=$?; chmod -R u+rwX -- DEST 2>/dev/null; exit $copy_status
  • copy_status is still cp's status, or mkdir's if that fails. The chmods' own errors are dropped, so a refusal still reports the copy's message.
  • Both chmods change only the destination. The source keeps its modes, and X keeps scripts executable without making other files executable.
  • OpenCode's re-stage already clears task_skills_pending only after stage_task_skills returns, so a failed or interrupted copy keeps it set, through a checkpoint as well.

Tests

  • test_a_retry_copies_over_read_only_skills_an_interrupted_copy_left (core, real local shell): it puts the task's read-only skills (0555 folders, 0444 SKILL.md, 0555 script) in the destination with their modes, as a copy stopped before its chmod leaves them, with SKILL.md cut short. It then stages again. The copy succeeds, SKILL.md matches the task's again, every entry is owner-accessible, the script stays executable, SKILL.md does not become executable, the source modes do not change, and the close removes the session. Without the pre-copy chmod, it fails with the error from your report: cp: cannot create regular file .../demo/SKILL.md: Permission denied and a 422. It is meaningful when run as non-root, as here; a root run writes over read-only files anyway.
  • OpenCode's test_a_seed_retried_after_its_re_bind_failed_to_copy_the_task_skills_copies_them_again restores from a JSON checkpoint, fails the re-stage twice with a timeout, and then succeeds. It keeps task_skills_pending until then, and now also checks that every copy repairs the destination before cp.
  • The copy-command matchers in the Claude Code, Codex, OpenCode, Hermes and Pi tests now check the mkdir and the cp separately.

Results (-n 2, non-root):

  • tests/unit_tests/agents/test_task_skills.py: 29 passed.
  • OpenCode -k skill (test_checkpoint.py, test_sandbox_sessions.py): 16 passed.
  • Hermes -k skill: 11 passed. Pi -k skill: 6 passed.
  • On the Claude Code/Codex branch: Claude Code test_sandbox.py 72 passed, Codex test_sandbox_sessions.py 368 passed.
  • pre-commit run passes on the changed files.

adil-a and others added 2 commits November 27, 2026 16:59
…lls branch

The skills copy now makes an existing destination owner-writable before copying,
so OpenCode's re-stage after a copy that timed out can copy over read-only skills
that copy left. Resolves task_skills.py by keeping this branch's skills_dir keyword
and taking the new copy command. The OpenCode, Hermes and Pi copy-command matchers
now check the mkdir and the cp separately, and OpenCode's retried re-stage checks
that each copy repairs the destination first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
…k-skills branch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0aee307

@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP WITH CARE

One RISK: interrupted read-only skills staging can leave a borrowed Hermes session unable to finish cleanup. No BLOCKERs found.

I reviewed all 29 changed files, affected callers, tests and documentation, with separate OpenCode, Hermes and Pi/Harbor reviews. The previous OpenCode retry finding is fixed: a real non-root copy timeout reproduced the old 422 at f8d4274, while this head accepted the first retry. Integrated probes also passed across JSON checkpoints. The cleanup finding below concerns a different path, which closes without recopying.

CI: I relied on successful Lint check, Unit tests / Test, Unit tests / Server suite, all four core shards, all eight server shards, combined coverage, sandbox tests and LongMT scoring in run 46091743459. Inspected logs tested merge commit ceb518c99d5265c099fcc38c2148fbafca34f4de, which includes the admitted head. Changed-server and session-routing checks were skipped, not passed. Non-blocking compliance and conformance checks are red; compliance flags existing run() methods, and the failing mini-SWE conformance job reported no usable scenario results. I have not attributed every non-blocking failure.

Local execution: Probes used Python 3.13.14 in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:main-offline, derived from default-branch commit e27be8e; no successful head container build was found. Imports were verified against the admitted trees. Shared staging, symlink handling, shell quoting, OpenCode recovery, session isolation, Hermes toolsets, Pi arguments and Harbor admission probes passed. An actual local-provider timeout and a separate Hermes seed/close probe reproduced the cleanup RISK below.

Provider connections and external runtimes were mocked where needed; filesystem copying, permission changes and removal used real shell commands. I did not rerun CI-covered suites, execute external agent CLIs, reproduce model rollouts or perform a remote checkpoint restore. The PR supplies historical rollout evidence and records its limits.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

await state.install_runtime(install_timeout=self.config.sandbox_install_timeout_seconds)
if not owns_sandbox:
# A task sandbox seeded by an Environment Server names the task's skills in task.json.
state.task_skills = await stage_task_skills(sandbox, f"{state.hermes_home}/skills")

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.

RISK: Make interrupted skills staging cleanable without recopying

The new borrowed-sandbox staging can leave failed Hermes setup unable to release its session. If a timeout or cancellation stops the copy after creating read-only skill directories but before its trailing chmod, the exception path calls state.close(). Common removal renames the session to .closed, then plain rm -rf fails inside those directories as a non-root user. That raises before disconnect, and subsequent closes encounter the same leftovers. The pre-copy permission repair fixes recopy retries, but this path never recopies.

I reproduced this through actual Hermes seed/close with real shell copying: two closes returned Could not remove Hermes session files, with DISCONNECTS 0 and a leftover directory at 0550. Independently, python /workspace/review-probes/leader-head/interrupted_close.py reproduced the failure using a real LocalProvider timeout at UID 65532. Repairing only the scratch copy made the next close succeed. This retains private files and a failed session/client; it does not demonstrate that Harbor's independent sandbox teardown fails.

Could cleanup make its session-owned staged files removable independently of the interrupted copy shell, including the retired .closed path on retries? Keep the task source unchanged, preserve the original staging error and atomic retirement fence, and disconnect rather than stop the borrowed sandbox.

Acceptance: as non-root, interrupt staging of 0555 directories containing 0444 files before the final permission repair. Exercise seed-failure cleanup and repeated close. Verify private files are removed, disconnect succeeds, source modes stay unchanged and no closing failed-seed record is left behind.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed. The fix is in the shared close on the Claude Code/Codex task-skills PR (#6293): 62b22fc43a, with a symlink guard in 8d55720755. This branch takes both through the merges 39012d8588 and 7675a7d1b0, the new head.

Change (remove_session_directory in nemo_gym/agents/utils/supervisor_client.py). The close still retires the session folder with mv before removing it, so the fence is unchanged. If rm -rf on the retired folder fails, the close now makes that folder owner-writable and removes it once more:

if [ -d DIR ]; then mv DIR DIR.closed || exit 1; fi; rm -rf -- DIR.closed 2>/dev/null || { [ -L DIR.closed ] || chmod -R u+rwX -- DIR.closed 2>/dev/null; rm -rf -- DIR.closed; }
  • This runs on every close, so it also clears a .closed folder that an earlier close failed to remove. Hermes' seed failure path calls state.close(), which calls this through SandboxSession.close(). That removes the session's files and then disconnects from the borrowed sandbox without stopping it.
  • The chmod runs only when the first removal fails, so a normal close does no extra work. It changes only the retired folder, never the task's skills folder. If the retired path is a symlink that could not be unlinked, the chmod is skipped, because GNU chmod -R follows a symlink named on its command line. If the second removal fails too, the command still exits non-zero, so the close raises and keeps the retired folder for a retry, as before.
  • The seed's own error is unchanged: when the close succeeds, the original staging error is raised.

Tests (real local shell, run as non-root):

  • test_removal_makes_folders_its_owner_cannot_write_removable[seed] (tests/unit_tests/agents/test_sandbox_supervisor_client.py): a session folder holding a 0555 skill folder with a 0444 SKILL.md and a 0555 subfolder is removed.
  • test_removal_makes_folders_its_owner_cannot_write_removable[earlier close]: the same files already under .closed, as a failed close leaves them, are removed by the next close.
  • test_a_session_whose_skills_copy_was_stopped_before_its_repair_still_closes (tests/unit_tests/agents/test_task_skills.py): the task's read-only skills sit in the session with their modes, as a copy stopped before its chmod leaves them. A borrowed, seeded session closes with no copy in between. The session folder and .closed are gone, disconnect is awaited once, stop is not awaited, and the source modes do not change.
  • Without the change, all three fail with RuntimeError: Could not remove test session files.
  • test_removal_does_not_make_writable_what_a_retired_symlink_points_to: a .closed symlink to a read-only folder outside the session, in a folder where the link cannot be unlinked. The close raises, and the target's modes stay 0555/0444. Without the guard, the target becomes 0755.

Results (-n 2):

  • test_task_skills.py, test_sandbox_supervisor_client.py and test_sandbox_session.py: 173 passed at the head.
  • Hermes test_sandbox.py: 244 passed. Pi test_sandbox.py: 304 passed, 10 skipped.
  • OpenCode test_sandbox_sessions.py and test_checkpoint.py: 376 passed.
  • On the Claude Code/Codex branch: tests/unit_tests/agents 941 passed, with the same 5 environment-only failures as before (3 need cloudpickle, 2 depend on the host's gid mapping). Claude Code test_sandbox.py 72 passed, Codex test_sandbox_sessions.py 368 passed.
  • pre-commit run passes on the changed files.

adil-a and others added 2 commits November 27, 2026 17:46
…e/Codex task-skills branch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
…s branch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7675a7d

@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

…/Codex task-skills branch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ff47b2b

@adil-a

adil-a commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

LGTM. No BLOCKER, RISK or NOTE found.

I reviewed all 29 changed files, affected callers, tests and documentation, with separate OpenCode, Hermes and Pi reviews. This was a full RESET review.

Previous finding: The interrupted-copy cleanup RISK from review 6094914273 is fixed. A non-root probe reproduced failed cleanup at 0aee3074aa364c03968a1e5771fb1a4c0c9f674e. At this head, the same timed-out copy followed by repeated close removed both fresh and already-retired session directories, disconnected without stopping the borrowed sandbox, and kept source permissions unchanged. The retired-symlink guard also kept outside permissions unchanged. A public Hermes seed-failure probe confirmed that the original timeout survives cleanup without leaving failed session state.

CI: I relied on successful Lint check, Nemo_CICD_Test, Unit tests / Test, Unit tests / Server suite, all four core shards, all eight server shards, combined coverage, sandbox tests and LongMT scoring. The test results are in run 46096699230; inspected logs tested merge commit c75caf1c5ffc854416786bcb03a516d6c341cae8, which includes the admitted head. Changed-server and session-routing checks were skipped, not passed.

Non-blocking compliance and conformance checks are red. Compliance flags pre-existing run() methods. OpenCode and Pi compaction diagnostics also appear on the default branch. The mini-SWE conformance step timed out after its tests and produced no usable scenario results. I have not attributed every non-blocking failure; these checks do not feed Nemo_CICD_Test.

Local execution: Probes ran with Python 3.13.14 in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:ba3eeeb0a60df9a7cd3bb9d2c1f36cabb0a493b5, the successful default-branch CI image because this head's container build was skipped. Imports were verified against the admitted source. Final probes passed for shared staging and error classification, real filesystem copying and cleanup, Harbor admission, OpenCode checkpoint retries and continuation, Hermes toolset isolation, and Pi worker arguments and replay. I did not rerun passing CI suites.

External agent runtimes, model calls and remote provider operations were mocked where needed. I did not reproduce external CLI discovery, model rollouts or a remote checkpoint restore. The PR supplies historical rollout evidence and states its limits.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

This branch has not been deployed

No deployments
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 needs-review PR is ready for code review and waiting on a reviewer risk:high Autobot PR risk: high sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants