8000 Refactor 2/4: task directories in Harbor's format, their own verifier, the bwrap backend; OfficeQA as task directories by haizhongzheng · Pull Request #113 · Infini-AI-Lab/hermit · GitHub
[go: up one dir, main page]

Skip to content

Refactor 2/4: task directories in Harbor's format, their own verifier, the bwrap backend; OfficeQA as task directories - #113

Merged
haizhongzheng merged 11 commits into
task-environment-refactorfrom
task-env/pr2-bwrap-tasks
Nov 19, 2026
Merged

haizhongzheng merged 11 commits into
task-environment-refactorfrom
task-env/pr2-bwrap-tasks

Conversation

@haizhongzheng
@haizhongzheng haizhongzheng commented Nov 19, 2026 •
Copy link
Copy Markdown
Member

Change

The second of four stacked PRs (design doc "Hermit agent 与 benchmark 重构设计", 第二阶段); based on #112, into
task-environment-refactor once #112 is merged there. A task set may now be a directory of task directories in
Harbor's format, run on Hermit's own sandbox: Harbor's task format without Harbor's runtime (the design's B class).

  • hermit/task/directory.py: Harbor's task format, read without Harbor (moved from hermit/harbor/dataset.py,
    which imports it). A task's instruction (line endings kept), settings and metadata are its public half; its directory
    and tests are private. Benchmark loads data.tasks: <directory>, with data.rollouts: k.
  • hermit/task/verify.py script: a task's own tests/test.sh, run in the judge's sandbox as Harbor runs it:
    /tests, a fresh /logs/verifier, reward.txt or reward.json, plus Hermit's feedback.txt for learning methods
    (judge: {path: hermit.task.verify, name: script, mode: shared | separate}). A task whose task.toml asks for a
    separate verifier is refused under mode: shared.
  • hermit/environment/spec.py, bwrap.py: EnvironmentSpec (the run config's environment section) and the
    bubblewrap backend the task sandbox is built by (the same sandbox as before, moved out 8000 of hermit/isolate.py). A task
    asking for more network or memory than the run's environment gives is refused, never run with less.
  • data.view: <file.py>:<function>: a directory task's row as the row the task set's agents and learners read. What
    a task asks of its environment (network per phase, allowlist hosts, memory, its agent's timeout, its verifier's
    memory) is its private needs, which the run checks and hands the sandboxed agent before each call, viewed or not.
  • As Harbor reads a task: a step's verifier mode and environment (verifier_mode.py), verifier timeout_sec
    default 600, [verifier.env] with ${VAR} templates, reward.json booleans, finite rewards only. A multi-step task
    is refused on this path (its steps share one environment in order; PR 4).
  • OfficeQA (examples/officeqa/utils/benchmark/): its task set is task directories now, beside its prepare.py,
    judge.py, task-info/, splits, data.json and seed adapter; every config views each task as SkillOpt's row
    (utils/agent/officeqa_fields.py:officeqa_task), so prompts, records and what each learning method reads are
    unchanged. Every OfficeQA method (GEPA, SkillOpt, ACE, OPRO, AHE, RRSI, Harness², ReHarness, ...) on the new paths.

Not in this PR: the Harbor environment backend and agents running in it (PR 3); the remaining benchmarks, LIBERO
among them (PR 4; ASPIRE's engine, shared with Robosuite, reads task rows in its simulator service and judge).

Validation

Linux (RHEL 9, x86_64), bubblewrap, non-root.

  • OfficeQA conversion, real data (246 questions from the CSV): every task directory reads back as exactly the old
    tasks.jsonl row (246/246, key order too; 11 questions hold \r\n, kept). Splits, answers and seed adapter
    identical. New test: examples/officeqa/utils/tests/test_task_directories.py.
  • OfficeQA real eval (gepa/smoke.yaml, seed skill, 4 test questions × 3, GLM 5.3 Flash, bubblewrap), with the
    view: 0 errors, 3/12 (PR 1's run of the old layout: 2/12; sampling). The system and user prompts each task's agent
    sent are byte-identical between the two runs (4/4); Benchmark.from_config gives every task exactly its old row
    (246/246, key order too). RRSI's generated rows are byte-identical to the old layout's.
  • Task directories end to end under real bubblewrap (tests/core/test_task_directory.py, 12 tests): the script
    verifier scores right 1 and wrong 0, reads feedback.txt, finds the agent's workspace without being told; the agent
    sees neither /tests nor _private; a separate-verifier task under mode: shared is a judge error.
  • Tests: pytest --changed --base origin/main on the final head ce800dca, in a clean worktree with the prepared
    OfficeQA data: 2075 passed, 118 skipped, 0 failed. CI: pass.
  • Docs (docs/build.sh, warnings as errors): clean. Lint (changed lines): clean.

Users of OfficeQA re-run utils/benchmark/prepare.py (CHANGELOG, Breaking).

Review

  • Tests and documentation cover the affected behavior: docs/framework/task.md (Task directories),
    docs/recipes/officeqa.md, examples/officeqa/README.md, CHANGELOG.md.
  • Commands, defaults, and public interfaces are consistent (data.rollouts in hermit/defaults.yaml).
  • Agents follow the agent layers; tasks and environments import no agent (test_layers).
  • Shared logs and examples contain no credentials or private data (no prepared data committed).
  • Independent review (/dual-review, this session and Codex gpt-6.1-sol, 5 rounds; 32 findings, all fixed or
    resolved): round 1, 17 (OfficeQA methods the move missed: ReHarness, RRSI, AHE, Harness², OPRO; step verifier
    settings, [verifier.env], reward.json booleans, task agent timeouts, the judge's deadline, allowlist hosts and the
    verifier's network); round 2, 7 (learners reading directory rows -> data.view; Harbor's verifier defaults, phase
    allowlists, wildcards); round 3, 5 (step verifier resolution, tests overlay, a view keeping the timeout, finite
    rewards); round 4, 3 (multi-step refused, the verifier's default workspace, its memory); round 5, none.

🤖 Generated with Claude Code

haizhongzheng and others added 8 commits November 19, 2026 11:53
…ment, hermit/common

The first of four stacked changes toward Harbor-format tasks run by Hermit's own
agents (design: "Hermit agent 与 benchmark 重构设计", 第二阶段). Structure only:
no behavior changes, the requests every agent sends are byte for byte main's.

- hermit/environment/: the environments move out of hermit/agent/ to the top
  level, since a task declares what it needs of one and a judge may run in one;
  hermit.agent.environment forwards for one release.
- hermit/task/: task.py becomes a package. Task holds a public half (what the
  acting agent is handed, what a run records as its input) and a private half
  only the judge reads; Benchmark is a task set and its splits; verify.py wraps a
  judge as a verifier of a Task. Every name importable from hermit.task before
  still is.
- hermit/common.py: RunOutput and load_callable, shared by agents and tasks so
  that neither imports the other.
- The run (hermit/trainer/rollout.py) hands the agent task.given() and the
  verifier the whole task; the trainer, eval and hermit check read a Benchmark.
  The validation file the learner gets holds each task's public half.
- tests/core/test_layers.py: tasks and agents never import each other; the
  environments import neither. tests/core/test_task.py covers the new types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the row's id

- judge_verifier calls the judge with Task.row() (the public half and `_private`), as
  run_one did before tasks were typed; the agent still gets only the public half.
- Records keep the row's own id (7, not "7"); run_tasks keys its results by task.
- run_one/run_tasks keep the `judge` parameter name; the Verifier protocol states
  `takes_task`; agent-layers.md shows hermit/environment/ beside hermit/agent/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… row's id)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ckend; OfficeQA as task directories

The second of four stacked changes (design: 第二阶段). A task set may now be a
directory of task directories in Harbor's format, run on Hermit's own sandbox
(B-class: Harbor's format, not Harbor's runtime).

- hermit/task/directory.py: Harbor's task format read without Harbor (moved from
  hermit/harbor/dataset.py, which imports it): the instruction (line endings
  kept), settings and metadata public; the task's directory and tests private.
  Benchmark loads `data.tasks: <directory>` (`data.rollouts: k`).
- hermit/task/verify.py: a task's own verifier, `judge: {path:
  hermit.task.verify, name: script}`, run in the judge's sandbox as Harbor runs
  it: tests at /tests, a fresh /logs/verifier, reward.txt or reward.json, and
  feedback.txt for learning methods. A judge is called with Task.row() (the row
  plus `_private`); an agent still gets only the public half.
- hermit/environment/spec.py and bwrap.py: EnvironmentSpec (the run config's
  `environment` section) and the bubblewrap backend the task sandbox is built
  by; a task asking for more network or memory than the run gives is refused.
- examples/officeqa: the task set moves to utils/benchmark/ (prepare.py writes
  task directories; judge.py, task-info/, splits, data.json, seed adapter); the
  agents read each task as the row they always read (officeqa_fields.py), so the
  prompts are byte for byte the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s as Harbor reads them

OfficeQA (the methods the move missed): ReHarness's launcher tests the tasks
directory; RRSI's rows (byte-identical to before on the real data) and AHE's come
from the task directories through officeqa_fields.question_rows; RRSI and AHE
score with utils/benchmark/judge.py; Harness²'s source hook reads a directory
row; OPRO shows the instruction; utils/.gitignore keeps the old paths ignored;
AHE's real-data tests find the prepared data again.

Task directories: a step's [verifier] settings come before the task's;
[verifier.env] is set for the script (${NAME} resolved as Harbor does);
reward.json takes a boolean as Harbor does; a task's [agent] timeout_sec bounds
its calls and the judge waits at least the verifier's timeout_sec; an allowlist
task's hosts and (with the script verifier) its verifier's network are checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…task-env/pr2-bwrap-tasks

# Conflicts:
#	CHANGELOG.md
#	hermit/task/benchmark.py
#	hermit/task/verify.py
@haizhongzheng
haizhongzheng changed the base branch from task-env/pr1-structure to task-environment-refactor November 19, 2026 18:04
haizhongzheng and others added 2 commits November 19, 2026 13:21
…rbor's verifier defaults and allowlists

- data.view: <file.py>:<function> turns a task directory's row into the row the
  task set's agents and learners read. OfficeQA's configs view each task as
  SkillOpt's row, so records and what a learning method reads (GEPA, ACE, OPRO,
  SkillOpt) are the same as with its tasks.jsonl (246/246 on the real data);
  OPRO's question_field is `question` again.
- What a task asks of its environment is kept in its private half (`needs`) and
  checked before each call (hermit.trainer.rollout asks a sandboxed agent's
  `refuses`), viewed or not.
- As Harbor: a verifier's timeout_sec defaults to 600; [verifier.environment]
  implies a separate verifier; each phase's allowlist (a step's first) is its own;
  wildcard hosts are refused under an allowlist run (the proxy matches hosts as
  written).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k keeps its timeout; finite rewards

- A step's verifier mode and environment are resolved as Harbor's
  verifier_mode.py does (explicit mode, else an environment implies separate,
  the step's level before the task's, else shared), and the verifier's network
  and allowlist come from that effective environment.
- A step's tests/ are laid over the task's in the judge's sandbox (its test.sh
  first), as Harbor uploads them.
- A task's agent timeout is kept in its needs, which the run hands the sandboxed
  agent, so a data.view that leaves it out of the row still bounds the call.
- reward.txt must hold a finite number, as in Harbor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… workspace and memory

- A multi-step task directory is refused here (its steps share one environment in
  order, which a per-call sandbox does not give); PR 4 brings that.
- The script verifier's workspace defaults to the directory the agent worked in,
  when its output names none.
- A separate verifier's own memory_mb is checked against the run's limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@haizhongzheng
haizhongzheng merged commit 52843e3 into task-environment-refactor Nov 19, 2026
1 check passed
@haizhongzheng
haizhongzheng deleted the task-env/pr2-bwrap-tasks branch November 20, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0