Skip to content

fix(terminal_bench_4): report deadline-ended runs and verifier timeouts accurately - #4230

Draft
giuliolovisotto wants to merge 1 commit into
mainfrom
glovisotto/tb4-timeout-status
Draft

giuliolovisotto wants to merge 1 commit into
mainfrom
glovisotto/tb4-timeout-status

Conversation

@giuliolovisotto

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes two reporting bugs in the TerminalBench-4 path (the miniswe_sandboxed_agent harness and the terminal_bench_4 resources server). Rewards, scores and verification flow are unchanged; only status and failure labels change.

1. A run that ended at its deadline could say failed. The agent server relabelled a deadline-ended run as termination.reason="timeout" only after MiniSWEHarness.execute returned. By then the harness had already built the rollout observations from the earlier reason. When the sandbox ends the command at the deadline and reports a non-zero exit instead of raising, the harness sees infrastructure_error. The result was an invocation with status="failed" next to a timeout termination. AgentInvocation.error_type was also never set.

  • MiniSWEHarness.execute now applies the deadline check itself (deadline = start + budget), before it derives observations. The invocation status, the tool-call statuses and the native_trajectory_partial gap now all agree with the timeout termination. The check in app.py was removed because it only duplicated this one.
  • A timed-out invocation is reported as status="incomplete" with error_type="TimeoutError". This matches how Terminus 2 reports a time-limited run.

2. A verifier timeout was hidden by an earlier agent timeout. lifecycle.exception recorded exception_info with setdefault, so only the first exception was kept. If the agent timed out (AgentTimeoutError) and the verifier then also timed out (VerifierTimeoutError), the verify response said infrastructure_error="AgentTimeoutError". The real reason there was no reward was lost.

  • The verifier's subphases now also record their exception as result["verifier_exception_info"]. exception_info still holds the agent's exception.
  • When there is no reward, _verified_response reports the verifier's exception first and falls back to exception_info as before. infrastructure_error and failure_reason therefore say VerifierTimeoutError.

Related: #2831, #3182.

Validation

  • pytest in responses_api_agents/miniswe_sandboxed_agent (environment built by gym env test +entrypoint=responses_api_agents/miniswe_sandboxed_agent): 125 passed, 1 skipped, and 1 timing failure in test_runner_stops_before_verification_and_retains_partial_trajectory[cancel], which passed on two reruns. The machine was heavily loaded by other test runs. The 77 tests in test_server.py, test_agent_server.py and the new worker test passed.
  • pytest in resources_servers/terminal_bench_4 (environment built by gym env test +entrypoint=resources_servers/terminal_bench_4): 114 passed. test_environment.py::test_offline_policy_and_unsupported_config fails on main too when OPENSANDBOX_*_CPU variables are set in the shell, so they were unset for this run.
  • Both new tests fail without the fix: the outcome is 'infrastructure_error' instead of 'timeout', and the failure is 'AgentTimeoutError' instead of 'VerifierTimeoutError'.
  • pre-commit run --files <changed files>: passed.

New regression tests:

  • responses_api_agents/miniswe_sandboxed_agent/tests/test_worker.py::test_command_ended_at_deadline_is_an_incomplete_timeout: the sandbox ends the runner at the deadline and returns exit 137 instead of raising. The test expects termination.reason == "timeout", invocation status == "incomplete" and error_type == "TimeoutError". On main this run comes back as infrastructure_error / failed.
  • responses_api_agents/miniswe_sandboxed_agent/tests/test_server.py::test_verifier_timeout_after_agent_timeout_reports_the_verifier: an agent timeout followed by a verifier timeout. The test expects the response to report VerifierTimeoutError, with the agent's AgentTimeoutError still in exception_info. This test drives the real TB4 resources server and lifecycle.

Rollouts

N/A. The change touches only status and failure labels in the emitted records. Agent behaviour, the verifier and rewards are unchanged, and the regression tests cover both paths deterministically.

Compatibility and benchmark impact

  • No reward or score changes.
  • Records change only in these cases:
    • Runs that end on their deadline now have invocation status="incomplete" and error_type="TimeoutError". Before, they could be failed with no error_type.
    • Agent-timeout runs whose verifier then fails now report the verifier's exception type in infrastructure_error / failure_reason. Before, they reported AgentTimeoutError.
  • The persisted TB4 result gains an optional verifier_exception_info key. Readers that use .get are unaffected.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification. (N/A: internal reporting fix, no documented behaviour changes.)
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header. (No new files.)
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

🤖 Generated with Claude Code

… timeouts accurately

The agent server relabelled a run that reached its deadline as a timeout only
after the harness had built its observations, so a command the sandbox ended
at the deadline could emit an invocation with status "failed" next to a
"timeout" termination. The harness now applies the deadline itself before
deriving observations, and reports a timed-out invocation as "incomplete" with
error_type "TimeoutError", matching Terminus 2.

The TB4 resources server kept only the first exception, so a verifier timeout
after an agent timeout was reported as AgentTimeoutError. The verifier's
exception is now also recorded as verifier_exception_info and is what the
verify response reports when there is no reward. exception_info is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Giulio Lovisotto <[email protected]>
@giuliolovisotto giuliolovisotto added bug Something isn't working area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers area:agent Agent harnesses and Responses API agent behavior labels Oct 8, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

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

area:agent Agent harnesses and Responses API agent behavior area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant