Skip to content

openenv/tbench2: adapter-driven TB2 fidelity (no OpenEnv fork/vendor)#1633

Open
Shi-Dong wants to merge 2 commits into
shi/openenv-miles-adapterfrom
shi/openenv-adapter-driven-fidelity
Open

openenv/tbench2: adapter-driven TB2 fidelity (no OpenEnv fork/vendor)#1633
Shi-Dong wants to merge 2 commits into
shi/openenv-miles-adapterfrom
shi/openenv-adapter-driven-fidelity

Conversation

@Shi-Dong

Copy link
Copy Markdown
Contributor

Summary

  • Drives full Terminal-Bench-2 fidelity from the miles adapter instead of patching OpenEnv: agent commands and scoring run in the task image's real /app workdir, and scoring uses the task's canonical tests/test.sh -> /logs/verifier/reward.txt harness, driven through plain exec steps.
  • Keeps upstream OpenEnv (huggingface/OpenEnv) unmodified and unvendored — the env server is used purely as a docker-exec transport.

Why

Upstream's Tbench2DockerEnvironment docker mode is low-fidelity: it runs the container in /task (a copy of the task source), drops the agent there instead of /app (the task image WORKDIR), and scores via bare pytest tests/ rather than TB2's canonical test.sh (which pins the pytest toolchain, copies test.py into /app, runs test_outputs.py, and writes reward.txt). That mis-drives and mis-scores essentially all 89 TB2 tasks. Rather than fork or vendor OpenEnv to fix it, this moves the TB2-specific fidelity logic into the adapter, where the rest of the TB2 integration already lives.

What changed (openenv_agent_function.py)

  • OPENENV_TASK_WORKDIR (default /app): every agent command is prefixed to run in the real task workdir.
  • Scoring replaces the built-in evaluate action with an exec that stages the task tests to /tests, runs the canonical test.sh in /app, and parses reward.txt.
  • OPENENV_TB2_TESTS_SRC (default /task/tests): where the unmodified upstream env stages the task's tests inside the container.

Validation

Prototyped end-to-end against a pristine origin/main Tbench2DockerEnvironment on a real docker daemon: reset -> apply reference solution in /app -> canonical eval -> reward = 1.0 (task cancel-async-tasks).

Caveat / deployment

This intentionally couples the adapter to unmodified upstream OpenEnv (which copies the task dir, tests included, into /task). It is incompatible with the earlier docker-patched snapshot path. Deployment therefore hosts the unmodified upstream env-server on a real-docker host (e.g. agent-server) rather than the serverless Daytona snapshot.

Test plan

  • Full-89 docker-mode smoke on a real-docker host, compared against a base reward baseline
  • 1-node training smoke run

Run agent commands and scoring in the task image's real /app workdir and
score via the canonical tests/test.sh -> /logs/verifier/reward.txt harness,
driven through plain exec steps. This keeps upstream OpenEnv unmodified (no
fork, no vendoring): the env server is used purely as a docker-exec transport.

Validated end-to-end (reward=1.0) against a pristine origin/main
Tbench2DockerEnvironment on a real docker daemon.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces adapter-driven Terminal-Bench-2 fidelity support to the OpenEnv agent function. It configures the agent to run commands in the correct task working directory and executes the canonical test.sh harness via an exec step rather than using the built-in non-canonical evaluate action. Feedback was provided to address potential stale reward leakage, ensure correct workdir fallback behavior when OPENENV_TASK_WORKDIR is disabled, and avoid shared temporary directory conflicts on multi-user clusters by appending the user's UID to the log path.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread examples/experimental/openenv/openenv_agent_function.py
Address the Gemini review on PR #1633's _CANONICAL_EVAL_CMD:
- rm -f /logs/verifier/reward.txt before running test.sh so a stale reward
  can never be read back if test.sh fails to write a fresh one.
- Only prefix `cd <workdir>` when _TASK_WORKDIR is non-empty, so setting
  OPENENV_TASK_WORKDIR="" actually disables the prefix (matches _apply_workdir),
  instead of silently forcing /app.

The test.sh stdout log stays at /tmp/tb2_testsh.log: it is written inside the
ephemeral per-episode task container, not on a shared host, so a host UID
suffix would be misleading rather than protective.
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