Repository navigation
test: deflake three timing-sensitive Harbor and OpenCode tests - #5721
Conversation
- harbor test_a_multi_step_task_longer_than_the_default_gets_its_own_budget: snapshot the task before asserting episode_timeout_seconds, whose lookup is bounded by the 0.1 s default and fell back to it on a slow runner. - harbor test_interrupted_verifier_start_is_stopped_by_the_episode: cancel the episode once the fake verifier start is entered instead of racing a 0.5 s episode deadline against the setup before it. - opencode test_optional_diagnostics_preserve_valid_terminal_result: give the artifact capture a 30 s close budget instead of the fixture's 1 s. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no concerns found. I reviewed all three changed tests and traced their task-budget, verifier cancellation/cleanup, and OpenCode artifact-capture paths. The changes retain the relevant behavioral assertions while reducing sensitivity to runner speed.
Static review only; I didn't execute tests.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
Every HTTP-flow test in the file runs the artifact capture under session_close_timeout_seconds; 1 s flaked on loaded CI runners, and an injected 1.5 s snapshot stall failed 83 of the 197 tests. No test relies on the 1 s value. Replaces the per-test override in the previous commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
…st_episode_deadline_stops_the_sandbox The 0.1 s deadline also covered the task snapshot and the seed; a slow runner expired it before the harness turn, so the close call was never made (IndexError on server_client.paths()). The episode now gets a 3600 s deadline and the turn expires that same deadline, so the timeout path is still exercised, at a fixed point. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
|
/ok to test b62931a |
…ine test test_hanging_export_is_bounded_by_the_collection_budget shares the sandbox-session fixture and relies on the close budget expiring; with the fixture at 30 s it hit its own 10 s guard. Set 1 s locally, as the fixture comment says a close-deadline test should. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
|
/ok to test 7473e63 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42314435071 |
Resolve the task snapshot before the slow-seed regression enters its 0.1-second lookup timeout. A slow CI snapshot otherwise selects the fallback episode budget and times out before sandbox creation, which is independent of the seed-budget behavior this test covers. Retain the real slow seed, both scored turns, and elapsed-budget checks. The separate slow-lookup regression still covers the fallback behavior. Follow the snapshot setup pattern used for the adjacent test in #5721. Validation on Linux workstation (Python 3.13.14): - Harbor suite: 698 passed. - pre-commit run --all-files: passed. - Injected 0.25-second snapshot: original test fails; fixed test passes. - Runtime changes and model rollouts: N/A (test-only timing isolation). Signed-off-by: yaoyu-33 <[email protected]>
…5082) * feat(copilot): add a sandboxed Copilot CLI agent server Signed-off-by: yaoyu-33 <[email protected]> * fix(agent): preserve zero completed usage for rejected Copilot calls Signed-off-by: yaoyu-33 <[email protected]> * fix(model): accept Copilot replay of null response annotations Signed-off-by: yaoyu-33 <[email protected]> * fix(agent): retain Copilot sandbox execution evidence Signed-off-by: yaoyu-33 <[email protected]> * fix(model): normalize Copilot background tool provenance Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): avoid partial usage totals after compaction Signed-off-by: yaoyu-33 <[email protected]> * docs(copilot): declare tested sandbox benchmark pairings Signed-off-by: yaoyu-33 <[email protected]> * docs(copilot): clarify evidence limits at agent deadlines Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): detect late compaction in native session state Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): preserve native startup error diagnostics Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): preserve prompts beginning with dash Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): hide the sandbox runner from pkill python Main now runs the shared supervisor as gym-supervisor from a file without a .py suffix (NVIDIA-NeMo#4805), and the Copilot test fake still matched process_supervisor.py, so 17 tests failed after merging main. Opt the Copilot runner in the same way as Pi, Codex, OpenCode and OpenClaw: upload it as sandbox_runner and set stdlib_runner, so a task agent's pkill -f python3, pkill python3 or killall python3 cannot stop the runner and end the episode. The post-run compaction probe uses the same file. The session fake now asserts the runner launches as bin/gym-runner. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): keep usage unknown when a reported call has no span Aggregate usage was summed over Copilot's OpenTelemetry chat spans alone, and model-call references came from the spans whenever any existed. If the file exporter lost a span, for example when Copilot stopped before flushing, the response published a subtotal as the total and dropped that call's reference without a gap. Treat any response ID from Copilot's events that has no chat span as missing coverage: usage stays unknown with a model_usage_spans_missing gap, and model-call references are the spans' IDs plus any event-only IDs. The provider-error test now carries the span for its first, successful call. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): keep the legacy relay migration off the session-only agent copilot_agent.yaml binds resources_server: null and Copilot has no compatibility /run, but the migration script did not know the agent type, so `--check` reported a legacy relay to add and test_repository_configs failed. Exempt Copilot the same way as Stirrup, and add a regression test that the default config composes with exactly one session Environment Server. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): fail a run only on errors that end Copilot's run Every session.error became the response error, so a run whose root agent finished with a final message came back failed, and the default outcome policy retried or failed it. Copilot 1.0.103's own exit status ignores errors from sub-agents (agentId, data.agentId or data.parentToolCallId), hook errors, and a model_call error that a later root assistant message recovers from (cli-main.js pyo() and its session status tracker). Apply the same rule; an unrecovered root model_call error still fails and stays classified. Also correct two usage gaps: - Observed or unreadable compaction no longer adds partial_model_usage_unavailable ("a model call reported no usage"), which was false when every chat span reported usage. - Rename native_compaction_state_unavailable to compaction_state_unavailable, following the AGENTS.md naming rule before the code reaches retained rollouts. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(model): accept Copilot replay of empty response annotations The replay normalizer dropped assistant annotations only when null. The openai SDK types Chat Completion annotations as an optional list, and the OpenAI Model Server passes the upstream message through, so a provider that returns "annotations": [] made Copilot's next request fail strict validation with a 422. An empty list carries no citation, so drop it too; non-empty annotations still fail. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * docs(copilot): align the TB2.1 and harness tables with the adapter - TB2.1: list Copilot in the intro and in the per-call cap and request-level max_output_tokens sentences, both of which apply to it. - TB2.1: Copilot's context_window is a prompt-token limit, so the 32k smoke example now leaves room for max_output_tokens (24576 + 8192). The adapter README says how to choose it. - Integrate Existing Agents: training-token capture is not wired up for Copilot, matching the other adapters' wording and its README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * test(copilot): keep the runner from waiting on a detached tool's stdout The runner drains Copilot's stdout after Copilot exits without waiting for EOF, because a tool that starts a service can inherit the pipe. Lock that in with real processes: a fake Copilot leaves a sleeping child that holds stdout and ends with an event that has no trailing newline. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * test(copilot): count chat spans that have no assistant event Usage coverage requires a span for every response that Copilot's events report, not equal ID sets. Lock in that background calls, which have chat spans but no assistant event, still add their counts and model-call references. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): keep Copilot's secret masking out of recorded output Copilot registers its BYOK provider key and header values as secrets and writes "******" in their place in every event: model text, reasoning, tool output, tool-call IDs and timestamps. The adapter sent the short capture key as x-session-id and "EMPTY" as the key, so a real NIM smoke recorded "2026-11-03" as "2026-1******3" for capture key "1-0", lost tool timing, and rewrote tool-call IDs containing "2-0". The model itself saw the original text, so recorded trajectories no longer matched it. Send a random per-session invocation ID as x-session-id, use it for the close observations, and send a random unused provider key. The rollout ID stays in the Model Server URL, which Copilot does not mask. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * test(copilot): expect the agent route's typed failure for a native startup error Since NVIDIA-NeMo#5072 the agent route reports an adapter error as an NgFailureEvent whose cause is the adapter's RuntimeError, and replies with that cause. Assert the bounded stderr on the cause. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * build(copilot): lock the adapter environment with pyproject.toml and uv.lock NVIDIA-NeMo#4837 replaced server requirements.txt files with committed uv projects and forbids requirements.txt. Copilot's requirement was the same as Pi's (nemo-gym[dev,sandbox] from the repository), so its pyproject.toml mirrors Pi's and its lock is Pi's with only the project name changed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * test(copilot): import NgFailureEvent from nemo_gym.core Main moved typed_exceptions into nemo_gym.core, which exports NgFailureEvent from its public API. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): run Copilot with only bash in the task sandbox Copilot required the task image's Python for its installer, its runner and its compaction probe, which the harness contract rules out for a CLI harness. Install and launch it the way the other CLI adapters do: - Bootstrap only bash, as root with apk or apt-get, or refuse clearly. - Probe the OS, CPU and C library with one shell command and select the npm platform package on the Agent Server. A non-Linux sandbox, another CPU or glibc older than 2.28 is refused at seed (422); other probe output and registry failures stay errors to retry (500). - Read the package's tarball URL and sha512 from the registry on the Agent Server, once per registry, package and version. - Install with install_copilot_runtime.sh: flock when available, reuse only a runtime with its ready marker that passes a health check, download with curl or wget, check the sha512, unpack the binary with a private HOME, and publish the staged directory atomically. - Launch Copilot through the shared harness_runner.sh with params.sh, and read the persisted session events for compaction on the Agent Server. - Remove sandbox_runner.py, install_copilot_runtime.py and their tests. Also: - Bound the whole seed by sandbox_install_timeout_seconds, so the owned sandbox's TTL holds. - Fail setup with the installer's output when it prints no runtime record. - Treat context_window as the total window: Copilot's prompt limit is context_window minus max_output_tokens, which must be smaller. - Keep aggregate usage unknown when the telemetry file has an unreadable line, with a model_usage_telemetry_malformed gap. - Reject a prompt that cannot be one command-line argument (NUL, 128 KiB). - Drop the unused --usage-output-file. - Declare Copilot in the Terminal-Bench 2.1 benchmark config, add it to the conformance compaction settings, and update the READMEs. Signed-off-by: yaoyu-33 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(copilot): keep Copilot's default window in the compaction conformance scenario The previous commit gave Copilot the 32k compaction window in the conformance episode. Copilot then compacts for real: it sends its summary request in the background, concurrently with the policy loop, and the scripted conformance model answers strictly in sequence, so it refuses those requests and the whole context_compaction scenario fails (71 P1 checks instead of the 3 known compaction-record gaps). Restore Copilot's default window there until the scripted model can serve concurrent background compaction. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): retain ordered transcripts and failure evidence Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): validate seeds and publish runtimes safely Signed-off-by: yaoyu-33 <[email protected]> * fix(copilot): support pinned offline runtimes and owned egress policies Signed-off-by: yaoyu-33 <[email protected]> * test(harbor): isolate slow seed test from task snapshot timing Resolve the task snapshot before the slow-seed regression enters its 0.1-second lookup timeout. A slow CI snapshot otherwise selects the fallback episode budget and times out before sandbox creation, which is independent of the seed-budget behavior this test covers. Retain the real slow seed, both scored turns, and elapsed-budget checks. The separate slow-lookup regression still covers the fallback behavior. Follow the snapshot setup pattern used for the adjacent test in NVIDIA-NeMo#5721. Validation on Linux workstation (Python 3.13.14): - Harbor suite: 698 passed. - pre-commit run --all-files: passed. - Injected 0.25-second snapshot: original test fails; fixed test passes. - Runtime changes and model rollouts: N/A (test-only timing isolation). Signed-off-by: yaoyu-33 <[email protected]> * test(kilocode): allow cleanup scheduling slack in CI Use a ten-second test cleanup budget for real process scanning and receipt polling on shared CI hosts. Preserve termination, process-group, cleanup receipt, transport, and repeated-close assertions. Signed-off-by: yaoyu-33 <[email protected]> * test(agentic-if): isolate resume checks from concurrent source changes Signed-off-by: yaoyu-33 <[email protected]> --------- Signed-off-by: yaoyu-33 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
What
Four unit tests fail intermittently in
Unit tests / Server suite (shard 0). They failed on the scheduledmainrun 42061454817 and on #3664 (job). Each one depends on how fast the runner is. This PR changes tests only.harbor/tests/test_multi_turn.py::test_a_multi_step_task_longer_than_the_default_gets_its_own_budgetassert 0.1 == 77.2.episode_timeout_secondsgives the cold task snapshot only the 0.1 s default and falls back to it onTimeoutError(app.py:833-837)._resolve_taskbefore the assertion. The cached, already-done result returns without yielding, so thewait_forcannot expire.harbor/tests/test_review_regressions.py::test_interrupted_verifier_start_is_stopped_by_the_episodeverifier.stoppedwas False. The 0.5 s episode deadline also covers the snapshot, seed, harness run and artifact collection. On a slow runner it fired before the verifier sandbox was created, so there was nothing to stop.start()sets anasyncio.Event. The test cancels the episode only after that point and asserts that cleanup stopped both sandboxes.harbor/tests/test_app.py::TestAgentStage::test_episode_deadline_stops_the_sandboxIndexErroronserver_client.paths()[-1]. The 0.1 s deadline also covered the snapshot and seed and expired before the harness turn.asyncio.Timeoutfrom the harness turn: a module-scoped wrapper records it and a turn hook callsreschedule(now). The real deadline → "Episode timed out" path is still exercised, at a fixed point.opencode_agent/tests/test_sandbox_sessions.py::test_optional_diagnostics_preserve_valid_terminal_resultTimeoutError. The fixture's 1 ssession_close_timeout_secondsbounds the artifact capture of every HTTP-flow test in the file.test_sandbox_extensions.py::test_hanging_export_is_bounded_by_the_collection_budget) sets 1 s locally.Verification
I injected delays with pytest plugins on
mainand on this branch:Harbor budget test. A delay of 0.09 s or more in
_snapshot_taskreproduces the exact CI error onmain. This branch passes, including with the event loop blocked for 0.5 s on each lookup. Instrumentation shows the swallowed exception is only the lookup'sTimeoutError.Verifier-start test. A 1.2 s delay in any stage before the verifier is created reproduces the exact CI error on
main: the snapshot, seed, agent harness, artifact collection, or verifier create. In every one of those cases the verifier key was never registered.start()is awaited (sandboxes.py:879-880). Every run where the deadline landed after registration stopped it.finallyblocks and cleanup.test_app.pyandtests/unit_tests/server_runtime/test_environment_server.py.OpenCode diagnostics test. A 1.5 s fake-snapshot stall fails the test on
mainwith the CI error. With the old 1 s fixture it also fails 83 of the 197 tests in the file. With this change all 197 pass under that stall, and wall time without delays is unchanged (~22 s). The whole OpenCode suite passes (801 passed, 22 skipped).Full files.
test_multi_turn.py+test_review_regressions.py: 147 passed.test_sandbox_sessions.py: 197 passed.pre-commit passes on the changed files.
Deadline test. A 1.2 s snapshot or seed delay fails it on
mainwith theIndexError. This branch passes with no delay and with snapshot, seed and harness delays.test_app.py: 260 passed.🤖 Generated with Claude Code