8000 Add the AHE-Beta Adapter: harness evolution from simulated users, confined to a Codex adapter by mmjzmy · Pull Request #118 · Infini-AI-Lab/hermit · GitHub
[go: up one dir, main page]

Skip to content

Add the AHE-Beta Adapter: harness evolution from simulated users, confined to a Codex adapter - #118

Merged
iamziyuzhao merged 21 commits into
Infini-AI-Lab:mainfrom
mmjzmy:feat/ahe-beta-integration
Nov 30, 2026
Merged

iamziyuzhao merged 21 commits into
Infini-AI-Lab:mainfrom
mmjzmy:feat/ahe-beta-integration

Conversation

@mmjzmy
@mmjzmy mmjzmy commented Nov 20, 2026 •
Copy link
Copy Markdown
Contributor

Rewritten by the maintainers on top of the author's commits (no force-push): the integration now fits main after #112–#126, sits entirely in examples/ahe_beta_adapter/ and its docs, and changes nothing in hermit/. The history of how it got here is in the comments below.

Change

The AHE-Beta Adapter: AHE-Beta (arXiv:2611.24924, code at 43b165f) evolves a coding agent's harness from what simulated users ask for while they work with it. AHE-Beta edits its whole NexAU seed harness; here its loop is confined to an adapter, as the AHE Adapter does for AHE: Codex, its loop and its tools are fixed, and only the adapter changes (Codex's project instructions, command hooks, scripts, skills, roles). AHE-Beta's own Hermit integration makes the same choice. Method page · example

  • Acting agent with a user (utils/user.py): UserCodexAgent subclasses Hermit's CliAgent. One codex exec runs in each task's own Harbor environment while a simulated user talks to it through three Codex hooks and a root-owned bridge: a message inserted after a tool call, tool calls denied after an interrupt or the user's end, a Stop that hands the reply to the user and continues with the next message. The adapter's .codex/ is merged with the user's hooks as the deployment uploads it; what the run places in the workspace is kept aside first and put back before the user reviews the agent's work, so the review and the task's capture see only the agent's change.
  • The user's contract, unchanged, for a later Hermit abstraction (real people giving a rollout feedback and interrupting it): simulate(task, agent, workspace, params) -> dict. utils/ahe_user.py puts AHE-Beta's own simulator behind it, its model reached through Hermit (a reference via the relay, or a chat endpoint over Codex on a login, each request in its own bubblewrap sandbox); utils/scripted_user.py is the smoke's.
  • Learner boundary: the rows hold id, harbor_task, instruction; each session's persona, scenario and round are in assignments.json, read only by the acting agent. The learner reads the visible verdict (rating, outcome, reason, issues, feedback) and the user transcript; the simulator's own records stay in a private folder outside every log.
  • Scores and failures: utils/judge.py user scores the verdict the host kept ((rating − 1) / 3), never a file in the container; verified is the task's verifier with the user's rating beside it. A failed user is extra.infra = user_failed (run again, then a failed run, not the agent's 0); a session out of time before the verdict is the agent's 0, as AHE-Beta rates it.
  • The user is part of the rollout: the simulated user's model spend is added to each session's tokens and cost (the actor's own stays in extra.actor), so it counts against the run's budget with the rollouts, not the learner's.
  • Runs (prepare.py): an AHE-Beta cohort (its exporter's Harbor task directories) becomes a run: Codex acting with AHE-Beta's user, Hermit's Codex Evolver learning from the users' verdicts, one step per round, AHE-Beta's requirement-centred protocol in the template's learner guide (.hermit/EVOLVER.md). Sessions whose task needs a companion container are left out (a Hermit environment does not reach one yet).
  • AHE-Beta's own team (delivery/, moved out of core): Triage, PM, Architect and the OpenAgents developers on a Gitea repository, as an Evolver. They are the paper's learner, so they run where a learner runs: AHE-Beta's controller and the OpenAgents worker each in a view of the run's sandbox, shown only their own folders and variables, never the cohort's assignments.json (the personas) or the run's layout; the worker configured and run as AHE-Beta runs its own. The Evolver itself runs nothing the team can write: it takes the delivered adapter from Gitea into a mirror of its own, refuses what the template or Hermit's tree would not keep, and moves the binding last. Setup refuses what no step can mend before a round of sessions is paid for (credentials, the hosts the run's proxy lets through, the folders each process is shown). Run end to end once on the paper's models (Validation below).

Application-side changes: none in hermit/. Added: examples/ahe_beta_adapter/, docs/methods/ahe_beta_adapter.md, rows in docs/methods/index.md and docs/index.md, a CHANGELOG.md entry. The original PR's core changes (RunUnavailable in hermit/task.py with Trainer/rollout plumbing, the cli.py f-string edit, the pyproject.toml package-data line, the template and Evolver inside the package) are dropped.

The authors' implementation against this one

Dimension AHE-Beta (43b165f) AHE-Beta Adapter Why Open?
When learning happens after each round (every seed once with its persona); five rounds learn, the sixth is observed the same: one step is one round, one epoch; the last round is the evaluation split Same no
What the learner sees issues with evidence, interaction records, harness logs, ratings, summaries; never a persona prompt or a verifier the users' verdicts and transcripts, the agent's event stream; no persona; the verifier verdict is recorded with each rollout (AHE-Beta's exported tasks only copy the rating) Framework no
Each component's carrier NexAU's whole seed harness (configuration, entry point, tool definitions and code, prompts, parameters), written by developer agents the adapter's files, written by the learner only; Codex's loop, tools, context handling and sampling fixed Framework (the reason for the name) no
The update requirement-driven: Triage, Architect's RFC, PM, admission, developers' PRs, review, merge only for a verified requirement one Codex learner session with AHE-Beta's protocol as text (.hermit/EVOLVER.md), check_spec; every step kept. AHE-Beta's own pipeline: run-delivery.yaml, run end to end once Decision (the route with a matched-effect run still to come) yes
Tasks and runtime 32 seeds; U8/U16/U32 over six rounds; E2B with internet the same cohorts in Harbor environments (local Docker, public network), without companion-container sessions Framework yes (companion containers)
Models and budgets GLM-5.3-Flash acting and user, GLM-5.3 team, Claude Code developers configuration; GPT-5.6-Luna on a ChatGPT login by default Decision no
Not ported the held-out suite (38 Harbor-index tasks, harbor-index@35f01ec, release 1.4), its evaluation persona, the human A/B study Decision yes

Protocol: AHE-Beta's own: train/test by rounds on one cohort (rounds 1–5 train, round 6 observes the final adapter on the same seeds); the paper's held-out evaluation (38 Harbor-index tasks, pass@1 by their verifiers, utils/judge.py:verified) is not packaged.

First evaluation

OfficeQA with GPT-5.6-Luna on a ChatGPT login in every role (actor and Codex Evolver at medium effort, the user at low), AHE-Beta's schedule on the 50 training questions (five rounds that learn, a sixth observed, the 15 personas of u32-mixed-e2b.json, concurrency 8), then one pass over the 172 test questions without a user (standard error about 3.7 points). The training signal is the users' ratings alone. Deviation from the row: the starting adapter is this example's template (one line), not SkillOpt's initial skill, since another template's adapter does not carry the user channel. Full record.

Run No adapter Starting adapter Final adapter Final − starting (paired)
examples/officeqa, the GPT-5.6-Luna column's evaluation (exact match, officeqa-codex:0.164.0); branch at 11e2cdb, AHE-Beta 43b165f; 2026-11-27 0.308 (the column's cell) 0.366 (63) 0.471 (81) +10.5 points, SE 3.4; 27 gained, 9 lost
examples/officeqa_harbor (#128's agent and verifier, the OfficeQA paper's scorer at 0.0%, Codex 0.164.0); main at 899597b with this branch merged; AHE-Beta 43b165f with two local fixes; 2026-11-28 0.576 (99) 0.622 (107) 0.605 (104) −1.7 points, SE 3.0; 12 gained, 15 lost
  • First run: the gain is the answer's form (22 of the 27 gained questions already held the reference's value). The users' mean rating did not move (2.98 → 3.00) and was unrelated to a correct answer: AHE-Beta's terminal review at 43b165f reads an 80-character preview of each reply, so an accepted complete answer is rated "not delivered". One question with CRLF failed in every round. Training 2 h 34 min, 127.4 M rollout and 4.4 M learner tokens.
  • Second run: both fixed in a local copy of AHE-Beta (neither fix is in 43b165f, which this PR pins). The rating then follows the answer (68% of sessions rated 4 are right at the scorer's 1% threshold, 26% of those rated 2) but does not rise with training (3.50 in round 1, 3.46 in round 6), and the test score is within one pass's noise of the starting adapter's. All 300 sessions rated, no test question errored. Training 2 h 17 min, 194.6 M rollout and 3.3 M learner tokens.
  • Reading: the integration runs a whole AHE-Beta schedule on a Harbor benchmark with no failure; on OfficeQA it shows no effect beyond the answer's form. The paper's own tasks (coding, optimization, analysis, tool use) are not run.
  • Not packaged: the OfficeQA cohort builder and the per-session records.

Validation

Run with Harbor 0.25.0 (local Docker), Codex 0.170.0 (mounted static release), AHE-Beta 43b165f, GPT-5.6-Luna on a ChatGPT login (records in the README):

  • Smoke (hermit eval --config examples/ahe_beta_adapter/smoke/run.yaml --adapter ../template, scripted user, the template deployed): 8 of 8 channel checks (a message delivered after a tool call, a follow-up delivered at Stop, the interrupt denying the next call, the user's final question against the file), no errors: 76 s on 11e2cdb, 84 s on fa7e1c6 (main merged in).
  • AHE-Beta's own delivery route, end to end (run-delivery.yaml from bootstrap.py, a Gitea 1.22.6 on this machine), on the paper's models for the team on Fireworks: GLM-5.3 for Triage, the Architect and the PM (its OpenAI-compatible API), Claude Code 2.1.332 calling GLM-5.3 for one developer (its Anthropic-compatible endpoint); the actor and the user on a ChatGPT login. Four U4 seeds (o14, m03, o01, m01), two rounds: hermit train, then hermit eval --adapter final. Bootstrap's retry took the repository again by its marker and the clones by its record; round 1's sessions ran with AHE-Beta's users and their native records; the controller published their reports; Triage opened 3 issues, merged into the Architect's RFC; the divergent PM wrote 3 requirements; admission passed them; the OpenAgents developer opened 4 pull requests, reviewed and merged; the sealed receipt (tested 15671a9, delivered ac61ffa) was imported as delivered and bound; round 2's sessions ran on it, each native record naming it, no errors. Ratings: round 1: 4, 1, 2, 1; round 2: 1, 2, 1, 2 (four sessions cannot show an effect). About $9.2 of GLM-5.3 for the team, 1 h 53 min for the training step. It ran on the tree as of the sixteenth review round. A second run on 11e2cdb's code (the reviewed tree) passed bootstrap (the worker's home claimed), the setup checks against the real configuration, round 1 (one session's simulated user rejected its own evaluation, and the session ran again, as a failed user's does), Triage, the RFC and the PM's three requirements, and three of four pull requests merged through the Gitea. Its spend guard stopped it at about $20 before the fourth pull request, the receipt and round 2: its developers ran about 50 Claude Code sessions of their own, reproducing a session's complaint (the agent verifying the wrong workspace) to test their fix.
  • AHE-Beta's simulator on one U8 seed (on the code at 068549f, before the review below): the persona's request, the session, the terminal review, rating 4, 286 s.
  • Four U8 seeds × two rounds (on the code at 068549f; the review's changes since are covered by the smoke and the tests) (hermit train, one Codex Evolver step, hermit eval --adapter final): ratings 4, 3, 3, 3 then 2, 3, 3, 4; four sessions a round cannot show an effect. The learner read no persona (checked in the material) and its change named no task.
  • Merge: main at 899597b (with OfficeQA through Harbor in the OfficeQA paper's evaluation #128) merged in at b5d73aa; CHANGELOG.md's Added list keeps both new entries.
  • Tests: python -m pytest --changed --base origin/main on the merged tree (the core group, which holds every example's own tests, this one's among them; no method's group is touched): 1413 passed, 121 skipped, 658 deselected, 2 failures. One is this machine's setup (test_rrsi_sees_a_harbor_rollouts_failure_and_a_cli_model_is_refused_for_harbor: No module named 'rrsi'). The other was this example's bridge test, whose socket under pytest's tmp_path passed AF_UNIX's 107 bytes with a long TMPDIR; fa7e1c6 names it relative to the test's folder (the environment's socket, /run/ahe-user-channel/channel.sock, is unchanged), and the example's suite then passed: 198 passed, 1 skipped (a bridge marker check that needs root). The PR's CI run (Tests) passed on fa7e1c6: 1440 passed, 92 skipped.
  • Docs: bash docs/build-pages.sh (Sphinx -W) and python docs/check-pages.py passed (71 pages on the merged tree, and again on 1731144).
  • 1731144 (the first evaluation's record, documentation only): the example's suite again 198 passed, 1 skipped.

Review

  • Core changes: none; git diff main -- hermit/ is empty.
  • Agent layers: UserCodexAgent is a CliAgent subclass in the example, run in the call's environment (a task's Harbor environment, isolation: remote); the user's model is Layer 1 (a reference through the relay, or a CLI chat endpoint in its own sandbox); prompts and models are configuration. The delivery Evolver declares needs: [send_material_out].
  • Correctness and failures: failed users are infra (final when no run can do better), out-of-time sessions are the agent's 0, a cleanup failure after a verdict keeps the verdict, an adapter failure is the agent's 0. Tests
  • Real execution paths: the smoke and the cohort runs go through hermit eval / hermit train with real models.
  • Documentation: the example README, the method page, both methods tables, the examples index, the changelog.
  • This description: read end to end against the code at 11e2cdb; fa7e1c6 adds main and the bridge test's fix; 1731144 adds the first evaluation's record.
  • Benchmark: AHE-Beta's exporter writes Harbor task directories; rows hold only the public half, personas are private; tasks declare their timeouts (the exporter's --agent-seconds) and no network (public, as AHE-Beta's E2B sandboxes); one smoke and one train/eval run above.
  • Tests: examples/ahe_beta_adapter/utils/tests, selected by pytest --changed; each regression test fails on the code before its fix; no network, sign-in or CLI.
  • Sandbox: the actor runs in each task's Harbor environment; the user's CLI model in a bubblewrap sandbox per request reaching only the login's hosts; the learner in Hermit's evolver sandbox (enforce: required); the judge only reads the host's verdict. AHE-Beta's own delivery route starts its controller and OpenAgents worker each in a view of the run's sandbox (refused without one), network sandbox.evolver.allowed_hosts.
  • Method reproduction: a new template (no existing one carries the user channel's hook rules), Hermit's Codex Evolver (flow below), the table above, the learner boundary, sandbox control as above; the first evaluation above (OfficeQA; no experiment of the paper's yet).
flowchart LR
  A[adapter H_r] --> R[round r: every seed once, Codex in its Harbor environment, AHE-Beta's user over the channel]
  R --> V[verdicts and transcripts]
  V --> L[Codex Evolver, AHE-Beta's protocol in EVOLVER.md]
  L --> C[check_spec, repair] --> B[adapter H_r+1]
Loading
  • Independent review: two independent reviewers over thirty rounds (this session and Codex gpt-6.2-astra at high effort, read-only); every finding verified against the code before acting on it, graded by this session; each fix has a regression test that fails on the code before it; the loop ran until a round left nothing graded P1 or P2, and what was left is recorded with its reason in the comments below

Add an example-local Codex conversation bridge with mailbox hooks for insertion,
follow-up, interruption, adapter Stop hooks, and explicit process shutdown.

Connect AHE native direct and simulated sessions to Harbor task rewards while
retaining complete session artifacts and separate Actor and user usage.
Reuse completed rollouts and bind tested adapter content to delivery commits.

Add a constrained Codex adapter template and an Evolver that delegates each
whole-cohort feedback round to AHE's native demand and OpenAgents delivery flow.
Prepare frozen training configurations with a separate final user-only round.

Propagate RunUnavailable through rollouts and training so missing prerequisites
leave the step unfinished rather than becoming zero-valued training examples.

Include scripted control checks, real-model smoke entry points, regression tests,
package data, test-group registration, and source-checkout setup documentation.
Route simulated-user control messages through a root-owned bridge instead of a writable Actor mailbox. Keep final reward and evidence host-owned, prevent Actor-created symlinks from redirecting host writes, and clean task processes from trusted service registrations and ancestry rather than declared ports. Add bridge regression coverage and document the isolation boundary.
Replace nested quote expressions in the Codex web-search settings with explicit values so the Hermit CLI module can be imported and its tests can run. This restores the existing behavior for live and disabled search modes without changing the configuration contract.
Rename the AHE-Beta template guide from STRUCTURE.md to EVOLVER.md so the template follows Hermit’s adapter contract and the existing learner entry points. Keep the guide contents and runtime behavior unchanged.
Identify the AHE-Beta Codex adapter as the implementation surface described by Agentic Harness Engineering Beta: Requirement-Centered Evolution of Agent Harnesses and link the arXiv paper. Clarify the adapter boundary and its fixed runtime inputs in the template README.
Keep the Hermit adapter contract separate from OpenAgents development metadata when importing a delivered commit. Filter copied files by the adapter manifest and calculate bindings over the same contract-managed paths so delivery metadata does not invalidate the runtime adapter. Initialize the first rollout binding after the Trainer has exported its workspace, preserve delivery and run identifiers in rollout configuration, and keep minimal binding fixtures compatible with adapters without a manifest.
Resolve the OpenAgents source from AHE's compatibility pins and verify the exact checkout before training. Add a Hermit-side bootstrap that creates or reuses a private Gitea Harness repository, seeds it from the adapter template, creates independent delivery and OpenAgents worker clones, and writes token-free worker configuration. Provide a pinned OpenAgents launcher, protected environment template, and documentation for local or self-hosted Gitea setup.
Provide an executable Harbor fixture, explicit Codex model settings, disabled web search, and a test API key for adapter runner tests introduced by the upstream Harbor validation contract.
Move the Hermit manifest and EVOLVER parsing from demand into the
integration layer. Add a generic ArtifactHandoff boundary so demand
roles remain independent of Hermit file names and semantics.

Preserve guidance injection, proposal annotations, tested commit
binding, fixed learnable paths, and recovery behavior. Move the
contract tests alongside the Hermit integration.
@iamziyuzhao
iamziyuzhao self-requested a review November 20, 2026 15:25
iamziyuzhao and others added 6 commits 10000 November 24, 2026 04:35
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>
- RunUnavailable (and its Trainer and rollout plumbing, with its test) is
  dropped: a rollout that is not the agent's result already has main's
  path (the agent's `extra.infra`: run again in a fresh environment, then
  an unscored record), and a failed Evolver step is recorded as failed.
  A new exception that ends a whole run is a core change for the core
  team, not part of a method.
- The web_search lines in hermit/agent/base/cli.py are valid Python 3.12
  (PEP 701 f-strings), the version Hermit requires: unchanged.
- pyproject.toml keeps agent/base/hermes_plugin/plugin.yaml in the
  package data, which the PR's line had dropped; the AHE-Beta template
  moves to the example (next commits), so no packaging line is needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The template moves from hermit/adapter/templates/ahe_beta to
examples/ahe_beta/template (a config names it by path), and the
demand/delivery Evolver from hermit/agent/evolver/methods/ahe_beta to
examples/ahe_beta/delivery (evolver.name names it by path).

The Evolver imported the example's helpers by putting examples/ on
sys.path from inside the hermit package, which breaks an installed
Hermit and runs the layering backwards; it needs an AHE-Beta checkout,
Gitea and an OpenAgents worker, and has run only with scripted models.
In the example it imports its siblings directly, its failures are a
local exception (the Trainer records the step failed, the adapter
stays), a round's rows come from the cohort's assignments.json, and a
session's native records from the private folder the acting agent kept
(next commit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arbor environment

main removed the Harbor runner this PR's acting side was built on
(agent.name: harbor, hermit/harbor/runner.py, harborside's HermitCodex):
every agent is now Hermit's, working in the task's HarborEnvironment
through exec, upload and download. The session with a user is rebuilt
on that, its contract unchanged:

    simulate(task, agent, workspace, params) -> dict

- utils/user.py: UserCodexAgent subclasses Hermit's CliAgent, so the
  adapter's deployment, the sign-in, the stream, the usage and the infra
  classification are the framework's. The first message starts one
  codex exec for the whole conversation; the PR's hooks and root-owned
  bridge are installed as root before it, and the adapter's .codex/ is
  merged with them as the deployment uploads it (its Stop hooks run
  first, inside the user's). This machine reaches the bridge with one
  command at a time (a read waits there up to 5 s), so auto_mounting and
  the host-mounted event mirror are gone.
- What a learner reads is the visible verdict (score, rating, outcome,
  reason, issues) and the transcript; the simulator's own records stay
  in a private folder outside the log. A failed user is extra.infra
  (user_failed: run again, then unscored), not RunUnavailable.
- utils/judge.py: `user` scores the verdict this machine kept (never a
  file in the environment); `verified` scores the task's own verifier
  (pass@1) with the user's rating beside it.
- utils/ahe_user.py: AHE-Beta's simulator, its model a Hermit model: a
  <backend>/<model> reference, or a chat endpoint over Codex on a login,
  each request in a sandbox of its own (hermit.isolate.cli_sandbox).
- prepare.py: the rows a learner reads hold no persona (each row's
  assignment goes to assignments.json, read by the acting agent only);
  run.yaml learns with Hermit's Codex Evolver, run-delivery.yaml with
  AHE-Beta's own.
- smoke/: one task through hermit eval with a scripted user on a real
  model: insertion, follow-up, interruption and a final review.
- Codex in a task's container is this machine's static release mounted
  read-only (agent.codex.bin), since Hermit asks only its built-in
  agents what to install there.
- test_channel_server's bridge test no longer depends on the
  interpreter's path containing "codex".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RunOutput.extra["user"] reaches the learning material (the record's
pipeline_extra), so it now holds the visible verdict, the user's usage
and the counts, never the simulator's other keys; and an environment
that cannot run the channel (no python3) is final infra, which no run
again would change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- AHE-Beta's verdict reaches the learner only through ahe_user.visible:
  in a session without interaction its user_outcome holds the review's
  call traces, whose system prompt is the persona; the full outcome now
  stays private (files/outcome.json).
- The bridge and the hooks run on python3 3.8 or later (a hook's
  annotations were evaluated at import; the bridge's accept timeout was
  not caught before 3.10), which the channel now checks; one broken hook
  connection no longer ends the bridge.
- Codex's clock ends user.review_s (600 s) before the task's budget, so
  the user's last turn and review fit in it; a session that runs out of
  its time before the user's verdict (Codex's clock, or Harbor's end of
  the phase) is the agent's result, scored 0, not infra run again.
- A task that needs a companion container fails for good (infra final),
  as does an image whose python3 cannot run the channel.
- The Codex thread runs in the run's context (the adapter's confinement
  is a ContextVar); the channel's commands failing while the deployment
  uploads .codex/ are the environment's failure, not the adapter's.
- The user model's sessions on a login count as their rollout's on the
  plan (no slot of their own: no wait for a slot only a finished rollout
  frees); a <backend>/<model> user model goes through Hermit's relay.
- The simulator's files go to files/ in its private folder; prepare.py
  on a prepared cohort writes only the delivery files (bootstrap.py).
- The README no longer calls the channel a boundary (any command the
  agent runs is under Codex and may run the hook), says the verifier's
  verdict is recorded with each rollout (train only on the exported
  tasks), how quiescing differs from Harbor's grading, and which tasks
  need a companion container.
- Tests through UserCodexAgent.run with stand-ins at the edges (the
  thread, the user's end, a user that raises, the phase's end, Codex's
  timeout, a companion service), AHE-Beta's direct-mode verdict, and
  the bridge and hook on Python 3.8 (skipped without one); each failed
  on the previous code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamziyuzhao
iamziyuzhao commented Nov 24, 2026 •
Copy link
Copy Markdown
Collaborator

I pushed patches on top of this branch so it fits current main (after #112–#126). The PR's history is preserved: it is a merge of main plus follow-up commits, with no force-push.

What changed and why

  1. Merged main. main replaced the Harbor runner this PR was built on (agent.name: harbor, hermit/harbor/runner.py, harborside's HermitCodex). Every agent is now Hermit's, working in the task's HarborEnvironment through exec/upload/download. The conflicts were all RunUnavailable plumbing; I resolved them to main's side.
  2. No core changes.
    • RunUnavailable and its Trainer/rollout plumbing are dropped. Failures take main's existing paths: a failed user session is extra.infra = user_failed (rerun in a fresh environment, then recorded as a failed run, not as the agent's 0), and a failed delivery step is a failed step (the adapter stays).
    • The cli.py f-string edits are reverted: they are valid on Python ≥ 3.12, which Hermit requires.
    • pyproject.toml is restored: the PR's line had dropped agent/base/hermes_plugin/plugin.yaml from the package data.
  3. Everything AHE-Beta-specific is under examples/ahe_beta/.
    • The template moved to examples/ahe_beta/template/ and the demand/delivery Evolver to examples/ahe_beta/delivery/; configs name both by path.
    • The Evolver used to put examples/ on sys.path from inside the hermit package, which breaks an installed Hermit.
  4. The simulated-user session is rebuilt on current Hermit (utils/user.py). The contract is unchanged: simulate(task, agent, workspace, params) -> dict.
    • UserCodexAgent subclasses Hermit's CliAgent, so the deployment, sign-in, stream, usage and infra classification are the framework's.
    • One codex exec runs per conversation. Your hooks and root-owned bridge are kept, installed as root before Codex starts, and the adapter's .codex/ is merged with them as the deployment uploads it.
    • There is no auto_mounting or host-mounted mirror any more: the host reads the bridge one command at a time, and each read waits up to 5 s for events.
    • Codex's clock ends review_s (600 s) before the task budget, so the user's last turn fits. A session that runs out of time before the user's verdict is the agent's result, scored 0.
  5. Learner boundary.
    • The rows hold only id, harbor_task and instruction. Each row's persona, scenario and round go to assignments.json, which only the acting agent reads.
    • The learner sees the visible verdict (rating, reason, feedback, opportunities as issues) and the user transcript.
    • The simulator's own records stay in a private folder outside the log. AHE-Beta's full user_outcome (which in direct mode holds the persona prompt via review_trace) is now kept private.
  6. utils/judge.py. user scores the verdict the host kept, never a file in the container. verified is the task's own verifier (pass@1) with the user's rating beside it, for held-out evaluation.
  7. utils/ahe_user.py. Your ahe_beta.integrations.hermit.session:simulate, with its model reached through Hermit: either a <backend>/<model> reference (via Hermit's relay) or a chat endpoint over Codex on a login, each request in its own bubblewrap sandbox.
  8. Codex in the task container is a static release mounted read-only (agent.codex.bin), because Hermit asks only its built-in agents what to install.
  9. Honesty fixes in the docs.
    • The bridge is not a security boundary: every agent command runs under Codex and can run the hook, and the exported images run the agent as root.
    • The verifier's verdict is recorded with each rollout, so train only on the exported (rating-copy) tasks.
    • Tasks with companion containers (kv-live-surgery, payments-pipeline-fix) are not reachable yet and now fail for good instead of being retried.

V 8000 alidation (Codex instead of the PR's acting agent and Evolver)

  • Smoke (examples/ahe_beta/smoke/run.yaml, real Codex 0.170.0 on GPT-5.6-Luna, scripted user): mid-run insert, follow-up, interrupt (the next tool call was denied), and final review. All 6 checks passed.
  • AHE-Beta's own simulator (pinned 43b165f) with a real model on 010-pivot-product-revenue: persona-styled request, session, terminal review, rating 4, 286 s.
  • Mini cohort (4 u8 seeds × 2 rounds): hermit train (round 1, then one Codex Evolver step), then hermit eval --adapter final (round 2).
    • Ratings went from 4/3/3/3 to 2/3/3/4. Four sessions per round cannot show an effect.
    • The learner's change was general and named no task: progress updates, prompt answers to status requests, identifiable reviewer findings.
    • It targeted exactly the users' complaints.
  • After the review fixes: the smoke passed 6/6 again, and one more AHE-Beta session on the same seed rated 2 (an earlier session on it rated 4: single sessions are noisy). An independent review's findings are fixed in the last commit.
  • Tests: examples/ahe_beta/utils/tests passes (32, plus 1 root-only skip). pytest --changed had no failures from this PR; the one remaining failure needs the optional rrsi group, which wasn't installed.

Benchmark (from the paper)

  • Evolution: 32 seeds (SWE-bench 9, Terminal-Bench 8, mechanism 8, NL2Repo 4, TUA-Bench 3).
  • Held-out: 38 Harbor-index tasks (harbor-index@35f01ec, release 1.4, published38).
  • Held-out evaluation is not packaged in this PR. In Hermit it would be a Harbor task set judged with judge.py:verified.

On the simulated user

这个模拟用户的功能我是这么想的:咱这一版先放在 Hermit 的 examples/ahe_beta/ 下跑,因为目前只用脚本模型验证过。等用真实模型和你们的真模拟器跑通之后,我再把它改成 Hermit 的 abstract,因为后面还要支持真人用户给 rollout 反馈和打断。之后 simulate(task, agent, workspace, params) 这个接口在变成 abstract 的时候不变,你们的 simulate 代码也可以不用改;如果接入过程中发现接口要调,我们可以在这一版就调完。

(For other readers: the simulated user stays in examples/ahe_beta/ for this version. Once it runs with real models and the authors' real simulator, it becomes a Hermit abstraction that also covers real people giving a rollout feedback and interrupting it. The simulate(task, agent, workspace, params) interface stays as it is. If integration shows it needs to change, we change it in this version.) The runs above used real models and AHE-Beta's own simulator.

Left for the authors

  • Update the PR description: several paths and claims are stale (RunUnavailable, hermit/adapter/templates/ahe_beta, the Harbor runner).
  • AHE-Beta's own delivery Evolver is moved and adapted but unvalidated beyond scripted runs. It still needs a real Gitea + OpenAgents run.

@haizhongzheng haizhongzheng mentioned this pull request Nov 25, 2026
27 tasks
…un's sandbox

The example moves to examples/ahe_beta_adapter ("AHE-Beta Adapter", as the
AHE Adapter): AHE-Beta evolves a whole NexAU harness; here its loop is
confined to a Codex adapter. A method page, rows in the methods index and
the examples index, and a changelog entry are added.

Fixes from ten rounds of independent review (Codex gpt-6.2-astra, high),
each with a test that fails on the code before it:
- the user channel: replies, interrupts and the user's end in order (a
  stale stop reply never answers a later message, an acknowledgement
  matched to its interrupt, nothing handed over while an interrupt or the
  end waits, a tool call denied while the channel cannot be read, long
  replies cut, U+2028 kept inside its JSON line);
- the workspace: what the run places is kept aside and put back before
  the user's review and the task's capture (links, folders, bytecode, the
  exclude lines, a task's own .codex owner and mode), never through a link;
- accounting: the user model's spend is the rollout's (priced parts kept,
  unknown parts flagged, failed sessions and Codex failures included); a
  lost user-model sign-in ends the run instead of buying more sessions;
- prepare.py: companion-container sessions left out, Harbor's delivery
  margin and the review time checked, JSON lines read and written safely,
  a machine whose Git ignores a template file refused;
- the template: check.py applies Hermit's hook shape; the learner's
  protocol is in .hermit/EVOLVER.md.

AHE-Beta's own delivery Evolver (the maintainer's decision: its team is
the paper's learner): its controller and the OpenAgents worker each run in
a view of the run's sandbox, shown only their own folders and variables,
never the cohort's personas; the Evolver runs nothing the team can write,
takes the delivered adapter from Gitea itself and writes the binding last;
the worker is configured and run as AHE-Beta runs its own; setup refuses
what no step can mend. Not validated end to end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamziyuzhao iamziyuzhao changed the title Add AHE-Beta Codex adapter evolution example Add the AHE-Beta Adapter: harness evolution from simulated users, confined to a Codex adapter Nov 25, 2026
@iamziyuzhao
iamziyuzhao commented Nov 25, 2026 •
Copy link
Copy Markdown
Collaborator

Update: renamed, dual-reviewed, AHE-Beta's team confined

Pushed 47b8768 on top of 068549f (fast-forward, no force-push). Three changes the maintainer asked for, and the review that followed:

  1. Renamed to examples/ahe_beta_adapter/, the AHE-Beta Adapter, as the AHE Adapter: AHE-Beta evolves its whole NexAU harness, while here its loop is confined to a Codex adapter. A method page, rows in both methods tables and the examples index, and a changelog entry are added.
  2. The simulated user is part of the rollout: its model spend is added to each session's tokens and cost (the actor's own stays in extra.actor), so trainer.budget counts it with the rollouts.
  3. AHE-Beta's own team (delivery/) runs where a learner runs. Its controller and OpenAgents worker are the paper's learner (Algorithm 1), so each now starts in a view of the run's sandbox: only its own folders and variables, never the cohort's assignments.json (the personas) or the run's layout. The Evolver itself runs nothing the team can write. It takes the delivered adapter from Gitea into a mirror of its own and refuses what the template or Hermit's tree would not keep. The binding is written last. The worker is configured and run as AHE-Beta runs its own. Setup refuses what no step can mend before a round of sessions is paid for. This route is still not validated end to end: it is unit-tested with stand-ins and a local Git server, and no run against a real Gitea and OpenAgents has been made.

Review

Two independent reviewers ran ten rounds: this session, and Codex gpt-6.2-astra at high effort in a read-only sandbox. Every finding was verified against the code before acting on it. Each fix has a regression test that fails on the code before it. The loop stopped at its ten-round cap, so the tenth round's fixes were not reviewed again.

Round Codex findings Fixed Left (why)
1 34 ~20 6 on the delivery route, settled by item 3 above; uncertain, minor, not a problem
2 19 + 2 minor 17 minor
3 18 + 3 minor 17 minor; a parity question for Codex 0.170
4 17 16 a stalled first persona request (bounded by the client's timeout)
5 25 + 1 minor 19 the issue footer (open, below); minor
6 19 + 2 minor 17 an upstream handle limitation, a core one (below); minor
7 18 + 2 minor 17 a known gap (below)
8 11 + 1 minor 12
9 14 + 2 minor 13 by design (a local model's port forwarded); not worth it (mirror history)
10 12 + 1 minor 12 an upstream handle limitation (below)

Open for the maintainer

  • AHE-Beta's controller publishes each user's issue to Gitea with its _auto-collected line (the persona's id, capability tier and error-correction style), which upstream puts there on purpose for its developers' triage. The validated route already cuts it from what the Hermit learner reads. Should the delivery route strip it too, deviating from upstream's developer evidence, so that OpenAgents sees nothing of a persona?
  • The reproduction guide asks for a draft until a first evaluation runs. This PR has no matched evaluation yet: the four-seed runs validate the route and measure no effect.

Recorded, not fixed

  • Known gaps of the delivery route, all listed in the README:
    • a failed round, or a step the Trainer stops after the clone moved, leaves the binding behind, so the later rounds refuse it (NotBound);
    • a crash between delivery and Hermit's checkpoint replays a different cohort;
    • the developers' usage is recorded as unreported;
    • demand usage is reported only for a delivered round;
    • the mirror fetches main's whole history each step;
    • bootstrap.py reuses an existing repository or clone without checking it.
  • Upstream's ConversationHandle closes a request only on a reply. After a zero-wait interrupt, or a terminal adapter Stop, its native records merge requests. The user's transcript here keeps them apart.
  • In core, rollout.py drops exc.spent on its OSError path, for every agent.

Validation on the pushed tree: python -m pytest --changed --base origin/main (the core group, which holds every example's own tests, this one's among them; no method's group is touched): 1315 passed, 117 skipped, 658 deselected, 1 failure of this machine's setup (test_rrsi_sees_a_harbor_rollouts_failure_and_a_cli_model_is_refused_for_harbor: No module named 'rrsi', RRSI's upstream package is not installed here). The example's own suite alone: 138 passed, 1 skipped (a bridge marker check that needs root). The PR's CI run (Tests) passed on 47b8768. The scripted-user smoke passed 8 of 8 checks in 78 s. The docs build and page check passed (70 pages). The branch merges into main (c3db471) cleanly.

AHE-Beta's own delivery route (run-delivery.yaml) was run end to end once
on the paper's models: GLM-5.3 on Fireworks for Triage, the Architect and
the PM, and Claude Code 2.1.332 calling GLM-5.3 for one developer. Four
U4 seeds over two rounds: bootstrap (with a retry), round 1's sessions,
three Triage issues merged into an RFC, three PM requirements, admission,
four pull requests reviewed and merged, the sealed receipt imported as
delivered, round 2 bound and evaluated on it. About $9.2 for the team,
1 h 53 min for the training step. The README, the method page and the
methods index report it.

Fixes from rounds 11-30 of independent review (Codex gpt-6.2-astra, high,
and this session), each with a test that fails on the code before it:
- delivery setup: exactly one Claude credential handed to the developers,
  a subscription token only for Anthropic's API over https; the demand
  roles' model set and handed to the controller; every model host and the
  Gitea's checked against the run's allowed hosts as its proxy matches
  them, and no loopback name among them; plain http refused off this
  machine, and a local endpoint only under the names whose port the
  sandbox forwards; the run's claim keeps the configuration's digest; the
  prepared clones must still exist;
- delivery steps: a session whose adapter failed before Codex ran is left
  out of the evidence as one rated out of time, not taken for a lost
  record; the OpenAgents environment must still be the checkout's own;
  the developers' light calls on the session's model unless one is set,
  as AHE-Beta sets both;
- bootstrap: the repository known by a random marker of the cohort's own,
  clones made in a folder of their own and renamed whole, the worker's
  home claimed and made like the clones, the developers' roster from the
  cohort, the OpenAgents environment only inside its checkout;
- prepare.py: AHE-Beta's snapshot keeps its compatibility pins, the
  controller is handed the demand roles' variables only, and a worker
  needs an OpenAgents pin;
- Git for the Gitea: the token for its origin whatever user Git's own
  configuration names, nothing for another origin; clones keep the
  commit's bytes (core.autocrlf off);
- the user model: AHE-Beta's own variables only with their own key, this
  machine's addresses in NO_PROXY and no_proxy alike, the key checked
  without following a redirect, a failed session's spend kept with
  unknown parts flagged;
- the channel: a hook past its timeout ends every process it started (its
  group and any process carrying its run's mark), a message still being
  written is not read, the Stop hook reads interrupts and the user's end
  again after the adapter's own Stop hooks; a Codex that could not start
  is not waited for, and a shorter configured deadline is kept;
- the template's check.py: hook timeouts in whole seconds within [1,
  3600]; role names as Codex takes them, each reported on its own file,
  and a role Hermit's loader refuses left to Hermit's deploy check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamziyuzhao
Copy link
Copy Markdown
Collaborator

Update: AHE-Beta's delivery route run end to end, review rounds 11–30

Pushed 11e2cdb on top of 47b8768 (fast-forward, no force-push).

AHE-Beta's own delivery route ran end to end once, on the paper's models for its team. GLM-5.3 on Fireworks served Triage, the Architect and the PM through its OpenAI-compatible API. Claude Code 2.1.332 served one developer, calling GLM-5.3 through Fireworks' Anthropic-compatible endpoint. The actor and the user ran on a ChatGPT login. The run used four U4 seeds (o14, m03, o01, m01) over two rounds: bootstrap.py, then hermit train, then hermit eval --adapter final.

  • Bootstrap's retry took the repository again by its marker and the clones by its record.
  • Round 1's four sessions ran with AHE-Beta's users, each with its native record. The controller published their reports.
  • Triage opened 3 issues, which the Architect merged into one RFC. The divergent PM wrote 3 requirements, and admission passed them.
  • The OpenAgents developer opened 4 pull requests, which were reviewed and merged.
  • The sealed receipt (tested 15671a9, delivered ac61ffa) was imported as delivered and bound for round 2.
  • Round 2's four sessions ran on it with no errors, and each native record names it.

Ratings were 4, 1, 2, 1 in round 1 and 1, 2, 1, 2 in round 2. Four sessions cannot show an effect. The team used about $9.2 of GLM-5.3, and the training step took 1 h 53 min. The run used the tree as of the sixteenth review round. The later rounds tightened setup and the channel; the tests and the smoke cover those changes.

Core: #129. Two fixes these runs needed in hermit/ are kept out of this PR:

  • a missing Codex login file counts as a lost sign-in;
  • a rollout that fails with OSError keeps its spend.

Maintainer's decisions since the last update:

  • The delivery route keeps the _auto-collected footer, as upstream publishes it for its developers' triage. The validated route still cuts it from what the Hermit learner reads.
  • This PR stays open, not a draft.

Review

The two reviewers ran rounds 11 to 30: this session, and Codex gpt-6.2-astra at high effort in a read-only sandbox. Every finding was verified against the code and graded by this session: P2 means it goes wrong under a specific configuration or event, P3 a rare combination. P2 findings were fixed, and P3 findings were fixed where the fix was cheap. Each fix has a regression test that fails on the code before it. The loop ran until a round left nothing graded P1 or P2.

Round Codex findings Graded P2 Fixed Left (why)
11 11 + 1 minor 7 10 1 moved to #129 (core); 1 minor
12 13 + 2 minor 12 12 + 2 minor 1 moved to #129 (core)
13 13 3 (+2 own) 11 1 P3; 1 not a problem
14 8 1 8
15 15 + 1 minor 3 (+1 own) 14 + 1 minor 1 P3
16 9 + 1 minor 1 7 (2 in the README) + 1 minor 2 P3
17 8 + 1 minor 2 4 4 P3; 1 minor
18 9 1 7 (1 in the README) 2 P3
19 9 + 1 minor 3 8 + 1 minor 1 P3
20 5 1 4 1 in core (below)
21 6 + 1 minor 2 4 1 P3; 1 not a problem; 1 minor
22 4 + 1 minor 2 3 + 1 minor 1 P3
23 6 + 1 minor 2 6 + 1 minor
24 5 + 3 minor 3 5 + 3 minor
25 4 + 1 minor 0 (+1 own) 4 + 1 minor
26 8 + 1 minor 1 8 + 1 minor 1 in core (below)
27 7 + 2 minor 1 3 (+2 own) 4 P3; 2 minor
28 8 + 1 minor 0 6 + 1 minor 2 P3
29 5 + 2 minor 1 1 + 2 minor 4 P3 (1 noted in the README)
30 5 + 2 minor 0 1 minor (README) 5 P3 (3 noted in the README); 1 minor

"Own" counts P2 findings from this session's own review that Codex did not report.

Recorded, not fixed (P3; the README lists the operator-facing ones):

  • Delivery and the operator:
    • two Trainer runs set up on one cohort at once, and a relocated runs folder;
    • shared or reused paths: a clone placed at a noted path between bootstrap attempts, a resumed cohort meeting another cohort's clone and home at paths that were cleared and taken again, a link chain through the worker's clone at an intermediate folder;
    • changes between bootstrap and the run: a repository an admin makes public mid-run, the seed binding checked against a reused tree, an edited cohort snapshot, a bootstrap retried with --review-seconds after run.yaml was published;
    • a Python installed with --prefix=$HOME/.local (the sandbox mounts its base);
    • host Git run in an --openagents-checkout the operator names (its help now says never to give a worker's clone);
    • a loopback alias other than localhost added by hand to the allowed hosts;
    • the sealed-receipt recovery starting the Evolver's own Git without the per-step network check;
    • a gateway without ANTHROPIC_MODEL (a gateway that aliases Claude's model names needs none);
    • an experiment with Architect grouping (the README says the Architects run ungrouped, as in every configuration upstream ships).
  • The channel and the user:
    • follow-ups larger than the hook's read size;
    • a hook helper started with both a new session and a cleared environment survives the hook's timeout;
    • the adapter's Stop hooks stop at the first block or end, and the later ones are tried again at the next Stop (documented);
    • a take whose answer is lost after the server moved the message;
    • gaps in the user model's accounting:
      • the persona client's SDK retries can hide a billed attempt;
      • AHE-Beta's client drops the tokens of a failed CLI call;
      • a receipt with reasoning tokens but no output tokens;
      • model_calls leaves out the user's calls;
      • a rollout with no count is recorded as 0;
    • a reference key that expires mid-run;
    • a reference endpoint that refuses enable_thinking or max_tokens: 32768 (the README states the requirement; Fireworks' GLM-5.3 accepts both);
    • a gateway that hides its model list from a key it serves;
    • agent.base: claude set on UserCodexAgent.

Open in core (not this PR's code):

  • Hermit's loader names no file when a role's frontmatter is not YAML, or when two roles share a name. repair then restores every changed file, so a valid edit made in the same step is lost. This affects every template that exports roles (ahe, continual_harness, harness2_codex, mwm, this one). Proposed fix: name the role's file in both errors.
  • The relay's ChatClient follows a cross-origin redirect with the Authorization header.
  • Left open on A missing Codex login ends the run; a host failure keeps its spend #129:
    • a local Codex session's lost sign-in, read from its stream;
    • a restart after an unrecorded first step.

Validation on the pushed tree:

  • Tests:
    • python -m pytest --changed --base origin/main (the core group, which holds every example's own tests, this one's among them): 1375 passed, 117 skipped, 658 deselected. The one failure comes from this machine's setup: test_rrsi_sees_a_harbor_rollouts_failure_and_a_cli_model_is_refused_for_harbor fails with No module named 'rrsi'.
    • The example's own suite: 198 passed, 1 skipped (a bridge marker check that needs root).
  • Smoke: the scripted-user smoke passed 8 of 8 checks in 76 s.
  • Docs: the docs build and the page check passed (70 pages).
  • Merge: the branch merges into main (c3db471) cleanly.
  • CI: the PR's CI run (Tests) on 11e2cdb passed.

iamziyuzhao and others added 3 commits November 28, 2026 12:53
main added examples/officeqa_harbor/ (Infini-AI-Lab#128). CHANGELOG.md's Added list
keeps both new entries, this example's first; docs/index.md and
examples/README.md merged on their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_root_bridge_delivers_to_hook_without_a_shared_mailbox bound the
channel's socket at an absolute path under pytest's tmp_path, which
passes AF_UNIX's 107 bytes under a long TMPDIR (115 here: the server
exited with "AF_UNIX path too long", and the test said only that it did
not start). The server and the hook now run in tmp_path and name it
channel/channel.sock, as the Python 3.8 bridge test does; a server that
exits ends the wait, and the failure shows its error. The environment's
socket, /run/ahe-user-channel/channel.sock, is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two runs of AHE-Beta's schedule on OfficeQA's 50 training questions, each
tested once on the 172 test questions without a user:

- examples/officeqa (exact match): starting adapter 0.366, final 0.471
  (+10.5 points, SE 3.4). The gain is the answer's form; the users'
  ratings did not move, because AHE-Beta's terminal review at 43b165f
  reads an 80-character preview of each reply.
- examples/officeqa_harbor (the OfficeQA paper's scorer): no adapter
  0.576, starting 0.622, final 0.605 (-1.7 points, SE 3.0), with that
  review and a CRLF comparison fixed in a local copy of AHE-Beta. The
  rating then follows a correct answer and does not rise with training.

The record is in the example's README; the method page's Result section
summarizes it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJYLx9BP8KVwANowQ2g
iamziyuzhao
iamziyuzhao previously approved these changes Nov 29, 2026
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJYLx9BP8KVwANowQ2g
@iamziyuzhao
iamziyuzhao merged commit 84afde7 into Infini-AI-Lab:main Nov 30, 2026
1 check passed
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.

2 participants

0