8000 Add CaP-Agent0: its acting agent, skill-library template and Evolver, with a LIBERO-Pro example by iamziyuzhao · Pull Request #136 · Infini-AI-Lab/hermit · GitHub
[go: up one dir, main page]

Skip to content

Add CaP-Agent0: its acting agent, skill-library template and Evolver, with a LIBERO-Pro example - #136

Draft
iamziyuzhao wants to merge 5 commits into
mainfrom
ziyu/cap-agent0
Draft

iamziyuzhao wants to merge 5 commits into
mainfrom
ziyu/cap-agent0

Conversation

@iamziyuzhao
@iamziyuzhao iamziyuzhao commented Nov 29, 2026 •
Copy link
Copy Markdown
Collaborator

Change

CaP-Agent0, the training-free coding agent of CaP-X (Fu et al., arXiv:2603.22435v2, §4.1; project; capgym/cap-x at acac62f), on LIBERO-Pro through the existing cap-harness engine (ASPIRE's robot harness, fa00f0e). The acting harness is cap-x's (the multi-turn loop with the Visual Differencing Module and the parallel ensemble); the adapter is its automatically synthesized skill library, which a new Evolver writes with cap-x's own compile code. Only CaP-Agent0 is integrated: CaP-Bench, CaP-Gym and CaP-RL are not, and the robot environment is the one the repository already has.

Draft until the first evaluation (the reproduction guide's rule): the configs, splits and tests are in; no run on the simulator has happened yet (see Validation).

What is added:

Part Where What it is
Template cap-agent0@1.0 hermit/adapter/templates/cap_agent0/ skill_library.py (learnable, ≤ 60 KB), its reader library (the context tool: the functions' signatures and docstrings in cap-x's ApiBase.combined_doc format, and their code), and a check against the engine's program rules
Acting agent actor.py CapAgent0Actor one trial of cap-x's _run_single_trial on one task row; every model call one Direct call (Layer 1)
Evolver cap_agent0 evolver.py, evolver.yaml cap-x's library compile (scripts/skill_library_compilation/); setting: paper or continual
cap-x's code and texts upstream/ (MIT, LICENSE, NOTICE), prompts.py the pure functions the port calls, copied verbatim as source segments; every prompt text verbatim with its source, two adaptations named
Example examples/libero/cap_agent0/ rows.py (one row per trial, the splits), paper.yaml, continual.yaml, smoke_paper.yaml, smoke_continual.yaml, judge.py, tasks.sh, launch.sh, README
Docs docs/methods/cap_agent0.md; rows in docs/methods/index.md (both tables), docs/index.md, examples/libero/README.md, CHANGELOG.md setup, one trial, the step, both settings, parameters, the comparison below
Tests tests/methods/cap_agent0/; tests/selection.py (METHODS), tests/README.md, tests/core/test_selection.py (the engine's and LIBERO's shared files now also select this group) see Validation

The two settings: the paper's pipeline and ours

paper.yaml (the paper's pipeline) continual.yaml (ours, not in the paper)
Training rollouts splits/collect.txt: the single-turn, low-level tier, no VDM, no ensemble, no library (the paper names its S3 rollouts, whose documentation adds usage examples, and cap-x's compile pools S3 and S4; the engine's API reference has no usage examples, as S4; each collection row carries multi_turn: false, vdm: false, ensemble: none, which win over agent.params) splits/train.txt: CaP-Agent0 itself, with the library as it stands
Syntheses one, at the epoch's last step, over every collected success one after every step (50 trials), over every success so far
Selection none: the one library the best validation mean (splits/val.txt, run only by the Evolver through run_agent) of the starting library and each step's; a tie goes to the later
Test ./launch.sh eval --adapter final: CaP-Agent0 with the library, frozen, on splits/test.txt the same

The paper synthesizes once, from S3 rollouts (cap-x's compile takes S3 and S4) of twelve models on CaP-Bench's Robosuite tasks, and calls the process "inherently iterative"; continual is that iteration, and is ours. Both are train / test protocols: the library is frozen at test time.

The splits (LIBERO-Pro, one row = one trial = a task and one seed)

Split Trials Suites Seeds Run by
collect 200 libero_object, libero_spatial, libero_goal, libero_10 (unperturbed, 40 tasks) 51-55 paper.yaml's training rollouts
train 200 the same 40 tasks 51-55 continual.yaml's training rollouts
val 60 the six test suites (60 tasks) 66 continual.yaml's Evolver
test 3,000 libero_{object,spatial,goal}_{swap,task}: Table 2's Pos and Task perturbations 1-50 eval
test_sample 300 the same 60 tasks 1-5 eval, a cheaper look (rows of test)
test_long 1,000 libero_10_swap, libero_10_task (beyond Table 2) 1-50 eval

rows.py refuses seed sets that meet (training, validation and test never share a seed); a row's seed is the actor's and its eval_seeds the judge's (the same seed). The *_smoke splits are 2 + 2 + 1 + 2 trials. A seed is a scene LIBERO samples (the engine's --init-mode seeded), not one of the 50 saved states the paper's trials use, so a success rate here is not comparable with Table 2's.

One trial (the acting agent)

flowchart TD
    P[probe program on the seed: the task's language, the reset frame] --> D{vdm}
    D -->|yes| V0[VDM: describe the initial frame]
    D -->|no| G
    V0 --> G[initial program: one request, or the ensemble and its synthesis]
    G --> X[turn k: the library and blocks 0..k replayed from the reset, each block in its own try]
    X --> T{episode over, or single-turn}
    T -->|yes| E[final program: the last turn's]
    T -->|no| V[VDM: how the turn's last frame differs from the one before]
    V --> Q[decision request: executed code, the block's stdout and stderr, the VDM's text]
    Q -->|REGENERATE, under the limit| X
    Q -->|FINISH, or the limit| E
    E --> J[judge on the host: the final program once more on the seed]
Loading

The engine runs one program per episode, so a turn replays the library and the blocks so far from the reset; each block runs inside a try of its own (an exception ends that block only, as each cap-x turn is one exec in the episode's namespace) and markers split the run's stdout by block. A block the engine's validator refuses, or that does not compile (a return outside a function), is left out and the refusal is its stderr. Each turn records whether its replay reached the frame the model saw (replay_matches). The model never sees the judge's score. A judge's rerun that ran no episode (no termination reason, harness_error, user_interrupt), or a refusal of the program the trial itself ran, is a judge error (judge_error), not a 0: the engine's judge counts task_success alone, so the example's judge.py checks the rerun's records.

One step (the Evolver)

flowchart TD
    R[the step's trial records: code and judge score] --> C[pool: each successful trial's code, by experiment]
    C --> S{paper: the epoch's last step? continual: every step}
    S -->|no| K0[library unchanged]
    S -->|yes| F[functions.txt per experiment: compile_successful_functions]
    F --> A[pooled by name, filtered: parse_functions_file, filter_functions, min_occurrences]
    A -->|none recurs| K0
    A --> M[run's model: SKILL_LIBRARY_PROMPT with the list, then the engine's rules]
    M -->|cut off, or none kept: once more| M
    M --> L[the reply's Python functions, as written, each kept if the template's check takes it with the others]
    L --> W[skill_library.py, check_spec]
    W -->|continual| V[run_agent on the validation trials]
    V --> B[finalize: the best validation mean, the starting library included]
    W -->|paper| Z[finalize: the library]
Loading

The pool is saved before the synthesis (a step stopped later keeps its trials) and a step's material read twice is pooled once. The curation request carries max_tokens 20,480 (cap-x sends none). A curation is tried once more when its call fails, its reply was cut off (finish_reason length, or a last block left open) or none of its functions is kept; a second failure fails the step and the library stays (in paper, finalize then says the library is empty and why). Python blocks may be ```python, ```py or bare; type hints stay as written (ASPIRE's runtime.py compiles a program with its own from __future__ import annotations, so the engine never evaluates one), and so do decorators, for the check to refuse; past 60,000 bytes the last function goes and the rest are checked again. With params.engine named (the four configs name the engine's sim.py and aspire_root), the engine's own validator, on the benchmark venv's Python in its sandbox, is asked about each library before it is kept, and the functions it refuses go (ASPIRE runs on Python 3.10 to 3.12, and the check, on Hermit's, cannot tell all that 3.10 refuses). A block inside a list item is read as Markdown reads it, the fence's indentation off its lines. A library that fails check_spec is put back; a validation run that failed (an agent or judge error) is run once more, and a library never scored is not selected.

The authors' implementation against this one

cap-x's robot code cannot be imported (its trial loop's modules import torch, SAM 3, Ray, Open3D and JAX at package import; capx/utils/launch_utils.py sets the process-wide multiprocessing start method on import; its client retries without end; the compile is a script outside the installed package), so it is not a dependency group: the pure functions the port calls are copied verbatim, pinned to acac62f, and the tests compare them with a checkout (CAPX_ROOT). Per component, the port follows: capx/envs/trial.py (_run_single_trial, _capture_initial_visual_feedback, _describe_initial_scene, _get_visual_differencing_feedback, _query_initial_code, _handle_multi_turn_step), capx/llm/client.py (query_model_ensemble, query_single_model_ensemble), scripts/skill_library_compilation/compile_skill_library.py (collect_all_functions, main). Every difference below is acceptable for this integration; none is left to close but the first evaluation.

Dimension CaP-Agent0 (the paper; cap-x at acac62f) This port Why
Robot environment CaP-Gym's LIBERO-PRO (FrankaLiberoEnv), cap-x's API classes and servers the cap-harness engine with LIBERO-Pro: its API, its SAM3, Contact-GraspNet, PyRoki and cuRobo services, each program in a bubblewrap sandbox forced by the task (the existing robot environment)
The API FrankaLiberoApiReducedSkillLibrary: the reduced low-level API and nine synthesized functions (numpy) the engine's API reference (its generated-program part) and the learned library, in cap-x's combined_doc format forced by the environment
Program rules any Python, numpy imported explicitly the engine's validator: only import math, no classes, with, global, nonlocal, del, async or _ names; the task prompt's last line says so instead of cap-x's numpy line forced; the one adapted line of the acting prompt
Initial state trial t is LIBERO's saved state t − 1 seed s is a sampled scene (--init-mode seeded) forced: the engine's saved mode fails at its pinned commit (NVlabs/ASPIRE#31); not comparable with Table 2
Turns one persistent episode, one exec per block a replay from the reset per turn, each block in its own try; a refused block left out forced: one program per episode
stdout / stderr the block's stdout and traceback the block's stdout (its last stdout_chars) and its exception as Name: message the engine gives a program no traceback
The loop's end "terminated episode" in stderr the episode's termination reason (task done, terminated, truncated, step limit) the engine reports it so
VDM frames env.render() after the reset and each turn the engine's agentview keyframes: the probe's first frame, each turn's last (a motion that raised, or that the step limit cut, recorded only its before- frame: the VDM then sees the scene from before it) the engine records keyframes around motions
Decision requests from the environment's own prompt: {libero_environment_goal} unformatted, no initial description the same by default (decision_prompt: upstream); initial starts them from the first request upstream's behaviour kept; the option is ours
The goal formatted into the whole first text into the task prompt alone the engine's API reference holds braces
Ensemble paper: three models × three temperatures; code: ENSEMBLE_CONFIGS gpt-5.4 × 0.1/0.5/0.9 8000 ; single-model: nine temperatures single (nine temperatures of the acting model, which also synthesizes) by default; multi with ensemble_models; candidates in their configured order a decision: one model on the first evaluation's row
VDM model Gemini-3-Pro (paper), gemini-3.1-pro-preview (code) vdm_model, default the acting model the first evaluation's row
Acting model the paper's models; temperature 1.0, 20,480 tokens, effort medium GLM 5.3 Flash with cap-x's defaults the first evaluation's row
Reasoning effort reasoning_effort sent to GPT models only (medium by default); other models get none effort medium sent to the run's model, GLM 5.3 Flash included, on every call (code, VDM, ensemble, curation) one setting for every call of the first evaluation's row
Failed requests retried without end the client's retries, then unserved_retries with pauses, then the trial fails (session_failed): an error row, which hermit eval counts in errors and as 0 in mean_score an outage must not stall a run
Score the trial's own task_completed the engine's judge: the final program once more on the seed; a rerun that ran no episode, or that refused the program the trial ran, is a judge error, not a 0 the existing environment's judge
Synthesis input the paper: successful S3 rollouts (the low-level API with usage examples) of 12 models on 7 Robosuite tasks; the code (is_reduced_api_experiment) and its shipped LIBERO library: the S3 and S4 experiments (_reduced_api, _reduced_api_exampleless) one acting model's successful trials on LIBERO's four suites: the single-turn, low-level tier on the engine's API reference, which has no usage examples (as S4; paper), or CaP-Agent0 (continual) the request: training on LIBERO-Pro; examples for the engine's API would be ours
Extraction each trial's summary.txt (code and log) each trial's annotated code alone a log's text is not code
Curation SKILL_LIBRARY_PROMPT to Gemini-3.1-Pro (no max_tokens); the released code stops at the curated text (the paper calls the pipeline automated) the prompt verbatim with the engine's rules after it (prompts.ENGINE_RULES), to the run's model with max_tokens 20,480; the reply's functions, as written, that the check takes become the library; a reply cut off or with none kept is tried once more the step from the text to a module is not in the code; an endpoint's default may cut the reply short
When learning happens one pass paper: once; continual: after every step continual is the added setting
Selection none paper: none; continual: best validation mean ours
Not ported — CaP-Bench, CaP-Gym, CaP-RL; video differencing, the wrist camera, images in the decision request (off in the CaP-Agent0 config); evolve_skill_library (nothing at acac62f reads it back); the web UI the request's scope; off upstream

The first evaluation's settings

Not run yet: this PR stays a draft until the row is here. The planned row, on the splits above:

Setting Value
Acting model GLM 5.3 Flash (fireworks/accounts/fireworks/models/glm-5p3-flash), effort medium, temperature 1.0, 20,480 tokens; also the VDM and the ensemble's synthesis
Learning model GLM 5.3 Flash, effort medium (the Evolver's curation calls)
Harness CapAgent0Actor on the cap-harness engine (ASPIRE fa00f0e), LIBERO-Pro, --init-mode seeded, 8,000 steps, at most 10 regenerations
Starting adapter the empty library
Data collect (paper) or train (continual) 200 trials, val 60 (continual), test 3,000 (test_sample 300 for a first look)
Evaluation eval --adapter final on the test split, one pass; the judge's success rate: mean_score with errors beside it (rows the agent or the judge failed, which mean_score counts as 0) and the rate over the scored rows
Baselines --adapter root (CaP-Agent0 without a library) and the single-turn tier (agent.params.multi_turn=false agent.params.vdm=false agent.params.ensemble=none), same model and trials
Budgets paper: $100 / 72 h; continual: $600 / 240 h (trainer.budget)

What the learner sees, and the boundaries

The Evolver reads only the learning material's successful trials' code (pipeline_extra.trial.code, which _annotate_code_blocks builds from the blocks the model wrote) and the judge's score on each trial's own seed, the label cap-x's task_completed is; in continual, also the validation trials' scores through run_agent. No prompt or task text carries a held-out seed, an answer or solution guidance: the task rows give a suite, a task id and a seed, and the actor's prompt is cap-x's with the engine's API reference (its generated-program part; the host-only part is cut). Test seeds (1-50) are never run before eval; validation seed 66 only by the Evolver. Learned code and the model's code run only inside the engine's sandbox. The judge runs on the host and reruns the final program in a cap-harness sandbox of its own; there the program runs inside cap-harness's own process (ASPIRE's design), so one that escaped ASPIRE's validator could write its own run's outcome: that score would not be trustworthy, and the sandbox keeps it from any other run, the judge's process and the host (the engine's README); the judge wrapper's clean-up of the rerun's images follows no link the program could leave in its output. The validation trials are the test's 60 tasks on a seed of their own (66): continual selects on the perturbations it is tested on, never on a test trial, and the Evolver sees only their scores; taking the best of several means, its test score is optimistic beside paper's one library.

What is left out

CaP-Bench, CaP-Gym and CaP-RL (the request's scope); the paper's twelve-model collection on CaP-Bench's Robosuite tasks
(one acting model on LIBERO's own suites instead); video differencing, the wrist camera and images in the decision
request (off in cap-x's CaP-Agent0 config); evolve_skill_library, cap-x's online recording of successful functions
(nothing at acac62f reads it back into a prompt); cap-x's web UI. A Robosuite example would be the same rows on
examples/robosuite/; it is not added.

Limits that stay (the audit's design questions): one validation trial that fails twice leaves its library unscored; a paper run stopped before the epoch's end has no library yet (a resume continues it); a trial has no wall-clock limit of its own (its bounds are under "What a task asks"); a provider outage inside an episode looks like a program error to the actor and the judge alike (the engine defines provider_error but never produces it). A trial keeps its initial frame and each turn's last (up to twelve) in its log; paper.yaml and continual.yaml set agent.params.keep_images: false, which removes them when the trial ends (the smokes keep them). Type hints reach the acting model as written (-> np.ndarray in an engine without numpy), as cap-x's combined_doc shows them. The same module-load race fixed here in actor.py exists on main in hermit/agent/evolver/methods/aspire/direct.py (engine_module); it is main's own and not changed here.

Application-side changes

All under examples/libero/cap_agent0/ (rows, configs, the judge wrapper that runs the engine's judge unchanged and prunes the images of each run its rerun recorded: a test split is 3,000 episodes) and examples/libero/.gitignore (the generated tasks/, splits/). No shared framework code changes; tests/selection.py is the registration every method adds. The index files (docs/methods/index.md, docs/index.md, CHANGELOG.md, examples/libero/README.md, examples/libero/.gitignore, tests/selection.py, tests/README.md, tests/core/test_selection.py) are the ones the open drafts #133, #134 and #135 also add rows to: whichever lands later rebases.

Validation

Run on this branch (Linux, bubblewrap working; TMPDIR on /home):

  • python -m pytest tests/methods/cap_agent0 → 64 passed at 0b8ec1b, with CAPX_ROOT (a cap-x checkout at acac62f) and ASPIRE_ROOT (ASPIRE's src/cap_harness/{runtime,api}.py and libero/adapter.py at fa00f0e) set, so the five parity tests ran: the vendored functions' ASTs equal cap-x's, LICENSE equals cap-x's, every prompt text is cap-x's but the one adapted line, the reader's text equals cap-x's own combined_doc, and the check's names and rules equal ASPIRE's (_SAFE_BUILTINS, _SAFE_CONSTRUCTORS, _ProgramValidator, register_tools), with both validators agreeing on a corpus that includes the actor's wrapped programs, and the check's compile is runtime.py's (compile(tree, ...) under its annotations future). Without the two variables those five skip (59 passed, 5 skipped).
    • The actor's trials run through the engine's real code (sim.Engine, its sandbox) on a stand-in cap-harness that executes each program as ASPIRE's ProgramExecutor does and records keyframes; the model is scripted. The Evolver runs with a scripted model and run_agent, and once through the Trainer on a toy task (train, validation selection, evaluate final 1.0 vs root 0.5).
    • rows.py against the benchmark's real prepare.py output; every config through Config.load and Benchmark.from_config.
  • The whole suite (pytest --changed selects every group: a new template's adapter.yaml is shared), in four parallel
    chunks: 1,854 passed, 181 skipped, 9 failed. One failure was this PR's: tests/core/test_selection.py listed the
    groups the engine's and LIBERO's shared files select, which now include cap_agent0; its expectation is updated
    and it passes. The other eight are this machine's, and none touches a file this PR changes:
    • tests/core/test_harbor_environment.py::test_rrsi_sees_a_harbor_rollouts_failure_and_a_cli_model_is_refused_for_harbor
      and tests/methods/harness2/test_harness2_on_pi.py::test_what_a_pi_session_spent_is_kept_when_it_times_out_or_is_stopped
      (2 cases): the rrsi and harness2 dependency groups are not installed here (ModuleNotFoundError; CI installs both).
    • tests/core/test_sandbox.py::test_inside_the_sandbox_an_installed_hermit_is_covered_but_the_relay_runs: the chunk ran
      the interpreter by a path with .., which bubblewrap cannot exec; it passes run by the absolute path.
    • tests/core/test_sandbox.py::test_a_linked_venv_runs_by_its_own_name_with_its_own_packages: this interpreter's base
      installation is under miniforge3/envs/, which the test's "env" in check matches.
    • examples/clbench_database/utils/tests/test_parity_golden.py (3): they compare with a local MetaWorld checkout that
      differs from their golden files.
  • After the first commit's last edits, rerun: tests/methods/cap_agent0, tests/core/test_selection.py,
    test_packaging.py, test_spec.py, test_isolate.py, test_harbor_environment.py (all passed but the rrsi case above).
  • CI on the first commit (ffb24ce): pytest --changed selected every group: 2,045 passed, 136 skipped, 0 failed; the four parity tests skip there (no checkouts), and the eight failures above pass or skip there. On the second (061e22e): 2,051 passed, 136 skipped, 0 failed. On the third (2b60663): 2,049 passed, 136 skipped, 0 failed (the two withdrawn check cases fewer). On the fourth (1cac6fd): 2,054 passed, 136 skipped, 0 failed (the five new tests and cases more). On the fifth (0b8ec1b): 2,058 passed, 137 skipped, 0 failed (the new compile parity test skips there: no ASPIRE checkout).
  • The second commit (round 1's fixes, 061e22e): tests/methods/cap_agent0 with test_selection.py, test_packaging.py and test_spec.py → 83 passed. The third (round 2's, 2b60663): the same four → 81 passed (two check cases of the withdrawn hint rule removed). The fourth (round 3's, 1cac6fd): → 86 passed. The fifth (round 4's, 0b8ec1b): → 91 passed; the docs build, ruff --select F and hermit check on the four configs again, the same results each time.
  • bash docs/build.sh (Sphinx -W) → builds with no warnings.
  • ruff check --select F on the new files → only two names in cap-x's annotations, in the verbatim copies (np.ndarray,
    TrialData), which from __future__ import annotations leaves unevaluated (noted in upstream/__init__.py).
  • hermit check --no-probe on paper.yaml, continual.yaml, smoke_paper.yaml, smoke_continual.yaml (rows generated by tasks.sh's command) → all [ok]; the warnings are the expected ones (environment.runner: host; validation data given to the Evolver).

Not run yet: the smoke and the first evaluation on the simulator. They need an ASPIRE checkout at fa00f0e with .venv-libero and its four provider services on a GPU host; this machine has neither (its provider ports are another project's). Commands: ASPIRE_CONFIG=smoke_paper.yaml ./launch.sh, then eval --adapter final; ASPIRE_CONFIG=smoke_continual.yaml ./launch.sh (examples/libero/cap_agent0/README.md). The first evaluation's row (GLM 5.3 Flash acting, describing and curating, effort medium; the empty library as the start; the 3,000 test trials, one pass; baselines --adapter root and the single-turn tier) goes into this description before it leaves draft.

Review

  • Tests and documentation cover the affected behavior, where applicable. — Validation above; docs listed under Change.

  • Commands, defaults, and public interfaces are consistent. — the configs' params are the actor's defaults (cap-x's: temperature 1.0, 20,480 tokens, effort medium, 10 regenerations, 8,000 steps); evolver.yaml is included in the method page.

  • Agents follow the agent layers. — CapAgent0Actor is an acting agent (Layer 3) whose every model call (code, VDM, ensemble candidates and synthesis) is one Direct call (Layer 1) over the framework's ChatClient (resolve/registry for the spec, its retries); it declares supports = ("context", "context_tool"), and the Evolver needs: [llm, context_tool] and calls only ctx.agent through ask (metered, cancellable). It is not a copy of a loop of a core agent: the loop is cap-x's trial, which no core agent has. Where it runs is the run's environment (environment.runner: host), because the engine starts the GPU simulator; every program runs confined by the engine (sim.confine), as ASPIRE's direct actor does.

  • Shared logs and examples contain no credentials or private data. — the configs name FIREWORKS_API_KEY only as a variable; the engine scrubs secrets from the simulator's environment.

  • Documentation-only: not applicable (this PR changes code).

  • Core changes. None to shared code: tests/selection.py (METHODS), tests/core/test_selection.py (its expected groups) and the docs' index rows are the registration the guide requires.

  • Implementation correctness and failures. A failed model call past the retries, an engine that ran no episode, or a lost sign-in: the trial is session_failed (an error row: hermit eval counts it in errors and as 0 in mean_score; the Evolver neither pools it nor counts it in validation) and keeps what it spent; a lost sign-in stops the run (login_failure). The judge's rerun that ran no episode, or that refused the program the trial ran, is a judge_error row, the same way. Concurrent trials wait for the engine module's one load (engine_module's lock), and a failed load is not kept. A curation cut off or with nothing kept is tried once more, then fails the step. A block that cannot compile or that the engine refuses is a block error, not a failed trial. The Evolver's misconfiguration (no llm, an unknown setting or select, continual without data.val) stops in setup and again in step; a budget stop is recorded and re-raised.

  • Real execution paths and tests. The actor runs through the engine's own Engine.run / validate / program_result in its sandbox and the template's real context tool (Session); the Evolver through the Trainer and evaluate; the stand-ins are the simulator CLI (from ASPIRE's run.py / runtime.py behaviour) and the model.

  • Documentation. Listed under Change.

  • Adapter template. New: cap-agent0@1.0. prompt-only and ace are text the agent reads, aspire's library is Markdown entries, and none runs its content as code before the agent's own. Learnable: skill_library.py; fixed: exports.yaml, interface.py, README.md, .hermit/. What reaches the agent: the reader's text (in the prompt, after the API reference) and source (before every program); the check refuses what would stop every program, compiling the library as the engine does (as Python 3.10, ASPIRE's oldest, so far as Hermit's parser tells), and the Evolver asks the engine's own validator, on the benchmark venv's Python, about each library before it keeps it.

  • Evolver. New: cap_agent0; flow chart above.

  • Upstream fidelity and adaptations. The comparison table above.

  • Learning information and evaluation boundaries. Above.

  • Sandbox control. sandbox: {enabled: true, enforce: required} in every config; web_search does not apply (no call goes through a CLI: every call is a chat completion with no tools); the learning material holds trial code and scores, no key values; the actor on the host (the GPU simulator), each program and the judge's reruns confined by the engine's bubblewrap sandbox, whose network reaches only the providers' services; the Evolver's model calls are Direct calls (no process); the template's check runs in check_spec's sandbox. No launch record yet: there has been no run (pending with the smoke).

  • Experiments. Pending: the smoke and the first evaluation (above).

  • Agent three-layer abstraction. Model: Direct over ChatClient for every call; Base Agent: none (no CLI session); Acting: CapAgent0Actor; Evolver: cap_agent0 with ctx.agent. Timeouts: the client's request timeout and retries, the engine's run_timeout_s per episode, the Trainer's call_timeout_min per step; cancellation: the Evolver checks ctx.cancel before each curation attempt and each validation run; usage: each trial's tokens and cost into RunOutput (unknown when a call is unpriced), the Evolver's through ask.

  • Group and selection. tests/methods/cap_agent0/ is group
    cap_agent0 (tests/selection.py: the method, the template and examples/*/cap_agent0/*);
    select() gives cap_agent0 for actor.py, interface.py, rows.py and the test file, and the engine's and LIBERO's
    shared files select it too (tests/core/test_selection.py). No new helper or fixture directory: the stand-ins are in
    the test file, which loads the engine's examples/cap_harness/utils/tests/cap_fakes.py.

  • Names. Every test is a sentence (test_a_block_that_cannot_compile_or_that_only_the_engines_run_refuses_is_left_out).

  • Docstrings. The file opens with what it covers and its stand-ins (the stand-in ASPIRE checkout, the scripted
    models); a test whose name cannot carry it says why (the replay check, the compile refusal, the pool on a re-read).

  • What it asserts. Records a caller reads: trial.json's turns (stderr, replay_matches), RunOutput
    (output, extra.session_failed, cost, tokens), the Evolver's state.json, skill_library.py, the StepResult, the
    Trainer's evaluate means. Regressions checked by reverting each fix: with the replay check as before, the collection
    test fails (assert (False is None)); with blocks only parsed, the compile test fails on its stderr; with the template
    check one directory too shallow, the file fails to import. Round 1's fixes, each file put back to ffb24ce: the
    load test fails with AttributeError: module ... has no attribute 'Engine', the reference test with the trial going
    on to its first episode, the judge test with no error raised, the curation test with an empty library called done.
    Round 2's, each file put back to 061e22e: the judge test fails with the rerun's media/ still there, the
    assembly test with List, np refused (the check) or no HINTABLE (the Evolver), the collection test with
    images/ kept. Round 3's, each file put back to 2b60663: the link test fails with the folders the links named
    emptied of media/, the crash test with a lost run's media/ left, the three new check cases with nothing
    refused, the library test with the trial going on to its first episode, the assembly test with the decorator
    dropped (and, run alone, the cap's helper's caller kept). Round 4's, each file put back to 1cac6fd: the
    list-item test fails with nothing found, the two engine-validator tests with the refused function kept (no
    refuse, no engine read), the curation test with no block named, the match test with a, b unknown names. Error
    text is matched where it is the contract (the engine's program rejected: ..., the model's stderr).

  • Real entry points and stand-ins. Config.load, Benchmark.from_config, the Trainer and evaluate, the
    template's context tool through Session, the engine's sim.Engine (validate, run, program_result) in its
    bubblewrap sandbox; stand-ins only at the edge: the model (CapAgent0Actor.direct scripted) and the simulator CLI, a
    run-batch that executes each program as ASPIRE's ProgramExecutor at fa00f0e does (its validator, one namespace,
    stdout redirected) and writes its files (results.jsonl, outcome.json, source/program-result.json, keyframes).

  • Isolation. Files only under ~/.cache/hermit-tests (the engine's fixture, removed after the test; the sandboxes'
    /tmp is empty); no network, no sign-in, no installed CLI. Skips with reasons: without bubblewrap (needs_bwrap),
    and the five parity tests without CAPX_ROOT / ASPIRE_ROOT.

  • Time and order. No timestamps; the retry pauses are recorded through a patched time.sleep, not waited; no
    state shared between tests.

  • Cost. --durations: the group is 64 tests in under two minutes here (load average ~100); the slowest are the
    bubblewrap trials and judge runs (up to ~30 s under that load) and the template checks (~10 s). The Trainer runs once.

  • Hygiene. No unused imports (ruff --select F: Validation); nothing from conftest; the engine's runs end with
    their test, and the directories go with the fixture.

  • Reuse the framework's sandbox. Processes this change starts: each program (probe, turns, the judge's rerun) and
    each validator check runs through the engine's sim.confine, which is hermit.sandbox.Sandbox (the network only to the
    providers' services: their loopback ports forwarded, a remote one through the allowlist proxy; ASPIRE's checkout
    read-only less its hidden paths; writable only the run's storage); the template's check runs in
    check_spec's sandbox. The actor itself runs in the Trainer's process (environment.runner: host, as ASPIRE's
    direct actor does): it is trusted code that starts the GPU simulator and runs no adapter code itself; the library's
    code runs only inside the confined programs. The judge on the host reads the rerun's verdict. Launch records: none
    yet (no run); a run writes one per sandbox under $ASPIRE_OUT/sandbox/ (the engine's record_dir, as for ASPIRE's
    direct actor), linked here with the smoke.

  • Sandbox changes are core changes. No change to the sandbox.

  • Task directories. The rows are task directories written by the engine's tasks.write_task
    (hermit.task.directory.write_task), one per trial; no new row format.

  • Public and private halves. A row holds benchmark, suite, task_id, seed, eval_seeds, score_label,
    role (and multi_turn, vdm, ensemble on collection rows); the view is the engine's fields.py:task_row (the
    metadata as the row), no answer or verifier. The judge's feedback the learner sees is the success score on the
    trial's own seed; continual also sees validation means, not their trials.

  • What a task asks. network_mode: no-network (the engine's write_task); the actor runs on the host, so the
    task sandbox's network and memory checks do not apply; the programs' sandbox reaches only the providers' services. Effective timeouts: no agent.timeout_min; each engine run run_timeout_s 3,600 s and 8,000 steps, a trial at
    most a probe and 11 turns, each model request the client's timeout and retries (then unserved_retries 3 with
    pauses); a step trainer.call_timeout_min 60 (paper: one curation, at most two calls) / 1,440 (continual: its sixty validation trials, and at step 1 the starting library's sixty too).

  • Parity, for a moved benchmark. Not applicable: no benchmark is moved.

  • A real run. Pending: the smoke (Validation).

  • This description. Read end to end against the code at 0b8ec1b.

  • Independent review (post-PR audit). Round 1: an Opus 5.5 agent at max effort, a separate session in its own
    worktree, on ffb24ce against the general, method, test, sandbox and benchmark checklists (code, callers, tests,
    configs, cap-x at acac62f, ASPIRE at fa00f0e, the paper; no model calls, no simulator). No P1. Three P2, all
    fixed in the second commit (061e22e):

    • concurrent trials took the engine's module while it still loaded (no Engine): the first trials of every
      process with agent.concurrency 4 were lost as errors; now a lock, and a failed load is not kept;
    • the engine's judge scored a rerun that ran no episode as a real 0 with status ok (a success dropped from the
      paper pool, a validation 0 not rerun); now a judge error;
    • a curation reply cut off (no max_tokens sent) or with nothing kept became an empty library in a step called
      done (in paper the final adapter would equal the root); now tried once more, then the step fails, with
      max_tokens sent and bare fences read (a type-hint rule added with it was withdrawn in round 2).

    Six P3, all addressed: step 1 of continual validates two libraries (timeout raised to 1,440 min); three claims
    of this description corrected (an error row is 0 in mean_score; the judge's rerun runs the program in
    cap-harness's own process, disclosed above; the timeout); the collection's tier is nearer S4 than S3 (said so
    everywhere); the API reference without its host-only heading now fails the trial instead of passing whole; the
    VDM's frame after a motion that raised is documented; the reasoning_effort difference is in the table. Design
    questions that stay are listed under "What is left out". Not verified by the audit: anything needing the
    simulator, the endpoint's default max_tokens, the whole suite's local breakdown.

    Round 2: the same, on 061e22e (both commits, the fixes in particular). No P1. Two P2, both fixed in the third
    commit (2b60663):

    • the judge wrapper removed runs/*/media, one level short of ASPIRE's run layout (<output-root>/<seed:04d>/<run-id>/,
      artifacts.py RunRecorder), so no rerun's keyframes were ever removed (tens of gigabytes a test split); the
      test's stand-in wrote the same wrong layout. Now each run directory the rerun's stage2.json records loses its
      media/ (the engine keeps only run directories inside the rerun's output), and the stand-in writes ASPIRE's
      layout;
    • round 1's type-hint rule rested on a false premise: ASPIRE's runtime.py has from __future__ import annotations
      and compiles a program without dont_inherit, so a program never evaluates a hint (reproduced with ASPIRE's own
      ProgramExecutor). The check refused libraries the engine runs, and the assembly stripped hints and reprinted
      the function (its comments gone). The rule, the removal and the prompt's sentence are withdrawn; the check reads
      no names in hints; the actor's compile check and the stand-ins compile with that flag.

    Round 1's three fixes hold (each re-checked). Three P3, all addressed: the synthesis input is S3 by the paper but
    S3 and S4 in cap-x's compile and its shipped LIBERO library (said so); "by hand" was unsupported (the released
    code stops at the curated text); smoke_paper.yaml's step comment, rows.py's sample-seed message, CI on
    061e22e. Added with the fix: keep_images (above). Not verified: anything needing the simulator or a GPU (real
    keyframe sizes, program-result.json's real shape), whether GLM's reasoning counts against max_tokens.

    Round 3: the same, on 2b60663. One P1 and one P2, both fixed in the fourth commit (1cac6fd):

    • P1: the judge wrapper's clean-up could follow a link out of the rerun's folder. A confined program can write
      links in its output; the engine removes them after the run, and when that removal fails (a run tree past the
      path limit) the judge raises before stage2.json is written, and the clean-up globbed runs/*/* through the
      links (reproduced: the folders a link named lost their media/); a stale stage2.json was trusted as is. It
      needs a program that escaped ASPIRE's validator. Now no link is followed and only a real media/ inside the
      rerun's folder goes, from the run folders and the records alike (a run ASPIRE lost, a folder with no record,
      loses its images too);
    • P2: nothing compiled the library: the check and the engine's validator only parse, so a function with an error
      only compiling finds (break outside a loop, a repeated keyword argument, a duplicate parameter) passed
      check_spec and stopped every program (in paper, every test trial an error row). The check now compiles each
      function and the library as the engine does, parsing as Python 3.10 (ASPIRE's requires-python is 3.10 to
      3.12; the parser tells except* and type parameters, not 3.12's f-string quoting), and the actor compiles the
      library before a trial.

    Round 2's fixes hold (re-checked). The P3s, all addressed: a curated function's decorators were dropped silently
    (now kept, so the check refuses it); the 60,000-byte cap could cut a function another calls (the rest are now
    checked again); the stand-in's lost runs wrote no images (now a frame, so the judge test checks they go); the test
    count and keep_images's wording. Of the design questions, keep_images is now false in paper.yaml and
    continual.yaml; the hints the acting model reads are under "What is left out".

    Round 4: the same, on 1cac6fd (a first attempt stopped on an authentication error and was run again). No P1.
    Two P2, both fixed in the fifth commit (0b8ec1b):

    • the check runs on Hermit's Python (3.12 or newer), and ASPIRE's venv may be 3.10 or 3.11 (its requires-python;
      bootstrap_libero.sh builds the venv from the host's python3): a 3.12 f-string that reuses its quote or holds
      a backslash, or a[*b], passes feature_version=(3, 10) (checked on real 3.10.20 and 3.11.13 parsers), so such
      a library passed the check and every trial refused it (in paper, every test row an error). Now the Evolver,
      with params.engine named, asks the engine's own validator, on the benchmark venv's Python in its sandbox,
      about each library; the functions it refuses go and the rest are checked again;
    • a curation reply that put its blocks inside list items gave no function: each block kept the list's
      indentation and failed to parse, and the failure named no block. Now a fence's indentation comes off its lines,
      as Markdown takes it, and a reply that gave nothing names the blocks that did not parse.

    Round 3's fixes hold (the clean-up tried again with more link layouts; the compile matches ASPIRE's on one
    Python). The P3s, addressed: the names a match pattern captures are bound in the check; a test pins the check's
    compile to ASPIRE's (runtime.py's compile(tree, ...) and its annotations future); the body's CI line.

    Round 5: the same, on 0b8ec1b. No P1 and no P2; round 4's fixes hold (the engine check run end to end with the
    real validate in bubblewrap and a Python 3.11 parser as the venv's: the f-string function dropped, the rest
    kept). Five P3 are open: the Evolver counts a validator that could not run (a broken venv) as a refusal of every
    function, and a refusal no single function reproduces drops them all (the actor's block check shares the first);
    code at column 0 under an indented fence, which the reading before 0b8ec1b took, no longer parses; aspire_root: ~/... resolves under the config directory in the Evolver (the actor expands ~), and a wrong engine or
    aspire_root shows only at the first synthesis; the method page's setup snippet leaves out engine and
    aspire_root, docs/methods/index.md says one curation call (up to two), and the grammar Hermit's parser cannot
    tell also takes in *args: *Ts and comments or newlines inside f-string expressions; the Evolver's engine test
    replaces sim.Engine whole.

iamziyuzhao and others added 5 commits November 29, 2026 01:47
…ample

CaP-Agent0 (CaP-X, arXiv:2603.22435; capgym/cap-x at acac62f) on the
cap-harness engine:

- the cap-agent0@1.0 template: the skill library (skill_library.py), its
  reader (the context tool: cap-x's combined_doc text and the code) and a
  check against the engine's program rules;
- CapAgent0Actor: one trial of cap-x's trial loop, every model call one
  Direct call; the multi-turn loop replayed from the reset with each
  block in its own try, the Visual Differencing Module on the engine's
  keyframes, the parallel ensemble and its synthesis;
- the cap_agent0 Evolver: cap-x's library compile (functions.txt per
  experiment, pooled, filtered, curated with SKILL_LIBRARY_PROMPT);
  setting paper synthesizes once at the epoch's end over the collection
  rollouts (the single-turn tier), setting continual (ours) after every
  step, keeping the best validation library.

cap-x's pure functions and prompt texts are copied verbatim (upstream/,
MIT), with tests that compare them with a cap-x checkout (CAPX_ROOT) and
the check's rules with ASPIRE's (ASPIRE_ROOT).

examples/libero/cap_agent0/: one task row per trial on LIBERO-Pro
(rows.py; collect and train on the four LIBERO suites, seeds 51-55; val
on the six test suites, seed 66; test on Table 2's six LIBERO-Pro suites,
seeds 1-50), paper.yaml, continual.yaml, their smoke configs and a judge
that prunes each scored run's images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- actor.py: concurrent trials wait for the engine module's one load (a
  module taken from sys.modules while it still ran had no Engine, so the
  first trials of every process were lost as errors), and a load that
  fails is not kept; the API reference is cut at its host-only heading,
  or the trial fails before its first run, never passed whole.
- examples/libero/cap_agent0/judge.py: a rerun that ran no episode, or a
  refusal of the program the trial ran, raises (a judge error) instead
  of the engine judge's 0 with status ok, which dropped a success from
  the paper setting's pool and counted a validation run as a real 0.
- evolver.py: a curation whose reply was cut off (finish_reason length,
  or a last block left open) or of which no function is kept is tried
  once more, then the step fails and the library stays; max_tokens is
  20,480 (cap-x sends none); bare fences are read; type hints that would
  not evaluate when the library is defined are removed, and the
  template's check refuses them; finalize says what the library holds.
- continual.yaml: call_timeout_min 1440 (step 1 validates two libraries).
- docs: the collection's tier is nearer S4 than S3 (the engine's API
  reference has no usage examples); the effort difference; a program
  runs in cap-harness's own process at judging; error rows count 0 in
  mean_score; the VDM's frame after a motion that raised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- examples/libero/cap_agent0/judge.py: each rerun's images are removed
  by the run directories its stage2.json records. The pattern before
  (runs/*/media) was one level short of ASPIRE's layout
  (<output-root>/<seed:04d>/<run-id>/), so no keyframes were removed;
  the test's stand-in run-batch now writes that layout.
- The type-hint rule is withdrawn: ASPIRE's runtime.py compiles a
  program with its own `from __future__ import annotations`, so the
  engine never evaluates a hint. The template's check ignores names in
  hints, the Evolver keeps each function as written (no hint removal,
  no reprint), and the engine rules no longer ask for it; the actor's
  compile check and the test stand-ins compile with that flag.
- actor.py: keep_images (default true); false removes a trial's VDM
  frames when it ends.
- Texts: the synthesis input is S3 by the paper and S3 + S4 in cap-x's
  compile; the released code stops at the curated text (not "by
  hand"); smoke_paper.yaml's step comment; rows.py's sample-seed
  message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- examples/libero/cap_agent0/judge.py: the prune follows no link and
  removes only a real media/ inside the rerun's own folder. With no
  stage2.json (the engine's removal of a program's links had failed and
  the judge raised) it globbed runs/*/* through any link a program left
  there, and a stale stage2.json was trusted as is. It now also removes
  the images of a run ASPIRE lost (a folder with no record).
- The template's check compiles each function and the library as the
  engine does (with `from __future__ import annotations`), parsing as
  Python 3.10, ASPIRE's oldest: `break` outside a loop, a repeated
  keyword argument and the like passed the check and stopped every
  program. The actor compiles the library before a trial too.
- evolver.py: a curated function keeps its decorators, for the check to
  refuse (they were dropped silently); past the 60,000-byte cap the
  rest are checked again, so a caller of a function cut goes too.
- paper.yaml and continual.yaml: keep_images false (a test split is
  thousands of trials). The stand-in's lost runs keep a frame, so the
  judge test checks that their images go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- evolver.py: with params.engine named (the four configs name the
  engine's sim.py and aspire_root), each library is checked by the
  engine's own validator, on the benchmark venv's Python in its
  sandbox, before it is kept; the functions it refuses go and the rest
  are checked again. The template's check runs on Hermit's Python, and
  ASPIRE's venv may be 3.10 or 3.11, whose parser refuses a 3.12
  f-string that reuses its quote or holds a backslash, and a[*b]: such
  a library passed the check and every trial refused it.
- evolver.py: a fenced block inside a list item loses the fence's
  indentation, as Markdown reads it (each such block failed as an
  unexpected indent and the step kept nothing); a reply that gave no
  function names the blocks that did not parse.
- The template's check binds the names a match pattern captures.
- tests: the check's compile is pinned to ASPIRE's runtime.py.

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

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0