Python
updates
rux0012152977a21c4
diff --git a/README.md b/README.mdindex 1ea8eec..4a902af 100644--- a/README.md+++ b/README.md@@ -1,37 +1,69 @@+<h3 align="center">+ <img src="assets/Harness2-wordmark.png" alt="Harness²" width="360"><br>+ Recursive Agent Harnessing for an Open World+</h3>+<p align="center">- <img src="assets/logo.png" alt="Harness² logo" width="128"><br>- <img src="assets/Harness2-wordmark.png" alt="Harness²" width="500">+ <a href="https://arxiv.org/abs/TODO"><img src="https://img.shields.io/badge/Paper-arXiv-EA4335?logo=arxiv&logoColor=white" alt="Paper"></a>+ <a href="https://harness2.github.io"><img src="https://img.shields.io/badge/Website-harness2.github.io-4285F4?logo=googlechrome&logoColor=white" alt="Website"></a>+ <a href="docs/BENCHMARKS.md"><img src="https://img.shields.io/badge/Docs-Benchmark%20guides-FBBC04" alt="Benchmark guides"></a>+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-34A853" alt="License"></a></p>-<p align="center"><strong>Recursive Agent Harnessing for an Open World</strong></p>+<p align="center">- <a href="#install">Install</a> ·- <a href="#run-a-benchmark">Run a benchmark</a> ·- <a href="docs/BENCHMARKS.md">Benchmark guides</a> ·- <a href="#experiments">Experiments</a> ·- <a href="#web-access">Web access</a>+ <a href="docs/BENCHMARKS.md#jobbench">+ <img src="assets/harness2-setup.gif" alt="Install, set up, and run JobBench: uv pip install -e '.[render]', harness2-setup jb, then harness2 --bench jb --k 1 --mode parallel. Click for prerequisites and commands." width="640">+ </a></p>-Official code for **Harness²: Recursive Agent Harnessing for an Open World**.+A **harness** is the system around a model that enables it to act as an agent:+prompts, tools, memory, skills, orchestration, and more. **Harnessing** is the+process of optimizing that system.++Harness² is a plug-and-play framework for **recursive agent harnessing** in an+open world, where agents encounter tasks unseen during harness design. It+connects two levels of recursion while keeping model weights fixed:-Harness² keeps model weights fixed and improves two harnesses. **Task-level-recursion** refines the execution harness through **Propose–Probe–Compose**:-edit general procedures and domain knowledge, execute the candidates, and-compose a successor from their behavioral contrasts. **Harnessing-level-recursion** updates the improvement harness after each task, retaining adopted-harness files and supported lessons in a per-domain library.+* **Task-level recursion** refines the execution harness for the current task+ through a contrastive **Propose–Probe–Compose** step: propose edits, probe+ their effects on the same task, and compose a refined harness from behavioral+ contrasts between executions, without ground-truth feedback.+* **Harnessing-level recursion** updates a persistent *improvement harness*+ with adopted harnesses and evidence-supported lessons from each task to guide+ future refinement.<p align="center"><a href="assets/harness2_pipeline.png">- <img src="assets/harness2_pipeline.png" alt="Harness² pipeline: task-level recursion proposes, probes, and composes execution harnesses; harnessing-level recursion retains harnesses and lessons for subsequent tasks." width="100%">+ <img src="assets/harness2_pipeline.png" alt="Harness² pipeline. Task-level recursion: an agent executor runs the initial harness, a harness editor proposes invariant and domain edits, candidate probes execute them, and a harness composer combines them into the final harness. Harnessing-level recursion: an experience reflector reflects on the step and updates the improvement harness used for the next task." width="100%"></a></p>-<p align="center"><em>Improve the executor on the current task; learn how to improve across tasks.</em></p>-The pipeline supports **parallel and sequential recursion**, **OpenCode and-Codex executors**, and **JobBench, LAB, and WorkBuddy-Bench**. Improvement uses-task instructions, trajectories, and deliverables. Reference answers and grader-scores stay out of improvement and selection. The judging command reports the-adopted output; WorkBuddy also runs its verifier inside each execution.+Across three professional benchmarks and four model–harness configurations, a+single Harness² step improves GLM-5 and Gemini 3.5 Flash over their base+harnesses, with gains of up to 11.5 points on WorkBuddy-Bench, 4.5 points on+JobBench, and 11.8 percentage points on LAB's partial pass rate. Increasing the+task-level recursion budget brings further gains.++The release supports **parallel and sequential recursion**, **OpenCode and+Codex executors**, and **JobBench, LAB, and WorkBuddy-Bench**.++## Video overview++https://github.com/user-attachments/assets/76b10548-b14b-4c8f-9aa5-a93662df4d56++## Contents++- [Video overview](#video-overview)+- [Harness components](#harness-components)+- [Install](#install)+- [Run a benchmark](#run-a-benchmark)+- [Experiments](#experiments)+- [Web access](#web-access)+- [Results and resume](#results-and-resume)+- [Citation](#citation)+- [Contributing](#contributing)+- [License](#license)+- [Disclaimer](#disclaimer)## Harness components@@ -45,139 +77,54 @@ inside the tool loop.<img src="assets/components.png" alt="Eight harness components grouped by runtime role: system prompt, guardrails, memory, and skills construct context; tool guidance and scripts define the tool interface; subagents orchestrate delegated work; plugins control middleware." width="100%"></a></p>-<p align="center"><em>The eight harness components and where they act during execution.</em></p>## Install-Use **Linux and Python 3.12**; the Python package also supports 3.13. On-Debian/Ubuntu:--```bash-sudo apt-get update-sudo apt-get install -y git curl unzip ca-certificates pandoc poppler-utils-```--Pandoc and Poppler are needed by LAB. Also install-[Node.js](https://nodejs.org/en/download) 20 or newer,-[uv](https://docs.astral.sh/uv/getting-started/installation/), and the-[Google Cloud CLI](https://cloud.google.com/sdk/docs/install). WorkBuddy needs-[Docker Engine](https://docs.docker.com/engine/install/) and an account that can-run `docker info`. Benchmark setup installs its own pinned Bun runtime under-`dependencies/`.--Run every command from the `harness2` directory:+Use **Linux, Python 3.12, and [uv](https://docs.astral.sh/uv/getting-started/installation/)**.+From the repository root:```bashuv venv --python 3.12 .venvsource .venv/bin/activateuv pip install -e '.[render]'harness2-demo --output runs/demo --k 2-cp .env.example .env```-The demo runs both recursion modes across two local tasks with deterministic-editors and real Python executions, and needs no model credentials. Repeat it to-verify resume.--A wheel ships the `harness2` package only, so the task partitioner, invoked as-`python scripts/split_tasks.py`, needs this source tree. For a wheel installation, work from a dedicated directory:-`.env`, `dependencies/`, and `runs/` are resolved there.+The local demo runs both recursion modes with deterministic editors and real+Python executions. It requires no model credentials.-### Models and credentials--Edit `.env` with your Vertex AI project and the model IDs available to your-account, then authenticate:+For model-backed benchmarks, install **Node.js 20+, the Google Cloud CLI**, and+the [benchmark dependencies](docs/SETUP.md#requirements). LAB needs Pandoc and+Poppler; WorkBuddy-Bench needs Docker. Then configure your models:```bash+cp .env.example .env+# Edit .env with your Vertex AI project and model IDs.gcloud auth application-default login```-A machine with an attached service account needs no further step. Without a-browser, use `gcloud auth application-default login --no-browser`, which prints a-command to run on a machine that has one; or `GOOGLE_APPLICATION_CREDENTIALS`-pointing at a service account key file; or-`gcloud auth application-default login --impersonate-service-account=<account>`.-`gcloud` must be on `PATH` in every case, including the key-file route, because-the installation check runs `gcloud auth application-default print-access-token`.--The shell takes precedence over `.env`. `GOOGLE_CLOUD_PROJECT` identifies your-project; `GOOGLE_CLOUD_LOCATION` defaults to `global`. Account access to each-configured model is required.--| Setting | Meaning |-|---|---|-| `HARNESS2_SOLVER_MODEL` | Executor model in OpenCode's `provider/model` format |-| `HARNESS2_IMPROVER_MODEL` | Improver model in the same format; defaults to the executor |-| `HARNESS2_JUDGE_MODEL` | Bare judge model ID; the adapter supplies the Vertex prefix |-| `HARNESS2_RUNS_DIR` | Output root; defaults to `runs/` |--The provided configuration uses Vertex Gemini executors and judges, and supports-either Vertex Claude or Gemini as the improver. LAB also supports the upstream-judge's direct providers when their credentials are configured. For WorkBuddy,-setup generates the Gemini solver and judge routes from these settings; rerun it-after changing either model.--### Network access--Installation reaches these hosts:--| Host | Used for |-|---|---|-| `github.com` | the pinned upstream checkouts |-| `registry.npmjs.org` | the pinned Bun runtime and Codex CLI, plus what `bun install` resolves |-| `huggingface.co` and its CDN | the JobBench dataset and the WorkBuddy subset archives |-| a Docker registry | the WorkBuddy container image |-| `astral.sh` | the CPython 3.12 build `uv` downloads when the host has no system 3.12 |--`harness2-setup <bench> --dry-run` prints every command that reaches the network,-so an egress-restricted host can be pre-cleared from that output. Experiments-additionally reach the model endpoints configured in `.env`.+See the [setup guide](docs/SETUP.md) for model settings, authentication+alternatives, and the [Codex executor](docs/SETUP.md#codex-executor).## Run a benchmark-Install one benchmark, then run adaptation, judging, and reporting:+The following example installs LAB and runs one task, then evaluates and reports+its result. Model-backed runs incur API costs; start with a small task selection.```bashharness2-setup labharness2-check --bench lab-harness2 --bench lab --k 1 --mode parallel+harness2 --bench lab --k 1 --mode parallel \+ --only-domains antitrust-competition --max-tasks 1harness2-judge --bench lab --k 1 --mode parallelharness2-report --bench lab --k 1 --mode parallel```Sequential recursion runs the same commands with `--mode sequential`. `--k` isthe task-level recursion budget; see [Experiments](#experiments). Judging and-reporting must reuse the adaptation's `--k` and `--mode`.--Each benchmark also has a script that runs the check, adaptation, judging, and-reporting in sequence. Settings are read from `SUBSTRATE`, `K`, `MODE`, and, for-WorkBuddy, `SUBSET`; any further arguments are passed to the adaptation command:--```bash-bash scripts/run_lab.sh --only-domains antitrust-competition --max-tasks 1-SUBSTRATE=cx K=3 MODE=sequential bash scripts/run_jobbench.sh-SUBSET=web bash scripts/run_workbuddy.sh-```--This copy does not include the benchmark runners and patches that setup-installs; see [`harness2/third_party/README.md`](harness2/third_party/README.md).-Everything else, including the demo and the tests, works without them.--Setup clones each upstream checkout at its supported pin under `dependencies/`,-applies the included patches, creates that benchmark's environment, and downloads-the task data. Each benchmark environment lives inside its upstream checkout —-`dependencies/harvey-labs/.venv`, `dependencies/job-bench-eval/.venv`,-`dependencies/workbuddy-bench/.venv` — so the directory follows the upstream-repository name, not the `lab`/`jb`/`wb` command token. Harness² selects their-interpreters automatically; do not activate them for the main commands.--`harness2-setup <bench> --dry-run` previews an installation without changing-anything. `harness2-check` inspects the installation without calling a model;-adaptation runs the same checks, judge configuration included, and refuses to-start when they fail, so running the check first surfaces those problems without-waiting for a sweep to reach them. No model is called until the first real run,-so a model your account cannot serve fails there, not at the check. Adaptation-and judging return nonzero when incomplete.+reporting must use the same benchmark, executor, subset, `--k`, `--mode`, and+seed as the refinement run. Add `--dry-run` to `harness2` to preview task+selection without model calls.| Benchmark | Tasks | Install | Guide ||---|---|---|---|@@ -190,127 +137,72 @@ Choose one benchmark per command. WorkBuddy also takes `--subset office`,[benchmark guides](docs/BENCHMARKS.md) cover each one's data, domains, andgrading.-### Codex executor--The Codex executor requires an endpoint that implements the OpenAI Responses API.-Vertex AI does not provide this API for Gemini models, so the release includes-`harness2-bridge`, a local LiteLLM server that exposes the Responses API and-forwards requests to Vertex AI using the same Application Default Credentials and-`GOOGLE_CLOUD_PROJECT`. Install the optional dependencies and start the bridge in-a separate session:--```bash-uv pip install -e '.[render,bridge]'-harness2-bridge # for WorkBuddy: harness2-bridge --host 0.0.0.0-```--The bridge prints the `HARNESS2_CODEX_*` settings to add to `.env`. Its port and-a generated access key are stored under `dependencies/codex/` and reused when it-restarts, so these settings remain valid. Then pass `--substrate cx` to every-command:--```bash-harness2-setup lab --substrate cx-harness2-check --bench lab --substrate cx-harness2 --bench lab --substrate cx --k 1 --mode parallel-```--WorkBuddy executes Codex inside Docker containers, so the bridge must listen on-`--host 0.0.0.0`; it then also prints `HARNESS2_CODEX_CONTAINER_URL`. Any other-Responses API endpoint can be used instead by setting `HARNESS2_CODEX_BASE_URL`,-`HARNESS2_CODEX_API_KEY`, and `HARNESS2_CODEX_MODEL` directly. Setup records the-endpoint and model in `dependencies/codex/home/config.toml`; rerun it after-changing either, and `harness2-check` reports the file as out of date until then.-## Experiments-Both modes begin with `k` reference executions of the common base harness.-Parallel recursion explores `k` candidate harnesses per scope and composes them;-sequential recursion carries one composed harness through `k` successive steps.-After adoption, reflection stores the adopted harness with a supported lesson in-a per-domain library: tasks in a domain run in order and read only earlier-entries, separate domains can run concurrently, and the library is kept separate-by benchmark, executor, mode, budget, and seed.+Scale task-level recursion in two ways: **parallel recursion** explores multiple+candidate harnesses and composes refinements from their execution evidence;+**sequential recursion** carries the refined harness and accumulated evidence+through successive Propose–Probe–Compose steps.++<p align="center">+ <a href="assets/harness2_recursion_modes.png">+ <img src="assets/harness2_recursion_modes.png" alt="Two ways to scale task-level recursion. Parallel: probe k general and k domain-specific candidate harnesses, then produce k compositions from the shared evidence. Sequential: carry the refined harness and accumulated evidence through k Propose–Probe–Compose steps." width="100%">+ </a>+</p>+<p align="center"><em>Parallel recursion explores wider; sequential recursion refines deeper.</em></p>| Option | Behavior ||---|---|-| `--k 1` | One improvement step: edit, probe, compose, and reflect |-| `--k K --mode parallel` | Explore `K` proposals per scope and `K` compositions |-| `--k K --mode sequential` | Carry the harness through `K` successive steps |-| `--workers N` | Run `N` domains concurrently; tasks within a domain stay ordered |-| `--substrate cx` | Use the optional Codex executor; OpenCode is the default |-| `--seed N` | Shuffle the task stream reproducibly; does not control model sampling |+| `--k 1` | One Propose–Probe–Compose step |+| `--k K --mode parallel` | Probe `K` general and `K` domain-specific candidates, then produce `K` compositions |+| `--k K --mode sequential` | Refine the harness through `K` successive steps |+| `--substrate cx` | Use Codex instead of the default OpenCode executor |-When changing the budget or mode, choose a new output root:+After each task, harnessing-level recursion retains the adopted harness and+evidence-supported lessons to guide future refinement. See the+[experiment guide](docs/EXPERIMENTS.md) for task selection, concurrency,+reproducibility, and baseline comparisons.-```bash-export HARNESS2_RUNS_DIR=runs/full-harness2 --bench lab --k 3 --mode sequential-harness2-judge --bench lab --k 3 --mode sequential-harness2-report --bench lab --k 3 --mode sequential-```--Run `harness2-judge` and `harness2-report` with the same benchmark, subset, `k`,-mode, and seed used for adaptation. Add `--dry-run` to `harness2` to preview-task selection and available domains without model calls. Adaptation calls paid-models on every rollout and every improver stage — the full LAB stream is 1143-tasks — so check your own pricing before a full run; `--only-domains` and-`--max-tasks` (a per-domain cap) scope a smaller trial.--When comparing budgets or modes, keep task selection, executor, improver, judge,-and web access fixed, and use a distinct `HARNESS2_RUNS_DIR` when changing the-model or task configuration; the saved configuration prevents incompatible-resumes. JobBench's dataset is resolved at download time rather than pinned to a-commit: setup records the Hugging Face revision it received in-`dependencies/job-bench-eval/dataset/main/.harness2-download.json`, so report-that revision alongside any JobBench result.--`harness2-judge --bases` scores a namespace's reference executions, writing-`base_judged.json` beside `judged.json` — the base-harness comparison row.-`harness2-report` covers the adapted harness only.--For a reproducible, domain-stratified partition instead of the installed task set:--```bash-python scripts/split_tasks.py --bench lab --seed 42 --output splits/lab.json-harness2 --bench lab --split-file splits/lab.json --split test --mode parallel-```+## Web access-The default train fraction is 0.5, generated files are local and not release-assets, and the script refuses to overwrite an existing file.+Executor network access is unrestricted, and Codex runs with its sandbox+disabled. Public benchmark rubrics may be accessible online. Before evaluation,+configure [network restrictions](docs/EXPERIMENTS.md#web-access) to prevent+access to benchmark answers and grading criteria.-## Web access+## Results and resume-All three benchmarks are public, and JobBench publishes each task's-`RUBRICS.json` on Hugging Face. An executor with network access can therefore-retrieve the criteria used to grade it. In a validation run of this release, a-Codex rollout on JobBench downloaded its task's rubric without being instructed to.-This release does not restrict network access. We recommend blocking the-following hosts for the executor once setup has completed, since setup itself-requires them to download the data:+Results are saved under `runs/`, organized by benchmark and subset where+applicable. They include task summaries, deliverables, adopted harnesses,+reflection notes, and evaluation results.-- `huggingface.co`, `hf.co`, and `*.hf.co`-- `github.com` and `raw.githubusercontent.com`, for the benchmark repositories+Repeat the same command to resume. Use a new `HARNESS2_RUNS_DIR` when changing+models or task selection. See [results and resume](docs/EXPERIMENTS.md#results-and-resume)+for details; each command also supports `--help`.-Codex runs with its sandbox disabled, so apply the restriction at the network-level, for example with an egress firewall or DNS policy on the executor host,-rather than through a tool setting. Report the restrictions in effect alongside-any result.+## Citation-## Results and resume+```bibtex+@article{xu2026harness2,+ title = {Harness$^2$: Recursive Agent Harnessing for an Open World},+ author = {Xu, Ruiyao and Chen, Yanfei and CuiZhu, Zhongying and Dalvi Mishra, Bhavana and Ming, Yifei and Yu, Han and Han, Rujun and Lee, Chen-Yu and Pfister, Tomas},+ journal = {arXiv preprint},+ year = {2026}+}+```-Results are saved under `runs/<benchmark>/` (and the WorkBuddy subset), including-per-task summaries, execution artifacts, adopted harnesses, reflection notes, and-graded results. Repeat the same command to resume. A failed judge stays unscored.-Use a new `HARNESS2_RUNS_DIR` when changing models or task selection.+## Contributing-Adaptation, judging, and reporting use `harness2`, `harness2-judge`, and-`harness2-report`; each has `--help`.+See [CONTRIBUTING.md](CONTRIBUTING.md).## License-Harness² is licensed under Apache 2.0. Benchmarks, datasets, and-derived runner files retain their upstream licenses; see+Harness² is licensed under [Apache 2.0](LICENSE). Third-party code under+[`third_party/`](third_party/README.md), benchmarks, and datasets retain their+upstream licenses; see[third-party notices](dependencies/README.md).-This is not an officially supported Google product. This project is not eligible for the [Google Open Source Software Vulnerability Rewards Program](https://bughunters.google.com/open-source-security).+## Disclaimer++This is not an officially supported Google product. This project is not eligible+for the [Google Open Source Software Vulnerability Rewards Program](https://bughunters.google.com/open-source-security).diff --git a/assets/harness2-setup.gif b/assets/harness2-setup.gifnew file mode 100644index 0000000..1e82df9Binary files /dev/null and b/assets/harness2-setup.gif differdiff --git a/assets/harness2-video.mp4 b/assets/harness2-video.mp4new file mode 100644index 0000000..32e4f3dBinary files /dev/null and b/assets/harness2-video.mp4 differdiff --git a/assets/harness2_pipeline.png b/assets/harness2_pipeline.pngindex 11d845d..64fac99 100644Binary files a/assets/harness2_pipeline.png and b/assets/harness2_pipeline.png differdiff --git a/assets/harness2_recursion_modes.png b/assets/harness2_recursion_modes.pngnew file mode 100644index 0000000..91f5503Binary files /dev/null and b/assets/harness2_recursion_modes.png differdiff --git a/dependencies/README.md b/dependencies/README.mdindex 7ed399b..85346f2 100644--- a/dependencies/README.md+++ b/dependencies/README.md@@ -13,8 +13,7 @@ control. Pins are defined in `harness2/config.py`; setup commands are in theThe WorkBuddy license includes a territorial limitation concerning use withinthe European Union. The derived runners, the patches, and the upstream license-notices that cover them are not included in this copy; see-[`harness2/third_party/`](../harness2/third_party/README.md).+notices that cover them are bundled in [`third_party/`](../third_party/README.md).Dataset licenses are separate from software licenses. Data is downloaded fromits upstream distribution and is not redistributed in Harness². Generateddiff --git a/docs/BENCHMARKS.md b/docs/BENCHMARKS.mdindex 6133ae6..18ca85f 100644--- a/docs/BENCHMARKS.md+++ b/docs/BENCHMARKS.md@@ -1,9 +1,9 @@# Benchmark guides-Complete the [installation and credentials](../README.md#install) first. Each+Complete the [installation and credentials](SETUP.md) first. Eachbenchmark installs separately; install the ones you intend to run. Every commandbelow takes `--substrate cx` to use the-[Codex executor](../README.md#codex-executor) instead of OpenCode. Choose the+[Codex executor](SETUP.md#codex-executor) instead of OpenCode. Choose therecursion mode with `--mode parallel` or `--mode sequential` and the task-levelrecursion budget with `--k`. Keep both identical across the run, judge, andreport commands.@@ -69,7 +69,7 @@ weights; unscored tasks are reported separately. Results are under `runs/jb/`.Note: JobBench data, including `RUBRICS.json`, is public on Hugging Face, so anexecutor with web access may retrieve it. Block those hosts during runs as-described under [Web access](../README.md#web-access).+described under [Web access](EXPERIMENTS.md#web-access).## WorkBuddy-Bench@@ -122,4 +122,3 @@ the improver never receives verifier output. Missing verifier results remainunscored. Runs live under `runs/wb/<subset>/`.For Codex, start the bridge with `harness2-bridge --host 0.0.0.0` so that the containers can reach it.-diff --git a/docs/EXPERIMENTS.md b/docs/EXPERIMENTS.mdnew file mode 100644index 0000000..bd52e15--- /dev/null+++ b/docs/EXPERIMENTS.md@@ -0,0 +1,122 @@+# Experiment guide++Complete [setup](SETUP.md) and choose a [benchmark](BENCHMARKS.md) first. This+guide covers recursion budgets, task selection, reproducibility, and evaluation.++## Recursion modes++Both modes start with `k` reference executions of the same base harness.++- **Parallel recursion** proposes and probes `k` general (invariant) candidates+ and `k` domain-specific candidates. Each of `k` independent compositions uses+ the full candidate pool and execution evidence to produce a refined harness.+- **Sequential recursion** runs `k` Propose–Probe–Compose steps, carrying the+ refined harness and accumulated execution evidence into the next step.++After adoption, reflection stores the adopted harness and evidence-supported+lessons in a per-domain library. Tasks within a domain run in order and read+only earlier entries; different domains can run concurrently. Libraries are+separated by benchmark, executor, mode, budget, and seed.++| Option | Behavior |+|---|---|+| `--k 1` | One Propose–Probe–Compose step, followed by reflection after adoption |+| `--k K --mode parallel` | Explore `K` candidates per scope and produce `K` compositions |+| `--k K --mode sequential` | Refine the harness through `K` successive steps |+| `--workers N` | Run `N` domains concurrently; tasks within each domain stay ordered |+| `--substrate cx` | Use Codex instead of the default OpenCode executor |+| `--seed N` | Shuffle the task stream reproducibly; does not control model sampling |++Use the same benchmark, executor, subset, `k`, mode, and seed for refinement,+judging, and reporting. For example:++```bash+export HARNESS2_RUNS_DIR=runs/lab-sequential-k3+harness2 --bench lab --k 3 --mode sequential \+ --only-domains antitrust-competition --max-tasks 1+harness2-judge --bench lab --k 3 --mode sequential+harness2-report --bench lab --k 3 --mode sequential+```++Use a separate output root when changing the budget or mode to keep experiments+easy to distinguish.++## Task selection and cost++Model-backed runs incur API costs for executor rollouts and improvement stages.+The full LAB task stream contains 1,143 tasks. Start with a small selection and+review model pricing before launching a full run.++- `--only-domains` restricts the run to the named domains.+- `--max-tasks` caps tasks **per domain**, not across the whole run.+- `--dry-run` previews selected tasks and available domains without model calls.++Each benchmark also has a script that runs checks, refinement, judging, and+reporting in sequence. Set `SUBSTRATE`, `K`, `MODE`, and, for WorkBuddy,+`SUBSET`; additional arguments are passed to the refinement command:++```bash+bash scripts/run_lab.sh --only-domains antitrust-competition --max-tasks 1+SUBSTRATE=cx K=3 MODE=sequential bash scripts/run_jobbench.sh --max-tasks 1+SUBSET=web bash scripts/run_workbuddy.sh --max-tasks 1+```++## Reproducibility++When comparing budgets or modes, keep task selection, executor, improver, judge,+and web access fixed. Use a distinct `HARNESS2_RUNS_DIR` when changing models or+task selection; the saved configuration prevents incompatible resumes.++JobBench's dataset is resolved at download time rather than pinned to a commit.+Setup records the downloaded Hugging Face revision in+`dependencies/job-bench-eval/dataset/main/.harness2-download.json`. Report that+revision alongside JobBench results.++### Task partitions++To create a reproducible, domain-stratified partition of the installed tasks:++```bash+python scripts/split_tasks.py --bench lab --seed 42 --output splits/lab.json+harness2 --bench lab --split-file splits/lab.json --split test --mode parallel+```++The default train fraction is 0.5. Generated partitions are local files, not+release assets, and the script refuses to overwrite an existing file.++## Baseline evaluation++`harness2-judge --bases` scores a run namespace's reference executions, writing+`base_judged.json` beside `judged.json` for the base-harness comparison.+`harness2-report` covers the refined harness only.++## Web access++All three benchmarks are public, and JobBench publishes each task's+`RUBRICS.json` on Hugging Face. An executor with network access can therefore+retrieve grading criteria. In a validation run of this release, a Codex rollout+on JobBench downloaded its task's rubric without being instructed to.++The release does not restrict network access. After setup, block the following+hosts for the executor to reduce access to benchmark data and grading criteria:++- `huggingface.co`, `hf.co`, and `*.hf.co`+- `github.com` and `raw.githubusercontent.com`, for benchmark repositories++Setup itself needs these hosts to download dependencies and data. Codex runs+with its sandbox disabled, so apply restrictions at the network level, such as+an egress firewall or DNS policy on the executor host, rather than relying on a+tool setting. Report the restrictions used alongside results.++## Results and resume++The default output roots are `runs/lab/`, `runs/jb/`, and+`runs/wb/<subset>/`. They contain task summaries, execution artifacts, adopted+harnesses, reflection notes, and graded results.++Repeat the same command to resume. Failed evaluations remain unscored rather+than being counted as zero. Use a new `HARNESS2_RUNS_DIR` when changing models or+task selection.++Refinement, judging, and reporting use `harness2`, `harness2-judge`, and+`harness2-report`; each supports `--help`.diff --git a/docs/SETUP.md b/docs/SETUP.mdnew file mode 100644index 0000000..0d037b8--- /dev/null+++ b/docs/SETUP.md@@ -0,0 +1,165 @@+# Setup guide++Start with the [quick start](../README.md#install). This guide covers benchmark+dependencies, model credentials, and the optional Codex executor. For individual+benchmarks, see the [benchmark guides](BENCHMARKS.md).++## Requirements++Use Linux and Python 3.12 for benchmark runs; the Python package also supports+3.13. On Debian/Ubuntu:++```bash+sudo apt-get update+sudo apt-get install -y git curl unzip ca-certificates pandoc poppler-utils+```++Pandoc and Poppler are needed by LAB. Also install:++- [Node.js](https://nodejs.org/en/download) 20 or newer.+- [uv](https://docs.astral.sh/uv/getting-started/installation/).+- [Google Cloud CLI](https://cloud.google.com/sdk/docs/install).+- [Docker Engine](https://docs.docker.com/engine/install/) for WorkBuddy-Bench,+ with permission to run `docker info`.++Benchmark setup installs its own pinned Bun runtime under `dependencies/`.+Keep the main Harness² environment active when running the commands below.++## Models and credentials++Copy `.env.example` to `.env` if you have not already done so. Set your Vertex AI+project and model IDs, then authenticate:++```bash+gcloud auth application-default login+```++Shell environment variables take precedence over `.env`.+`GOOGLE_CLOUD_PROJECT` identifies your project; `GOOGLE_CLOUD_LOCATION` defaults+to `global`. Your account must have access to each configured model.++| Setting | Meaning |+|---|---|+| `HARNESS2_SOLVER_MODEL` | Executor model in OpenCode's `provider/model` format |+| `HARNESS2_IMPROVER_MODEL` | Improver model in the same format; defaults to the executor |+| `HARNESS2_JUDGE_MODEL` | Bare judge model ID; the adapter supplies the Vertex prefix |+| `HARNESS2_RUNS_DIR` | Output root; defaults to `runs/` |++The provided configuration uses Vertex Gemini executors and judges, and supports+either Vertex Claude or Gemini as the improver. LAB also supports the upstream+judge's direct providers when their credentials are configured. For WorkBuddy,+setup generates the Gemini solver and judge routes from these settings; rerun+setup after changing either model.++### Authentication alternatives++On a machine with a configured attached service account, Application Default+Credentials can use that account. Other options include:++- `gcloud auth application-default login --no-browser`, which prints a command+ to run on another machine that has a browser.+- `GOOGLE_APPLICATION_CREDENTIALS` pointing at a service account key file.+- `gcloud auth application-default login --impersonate-service-account=<account>`.++Keep `gcloud` on `PATH` for these Vertex configurations, including the key-file+route: the installation check runs+`gcloud auth application-default print-access-token`.++## Benchmark installation++Install only the benchmark you intend to run:++```bash+harness2-setup lab+harness2-check --bench lab+```++Use `jb` for JobBench or `wb` for WorkBuddy-Bench. See the+[benchmark guides](BENCHMARKS.md) for subset selection and licensing.++The runner overlays and compatibility patches are included in+[`third_party/`](../third_party/README.md). Setup clones supported upstream+revisions under `dependencies/`, applies the patches, creates the benchmark+environments, and downloads task data.++Each benchmark environment lives inside its upstream checkout:++- `dependencies/harvey-labs/.venv`+- `dependencies/job-bench-eval/.venv`+- `dependencies/workbuddy-bench/.venv`++Harness² selects these interpreters automatically; do not activate them for the+main commands.++### Installation checks++`harness2-setup <bench> --dry-run` previews setup without making changes.+`harness2-check` checks installed dependencies, credentials, and configuration+without calling a model. Refinement runs perform the same checks, including+judge configuration, before starting.++These checks do not test model availability. Access to an executor, improver, or+judge model is tested when that model is first called. Refinement and judging+return a nonzero exit status when incomplete.++## Codex executor++The Codex executor connects to a Responses API endpoint. For Gemini on Vertex+AI, the included `harness2-bridge` provides this interface through a local+LiteLLM server, using the same Application Default Credentials and+`GOOGLE_CLOUD_PROJECT`.++Install the optional dependencies and start the bridge in a separate session:++```bash+uv pip install -e '.[render,bridge]'+harness2-bridge # for WorkBuddy: harness2-bridge --host 0.0.0.0+```++The bridge prints the `HARNESS2_CODEX_*` settings to add to `.env`. Its port and+generated access key are stored under `dependencies/codex/` and reused on+restart. Pass `--substrate cx` to setup, checks, refinement, judging, and+reporting:++```bash+harness2-setup lab --substrate cx+harness2-check --bench lab --substrate cx+harness2 --bench lab --substrate cx --k 1 --mode parallel \+ --only-domains antitrust-competition --max-tasks 1+```++WorkBuddy executes Codex inside Docker containers, so the bridge must listen on+`--host 0.0.0.0`; it also prints `HARNESS2_CODEX_CONTAINER_URL`. This binds the+bridge to all network interfaces; restrict access to the intended clients.++To use another Responses API endpoint, set `HARNESS2_CODEX_BASE_URL`,+`HARNESS2_CODEX_API_KEY`, and `HARNESS2_CODEX_MODEL` directly. Setup records the+endpoint and model in `dependencies/codex/home/config.toml`; rerun setup after+changing either. `harness2-check` reports stale configuration until then.++Codex runs with its sandbox disabled. Review the+[executor network restrictions](EXPERIMENTS.md#web-access) before evaluation.++## Network access during setup++Setup downloads dependencies from the following hosts:++| Host | Used for |+|---|---|+| `github.com` | Pinned upstream checkouts |+| `registry.npmjs.org` | Pinned Bun runtime and Codex CLI, plus dependencies resolved by `bun install` |+| `huggingface.co` and its CDN | JobBench data and WorkBuddy subset archives |+| A Docker registry | WorkBuddy container image |+| `astral.sh` | CPython 3.12 when the host has no system Python 3.12 |++Use `harness2-setup <bench> --dry-run` to review setup commands when configuring+network access. Experiments also access the model endpoints configured in+`.env`. Setup downloads and executor web access have different requirements;+see [web access during evaluation](EXPERIMENTS.md#web-access).++## Wheel installations++A wheel ships the `harness2` package only. The task partitioner,+`python scripts/split_tasks.py`, requires this source tree. For a wheel+installation, work from a dedicated directory: `.env`, `dependencies/`, and+`runs/` are resolved there.diff --git a/scripts/render_readme_typing.py b/scripts/render_readme_typing.pynew file mode 100644index 0000000..d01d722--- /dev/null+++ b/scripts/render_readme_typing.py@@ -0,0 +1,140 @@+#!/usr/bin/env python3+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# https://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++"""Render installation, JobBench setup, and a run in one terminal line (requires Pillow).++Run: python scripts/render_readme_typing.py+Optional: --preview /tmp/harness2-setup.png --font /path/to/monospace.ttf++The 2560x256 GIF is displayed at 640x64 CSS pixels. Preserve its native pixels+when saving: downsampling before embedding defeats high-DPI text rendering.+Commands are illustrated, not executed. Prerequisites remain in Install and+docs/BENCHMARKS.md; clicking the animation opens the JobBench guide.+"""++import argparse+from pathlib import Path++from PIL import Image, ImageDraw, ImageFont++ROOT = Path(__file__).resolve().parents[1]+WIDTH, HEIGHT, SCALE = 640, 64, 4+BACKGROUND = "#232d43"+TEXT = "#f2effa"+PURPLE = "#c6acf5"+BORDER = "#46516b"+COMMANDS = (+ "uv pip install -e '.[render]'",+ "harness2-setup jb",+ "harness2 --bench jb --k 1 --mode parallel",+)+++def find_font(requested):+ candidates = [requested] if requested else [+ "/System/Library/Fonts/Menlo.ttc",+ "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",+ "/usr/share/fonts/truetype/liberation2/LiberationMono-Regular.ttf",+ ]+ for candidate in candidates:+ if candidate and Path(candidate).is_file():+ return candidate+ raise SystemExit("Provide a monospace TrueType font with --font.")+++def render_frame(font_path, command, length, cursor=True):+ canvas = Image.new("RGB", (WIDTH * SCALE, HEIGHT * SCALE), "white")+ draw = ImageDraw.Draw(canvas)+ mono = ImageFont.truetype(font_path, 20 * SCALE)+ full_width = draw.textlength(command, font=mono)+ text_x = 102 * SCALE+ if text_x + full_width + 24 * SCALE > WIDTH * SCALE:+ raise SystemExit("Setup command is too long for the image width.")+ draw.rounded_rectangle(+ (SCALE, SCALE, (WIDTH - 1) * SCALE, (HEIGHT - 1) * SCALE),+ radius=10 * SCALE, fill=BACKGROUND, outline=BORDER, width=SCALE,+ )+ # Minimal window controls stay on the same row as the text.+ for x, color in ((21, "#63708b"), (33, "#8b7daf"), (45, "#b39ace")):+ draw.ellipse(+ ((x - 3) * SCALE, 29 * SCALE, (x + 3) * SCALE, 35 * SCALE), fill=color,+ )+ draw.line((61 * SCALE, 20 * SCALE, 61 * SCALE, 44 * SCALE), fill=BORDER, width=SCALE)+ baseline = 39 * SCALE+ draw.text((77 * SCALE, baseline), "$", font=mono, fill=PURPLE, anchor="ls")+ # Type a real executable and its arguments; no simulated success output.+ visible = command[:length]+ name_length = len(command.split(" ", 1)[0])+ executable, arguments = visible[:name_length], visible[name_length:]+ draw.text((text_x, baseline), executable, font=mono, fill=PURPLE, anchor="ls")+ args_x = text_x + draw.textlength(executable, font=mono)+ draw.text((args_x, baseline), arguments, font=mono, fill=TEXT, anchor="ls")+ if cursor:+ right = text_x + draw.textlength(visible, font=mono) + 3 * SCALE+ draw.rectangle(+ (right, 21 * SCALE, right + 2 * SCALE, 43 * SCALE), fill=PURPLE,+ )+ return canvas+++def main():+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--font")+ parser.add_argument("--output", type=Path, default=ROOT / "assets/harness2-setup.gif")+ parser.add_argument("--preview", type=Path)+ args = parser.parse_args()+ font_path = find_font(args.font)+ documented = {+ line.strip()+ for path in (ROOT / "README.md", ROOT / "docs/BENCHMARKS.md")+ for line in path.read_text().splitlines()+ }+ for command in COMMANDS:+ if command not in documented:+ raise SystemExit(f"Command no longer matches the setup documentation: {command}")+ stills = [render_frame(font_path, command, len(command)) for command in COMMANDS]+ palette_source = Image.new("RGB", (WIDTH * SCALE, HEIGHT * SCALE * len(stills)))+ for index, still in enumerate(stills):+ palette_source.paste(still, (0, index * HEIGHT * SCALE))+ palette = palette_source.quantize(colors=256)+ frames, durations = [], []++ def add(command, length, duration, cursor=True):+ frame = render_frame(font_path, command, length, cursor)+ frames.append(frame.quantize(palette=palette, dither=Image.Dither.NONE))+ durations.append(duration)++ for command in COMMANDS:+ add(command, 0, 400)+ for length in range(1, len(command) + 1):+ add(command, length, 60 if command[length - 1] != " " else 100)+ for _ in range(3):+ add(command, len(command), 450, cursor=False)+ add(command, len(command), 450)++ args.output.parent.mkdir(parents=True, exist_ok=True)+ frames[0].save(+ args.output, save_all=True, append_images=frames[1:], duration=durations,+ loop=0, disposal=1, optimize=False,+ )+ if args.preview:+ stills[-1].save(args.preview)+ print(f"Saved {args.output}: {WIDTH * SCALE}x{HEIGHT * SCALE} "+ f"(display {WIDTH}x{HEIGHT}), {sum(durations) / 1000:.2f}s, "+ f"{args.output.stat().st_size / 1024:.0f} KiB")+++if __name__ == "__main__":+ main()