8000 One agent abstraction: environments, Direct in Layer 1, ReAct hooks, supports and needs by haizhongzheng · Pull Request #111 · Infini-AI-Lab/hermit · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .agents/skills/prepare-pr/references/general-pr-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Answer each item in the PR with links to supporting files or records.

- [ ] **Core changes.** Does the pull request change shared or core code? If so,
what changes, and why are they needed?
- [ ] **Agent layers.** Does every agent the change adds or changes follow
[the agent layers](../../../../docs/framework/agent-layers.md)? Model calls go through Layer 1 (a client, or
`Direct` for one call); where an agent runs is the call's environment (`Local`, `Sandboxed`, `Container`), never
a setting; a benchmark's own agent is a subclass of a core agent in its example folder (a `ReactAgent` with
`@tool` methods and hooks), never a copy of a loop; a different prompt or model is configuration, not a new
agent; an agent declares what it takes of an adapter (`supports`) and a method what it needs (`needs`).
- [ ] **Implementation correctness and failures.** Trace affected execution paths,
including configuration propagation, errors, timeouts and cancellation where
relevant. Verify that failed or incomplete execution is reported accurately
Expand Down
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ Provide outcomes and supporting evidence; reference answers already in Change or

- [ ] Tests and documentation cover the affected behavior, where applicable.
- [ ] Commands, defaults, and public interfaces are consistent.
- [ ] Agents follow the [agent layers](../docs/framework/agent-layers.md): model calls through Layer 1, where an agent
runs is its environment, a benchmark's own agent subclasses a core agent in its example folder.
- [ ] Shared logs and examples contain no credentials or private data.
- [ ] Documentation-only: links the issue where it was discussed with the core team.
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ python -m pytest --changed # the test groups this branch touches (tests/READM
- Inspect the relevant implementation, callers and tests to understand current
behavior. Agents follow [Model → Base Agent → Acting / Evolver Agent](docs/framework/agent-layers.md):
reuse shared model and CLI execution through Base Agents; keep task-specific
logic in `examples/`.
logic in `examples/`. Where an agent runs is the environment its call gives (`hermit.agent.environment`), never
a setting; a benchmark's own agent subclasses a core agent (a `ReactAgent` with `@tool` methods and hooks) in its
example folder instead of copying a loop; a different prompt or model is configuration, not a new agent.
- For method reproductions, read the [reproduction guide](docs/developer/reproducing-a-method.md)
and [reproduce-method skill](.agents/skills/reproduce-method/SKILL.md).
- Before submitting or updating a PR, follow [prepare-pr](.agents/skills/prepare-pr/SKILL.md)
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ Changes are grouped by software version. Entries under Unreleased describe work

### Breaking

- One agent abstraction (#111, [agent layers](docs/framework/agent-layers.md#from-the-one-agent-refactor)): where an
agent works is an environment given with each call. `BaseAgent.run(prompt, environment=..., tools=, session=,
roles=)` replaces `run(prompt, workspace=, limits=)` (a path is a `Local` environment), and a CLI Base Agent
refuses `isolation`, `sandbox` or `container` given as settings (use `Sandboxed(path, sandbox=...)` or
`Container(path, settings=...)`). A single model call is Layer 1: `Direct(settings, model)` in
`hermit.agent.model.direct` returns a `Reply`, and `make("direct")` is refused. `hermit.agent.base.direct` and
`hermit.agent.base.container` (now `hermit.agent.environment.docker`) forward for one release. A run whose acting
agent does not take what its method needs of an adapter (`supports` against `evolver.yaml` `needs`) is refused
before it starts.

- One sandbox design replaces every earlier sandbox mode ([design](docs/developer/sandbox-design.md)); no old
configuration keeps working, and an old key fails with where it went:

Expand Down
6 changes: 3 additions & 3 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ before the offline runs; running it again re-syncs the clbench venv, so not whil
hermit runs every agent, learner and adapter tool in a bubblewrap sandbox of its own (`hermit/sandbox.py`): user,
mount, PID and network namespaces, a fresh `/proc` and `/dev`, a positive allowlist of paths. Docker allows an
unprivileged process to make namespaces only with `--cap-add SYS_ADMIN`, `--security-opt seccomp=unconfined` and
`--security-opt apparmor=unconfined`, the list of `hermit/agent/base/container.py`, which runs Codex's bubblewrap the same way. One
`--security-opt apparmor=unconfined`, the list of `hermit/agent/environment/docker.py`, which runs Codex's bubblewrap the same way. One
more is needed for hermit's `--proc /proc`: `--security-opt systempaths=unconfined` lifts the masks Docker lays over
`/proc` (`/proc/kcore`, `/proc/keys`, ...), without which a fresh `/proc` cannot be mounted in a namespace
(`bwrap: Can't mount proc on /newroot/proc: Operation not permitted`); `container.py` gives it to Claude Code's
(`bwrap: Can't mount proc on /newroot/proc: Operation not permitted`); `docker.py` gives it to Claude Code's
containers too, whose own sandbox mounts one. The container's user is unprivileged, so what
the masks hid stays root's (`/proc/kcore` is mode 0400, `/proc/sys` is read-only to it). `NET_RAW`, `MKNOD` and
`AUDIT_WRITE` are dropped as `hermit/agent/base/container.py` drops them, and `label=disable` keeps an SELinux host from refusing
`AUDIT_WRITE` are dropped as `hermit/agent/environment/docker.py` drops them, and `label=disable` keeps an SELinux host from refusing
the bind mounts. The containers are not privileged, have no Docker socket and are not on the host network.
`prepare` gets none of the sandbox additions.

Expand Down
10 changes: 5 additions & 5 deletions docs/_includes/agent-layers-interactive.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<span>Follow a path:</span>
<button type="button" data-path="all" aria-pressed="true">All</button>
<button type="button" data-path="officeqa" aria-pressed="false">Acting · OfficeQA × Codex</button>
<button type="button" data-path="clbench" aria-pressed="false">Acting · CL-Bench × direct</button>
<button type="button" data-path="gepa" aria-pressed="false">Learning · GEPA × direct</button>
<button type="button" data-path="clbench" aria-pressed="false">Acting · CL-Bench × Direct</button>
<button type="button" data-path="gepa" aria-pressed="false">Learning · GEPA × Direct</button>
<button type="button" data-path="mha" aria-pressed="false">Learning · Meta-Harness Adapter × Codex</button>
<button type="button" data-path="harness2" aria-pressed="false">Learning · Harness² × Claude Code</button>
</div>
Expand All @@ -16,11 +16,10 @@
<div class="ha-layers-cell" data-on="gepa mha harness2"><b>Evolver Agent</b><small>Learns: reads the acting runs' trajectories and writes a new adapter. GEPA, SkillOpt, Meta-Harness Adapter, Harness² and the other methods.</small></div>
</div>
</div>
<div class="ha-layers-seam"><div class="ha-layers-line" aria-hidden="true"></div><div><code class="ha-layers-api">run(prompt, workspace, tools, limits, session, roles) → reply + trajectory + usage + session</code><span>The Base Agent's one API. The caller cannot tell which Base Agent is below; passing the session back continues the same agent.</span></div></div>
<div class="ha-layers-seam"><div class="ha-layers-line" aria-hidden="true"></div><div><code class="ha-layers-api">run(prompt, environment, tools, session, roles) → reply + trajectory + usage + session</code><span>The Base Agent's one API. The caller cannot tell which Base Agent is below; passing the session back continues the same agent.</span></div></div>
<div class="ha-layers-band ha-layers-l2" aria-label="Layer 2: Base Agent">
<div class="ha-layers-head"><strong>Layer 2 · Base Agent</strong><span>How a model takes steps; only the framework's agents · <code>hermit/agent/base/</code></span></div>
<div class="ha-layers-cells">
<div class="ha-layers-cell" data-on="clbench gepa"><b>direct</b><small>One model call. Tools in the request come back as tool calls; direct never runs them.</small></div>
<div class="ha-layers-cell"><b>react</b><small>The framework's tool loop: call the model, run the tools it asks for, call it again.</small></div>
<div class="ha-layers-cell" data-on="officeqa mha"><b>codex</b><small>The Codex CLI, working in a workspace.</small></div>
<div class="ha-layers-cell" data-on="harness2"><b>claude</b><small>The Claude Code CLI, working in a workspace.</small></div>
Expand All @@ -31,8 +30,9 @@
<div class="ha-layers-head"><strong>Layer 1 · Model</strong><span>A model and the way to reach it · <code>hermit/agent/model/</code></span></div>
<div class="ha-layers-cells">
<div class="ha-layers-cell" data-on="officeqa clbench gepa mha harness2"><b>Model</b><small>A <code>&lt;backend&gt;/&lt;model&gt;</code> reference, or a model name with a login (<code>login: chatgpt</code>, <code>login: claude</code>); the reasoning effort; the price.</small></div>
<div class="ha-layers-cell" data-on="clbench gepa"><b>Direct</b><small>One model call, no agent: tools in the request come back as tool calls, never run. For code that decides every step itself.</small></div>
</div>
</div>
</div>
<figcaption class="ha-layers-note" aria-live="polite">Every agent goes through all three layers. A method that decides every step in its own code still has a Base Agent: the simplest one, direct.</figcaption>
<figcaption class="ha-layers-note" aria-live="polite">Every model call goes through Layer 1. A method or a benchmark that decides every step in its own code makes single model calls (Direct) and needs no Base Agent; an agent works in the environment its call gives.</figcaption>
</figure>
6 changes: 3 additions & 3 deletions docs/_static/js/agent-layers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* Agent layers: highlight the cells one call path goes through. Without this script every cell shows. */
(() => {
const NOTES = {
all: 'Every agent goes through all three layers. A method that decides every step in its own code still has a Base Agent: the simplest one, direct.',
all: 'Every model call goes through Layer 1. A method or a benchmark that decides every step in its own code makes single model calls (Direct) and needs no Base Agent; an agent works in the environment its call gives.',
officeqa: "Acting: OfficeQA's task functions place task.md and the corpus in the workspace, the adapter is deployed under hermit/<id>/ as hermit deploy does, and Codex answers in a container of its own.",
clbench: "Acting: CL-Bench's runner keeps its own loop (the game, its turns and scoring) in Layer 3 and reaches its model through a local endpoint; each request is one direct call.",
gepa: 'Learning: GEPA decides every step in its own code and needs only text back from the model, so its Base Agent is direct (ctx.agent).',
clbench: "Acting: CL-Bench's runner keeps its own loop (the game, its turns and scoring) in Layer 3 and reaches its model through a local endpoint; each request is one Direct call (Layer 1).",
gepa: 'Learning: GEPA decides every step in its own code and needs only text back from the model, so it makes single Direct calls (Layer 1, ctx.agent) and needs no Base Agent.',
mha: "Learning: Meta-Harness Adapter's proposer is a Codex session that reads the learning material and writes candidate adapters.",
harness2: "Learning: Harness²'s proposer is started by the upstream code; each of its sessions is one claude call.",
};
Expand Down
Loading
Loading
0