8000 Refactor 1/4: hermit/task and hermit/environment beside the agents (structure only) by haizhongzheng · Pull Request #112 · Infini-AI-Lab/hermit · GitHub
[go: up one dir, main page]

Skip to content

Refactor 1/4: hermit/task and hermit/environment beside the agents (structure only) - #112

Merged
haizhongzheng merged 5 commits into
task-environment-refactorfrom
task-env/pr1-structure
Nov 19, 2026
Merged

haizhongzheng merged 5 commits into
task-environment-refactorfrom
task-env/pr1-structure

Conversation

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

Change

The first of four stacked PRs into task-environment-refactor (design doc "Hermit agent 与 benchmark 重构设计",
section 第二阶段): Harbor gives the data, the environments and the verifiers; Hermit runs every agent. This PR is
structure only and changes no behavior.

  • hermit/environment/ moves out of hermit/agent/ to the top level: a task declares what it needs of an
    environment and a judge may run in one, so it belongs to no layer of the agents. hermit.agent.environment
    forwards for one release (hermit._moved).
  • hermit/task/: hermit/task.py becomes a package.
    • Task: a public half (what the acting agent is handed, what a run records as its input) and a private half only
      the judge reads. A row of tasks.jsonl is all public, so nothing changes for existing task sets.
    • Benchmark: a task set and its splits (replaces the trainer's, eval's and hermit check's TaskData).
    • verify.py: a judge wrapped 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
    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.

Core changes: hermit/environment/ (moved), hermit/task/ (new package from task.py), hermit/common.py,
hermit/trainer/{rollout,trainer}.py, hermit/evaluate.py, hermit/settings_check.py, the acting agents' imports.

Not in this PR (the next three): the bwrap backend and task directories with their own verifier (PR 2), the
Harbor environment backend and agents running in it (PR 3), the remaining benchmarks (PR 4).

Validation

Linux (RHEL 9, x86_64), bubblewrap, non-root, against task-environment-refactor (= main at 127a1f81).

  • Requests unchanged: the parity script (stand-in models at the edge: ReAct, Direct, Codex, Claude Code, Codex in
    the bubblewrap sandbox) records byte-for-byte the same requests as main.
  • Tests: pytest --changed --base origin/main in a venv with CI's optional groups, on the final head 0d5f61f3:
    2063 passed, 118 skipped, 0 failed. New: tests/core/test_task.py (7),
    test_training.py::test_eval_scores_a_task_set_with_numeric_ids (fails without its fix). CI: pass.
  • Lint: ruff E9/F/E501 at 120 on changed lines: clean. Docs: docs/build.sh (warnings as errors): clean.
  • Real run: OfficeQA smoke eval (gepa/smoke.yaml, seed skill, 4 test questions × 3, GLM 5.3 Flash, bubblewrap):
    0 errors, mean 0.17 (2/12), the same range as main.

Review

  • Tests and documentation cover the affected behavior: docs/framework/task.md, docs/developer/index.md,
    docs/framework/agent-layers.md, CHANGELOG.md.
  • 10000
  • Commands, defaults, and public interfaces are consistent: old import paths keep working.
  • Agents follow the agent layers; tasks and agents are independent (test_layers).
  • Shared logs and examples contain no credentials or private data.
  • Independent review (/dual-review, this session and Codex gpt-6.1-sol, 3 rounds): round 1 found 5 (all fixed:
    a bare judge reads _private again, records keep a row's own id, the judge parameter name, the Verifier
    protocol's takes_task, a stale docs tree); round 2 found 1, from a round-1 fix (eval with numeric ids; fixed,
    test added); round 3 none. Left: test_layers does not see relative imports (minor); numeric-id training records
    never match the split ids for their logs (the same on main).

🤖 Generated with Claude Code

haizhongzheng and others added 5 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>
@haizhongzheng
haizhongzheng merged commit 7e21755 into task-environment-refactor Nov 19, 2026
1 check passed
haizhongzheng added a commit that referenced this pull request Nov 20, 2026
Task/environment refactor: task directories, Harbor as environments, every agent Hermit's (#112-#116)
@haizhongzheng
haizhongzheng deleted the task-env/pr1-structure branch November 20, 2026 15:01
iamziyuzhao added a commit to mmjzmy/hermit that referenced this pull request Nov 24, 2026
main moved hermit/task.py into the hermit/task package and replaced the
Harbor runner (agent.name: harbor, hermit/harbor/runner.py, harborside)
with Hermit's own agents in each task's HarborEnvironment (Infini-AI-Lab#112-Infini-AI-Lab#126).

Conflicts in hermit/task, the rollout, the Trainer and tests/selection.py
are resolved to main's side: they were the RunUnavailable plumbing, which
the next commits drop in favour of main's infra handling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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