-
Notifications
You must be signed in to change notification settings - Fork 230
feat: harness agnostic TerminalBench environment #1631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
aef08cb
feat: add terminal bench with pluggable agents
elisam0 97e4c38
fix: interrupt if agent timeout to retrieve partial transcript
elisam0 6dd361c
fix: use same Hermes parameters as Hermes in Harbor
elisam0 88b5a77
fix: clean apptainer containers properly
elisam0 e316756
fix: use input field instead of problem statement
elisam0 8ae81a7
fix: use default temperature
elisam0 dc8f3a9
fix: remove system prompt
elisam0 2557012
fix: model parameter in trace
elisam0 650dd55
feat: download terminal 2.1
elisam0 8769903
feat: gather task resource info and reserve
elisam0 ded3692
refactor: general comment
elisam0 91499dd
chore: remove anyswe reference
elisam0 a203d52
fix: add fallback when non metadata
elisam0 d8fb536
feat: add tests to anyterminal
elisam0 6aa3c87
fix: ignore agnostic harness folders in tests
elisam0 dbf1a80
fix: sigterm signal for each agent
elisam0 bf45524
feat: add example input+rollouts
elisam0 119250f
feat: add apptainer install instructions to anyterminal
elisam0 81989a9
feat: add anyterminal to README
elisam0 e4d0dfe
fix: update docstring
elisam0 74eb2aa
fix: update ulimit comment
elisam0 16937ec
feat: tmp hermes home fp;der cleanup
elisam0 04d0d1b
feat: increase test coverage
elisam0 fcf6cb7
feat: add claude code config
elisam0 980f7fa
fix: claude code config
elisam0 1305606
fix: not finding test if agent creates test folder
elisam0 8471af0
fix: timeout issues in claude config
elisam0 524cd88
refactor: remove unused params
elisam0 12ac9f6
Merge branch 'main' into elisam0/add-anyterminal
cmunley1 575255a
Merge branch 'main' into elisam0/add-anyterminal
cmunley1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -462,6 +462,8 @@ norecursedirs = [ | |
| "scripts", | ||
| "tools", | ||
| "tutorials", | ||
| "deps", | ||
| "results", | ||
| "*.egg", | ||
| ".*", | ||
| "_darcs", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| results/ | ||
| deps/ | ||
| anyterminal_*_deps | ||
| anyterminal_results_* | ||
| sifs/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # anyterminal_agent | ||
|
|
||
| Runs any Gym agent inside a Terminal Bench task container and evaluates the result | ||
| by running the task's `tests/test.sh` in the same container. Works with | ||
| `hermes_agent`, `claude_code_agent`, or any other compatible Gym agent. | ||
|
|
||
| Unlike `anyswe_agent` (which runs agent and eval in two concurrent containers), | ||
| anyterminal runs everything sequentially in one container: agent finishes, then | ||
| `test.sh` runs and writes a reward to `/logs/verifier/reward.txt`. The test | ||
| directory is mounted read-only so the agent cannot tamper with the tests before | ||
| they run. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Every task runs inside an [Apptainer](https://apptainer.org/) (formerly Singularity) container, | ||
| so Apptainer must be installed on each machine that runs rollouts. It is not bundled with Gym. | ||
|
|
||
| ```bash | ||
| apt-get update && apt-get install -y wget | ||
| cd /tmp | ||
| wget https://github.com/apptainer/apptainer/releases/download/v1.4.2/apptainer_1.4.2_amd64.deb | ||
| apt-get install -y ./apptainer_1.4.2_amd64.deb | ||
| apptainer --version | ||
| ``` | ||
|
|
||
| ## Quickstart | ||
|
|
||
| **1. Prepare the dataset** — downloads tasks via Harbor and writes the input JSONL: | ||
|
|
||
| ```bash | ||
| # Download tasks + build dataset + build SIFs (default) | ||
|
elisam0 marked this conversation as resolved.
|
||
| python responses_api_agents/anyterminal_agent/prepare.py | ||
|
|
||
| # Skip SIF builds — Apptainer will pull docker:// images at runtime | ||
| python responses_api_agents/anyterminal_agent/prepare.py --no-build-sif | ||
|
|
||
| # Build SIFs into a custom directory | ||
| python responses_api_agents/anyterminal_agent/prepare.py --sif-dir /shared/sifs | ||
|
|
||
| # Smoke test — first 5 tasks only | ||
| python responses_api_agents/anyterminal_agent/prepare.py --limit 5 --no-build-sif | ||
| ``` | ||
|
|
||
| Requires the `harbor` CLI on PATH. Tasks are downloaded automatically and cached at | ||
| `~/.cache/harbor/tasks/terminal-bench/`; subsequent runs skip the download. | ||
|
|
||
| **2. Start the environment** with Hermes and a model server: | ||
|
|
||
| ```bash | ||
| ng_run "+config_paths=[responses_api_agents/anyterminal_agent/configs/anyterminal_hermes.yaml,responses_api_models/vllm_model/configs/vllm_model.yaml]" | ||
| ``` | ||
|
|
||
| If you pre-built SIFs into a custom directory, override `tb_sif_dir`: | ||
|
|
||
| ```bash | ||
| ng_run "+config_paths=[...]" \ | ||
| ++anyterminal_hermes.responses_api_agents.anyterminal_agent.tb_sif_dir=/shared/sifs | ||
| ``` | ||
|
|
||
| **3. Collect rollouts:** | ||
|
|
||
| ```bash | ||
| ng_collect_rollouts \ | ||
| +agent_name=anyterminal_hermes \ | ||
| +input_jsonl_fpath=responses_api_agents/anyterminal_agent/data/terminal_bench.jsonl \ | ||
| +output_jsonl_fpath=results/anyterminal_rollouts.jsonl | ||
| ``` | ||
|
|
||
| Each rollout row contains `reward` (0.0 or 1.0), the full agent trajectory, and | ||
| `mask_sample` (set when a timeout made the reward unreliable). | ||
|
|
||
| ## Agent wiring | ||
|
|
||
| Swap the agent by changing three fields in the YAML (or overriding on the CLI): | ||
|
|
||
|
|
||
| ```yaml | ||
| agent_server_module: responses_api_agents.hermes_agent.app | ||
| agent_server_class: HermesAgent | ||
| agent_config_class: HermesAgentConfig | ||
| agent_kwargs: | ||
| max_turns: 30 | ||
| terminal_backend: local | ||
| ``` | ||
|
|
||
| Agent dependencies are installed once at startup into a portable Python prefix | ||
| mounted read-only inside the task container at `/agent_deps_mount`. To support a | ||
| new agent, add `setup_scripts/<agent_dir>_deps.sh` (see `hermes_agent_deps.sh` | ||
| for the pattern). | ||
|
|
||
| ## Container images | ||
|
|
||
| Each Terminal Bench task specifies a Docker image in its `task.toml`. You can | ||
| either: | ||
|
|
||
| - **Pull at runtime** (default, `tb_sif_dir: null`): Apptainer pulls | ||
| `docker://<image>` on first use. Requires internet access on compute nodes. | ||
| - **Pre-build SIFs** (`prepare.py --sif-dir PATH`): Converts each image to a | ||
| `.sif` file. Faster and works on air-gapped clusters. | ||
|
|
||
| ## Key config options | ||
|
|
||
| | Field | Default | Description | | ||
| |---|---|---| | ||
| | `tb_tasks_cache_dir` | `~/.cache/harbor/tasks` | Where Harbor stores downloaded task definitions | | ||
| | `tb_sif_dir` | `null` | Pre-built SIF directory; `null` = pull docker:// at runtime | | ||
| | `tb_agent_timeout` | `1800` | Seconds before the agent is killed | | ||
| | `tb_eval_timeout` | `300` | Seconds for `test.sh` to complete | | ||
| | `apptainer_memory_limit_mb` | `32768` | Per-container memory cap via `ulimit -v` | | ||
| | `concurrency` | `256` | Max concurrent tasks dispatched to Ray | | ||
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.