Skip to content

fix(openclaw): preserve replay identity and startup timeout outcomes - #5379

Open
yaoyu-33 wants to merge 12 commits into
NVIDIA-NeMo:mainfrom
yaoyu-33:codex/gymint-667-openclaw-conformance
Open

yaoyu-33 wants to merge 12 commits into
NVIDIA-NeMo:mainfrom
yaoyu-33:codex/gymint-667-openclaw-conformance

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

The sandboxed OpenClaw adapter now executes a dataset tool called by its bare name, such as bash_command, when that name identifies one granted MCP tool. The original qualified name still works. Both names call the same implementation. Ambiguous names and names already used by native tools keep their qualified MCP spelling. This addresses the extra model request and mixed replay reported during training. Review reproduction

The bundled provider plugin preserves the model's original tool name, call ID and reasoning on the next request. On OpenClaw 2026.11.5, the CLI can load a cached copy of the plugin, so the adapter passes an explicit per-session path for its readiness receipt. Missing replay evidence after activity raises a typed harness failure. A confirmed startup timeout before any model or tool activity remains eligible for verification.

CLI prechecks and provider refusals that report context_overflow now return model_context_limit to the Environment Server with the original message, partial output and usage. The default policy fails the episode. An explicit verify grades the partial result and retry requests another attempt. Worker cleanup failures retain precedence. The PR review tracks both regressions.

Verification at bc00627c20

Merged main at dd09637342 and tested the resulting tree on Linux with Python 3.13.14, Node 24.22.3 and OpenClaw 2026.11.5.

Check Result
OpenClaw adapter, scripted harness tests, harness capabilities, conformance tooling, agent outcomes and session contract 1,610 passed, 7 skipped. One skip was the non-root Docker regression, which passed in a separate run on the workstation. The other six require optional NOOA or Jujutsu tooling.
Non-root Docker upload and provider plugin Both tests passed, including executing the hook as UID 65534.
Real CLI and HTTP MCP regression A bare call and a qualified call executed exactly once each. Three model requests included the final answer. IDs, names, arguments and reasoning matched on replay. Reward 1 on both 2026.11.5 and 2026.6.11. With only the alias hook disabled on 2026.11.5, zero tool executions and zero verifications completed.
Real model rollout Qwen3-4B (Q4_K_M) made two model calls and executed the bare bash_command once. The follow-up request preserved the call ID, arguments and all 1,417 reasoning characters. The verifier returned reward 1 and the session closed. Nano 4 RL training and token-ID/logprob fidelity remain unverified.
Repository hooks and DCO pre-commit run --all-files and git diff --check passed. The private guardwords catalog was unavailable to the hook. Both follow-up commits carry DCO sign-off.

The full scripted conformance run passed 7 of 8 P0 scenarios. The remaining P0 scenario and the P1 compaction scenario reproduced on clean main under the same runtime with identical failing checks.

  • tool_failure recovered from exit 7 and earned reward 1 on both trees. The saved tool status differed from the independent tool witness.
  • context_compaction sent additional requests after the scripted provider's final answer. Both runs made 24 model attempts and ended without verification.
HARNESS=openclaw python -m pytest -q -o addopts= --import-mode=importlib -o log_cli=false -rs \
  responses_api_agents/openclaw_agent/tests scripts/harness_conformance/tests \
  tests/unit_tests/rollouts/harness_capabilities tests/unit_tests/tooling/test_harness_conformance*.py \
  tests/unit_tests/agents/test_agent_outcome.py tests/unit_tests/test_session_contract_repo.py
python -m scripts.run_harness_conformance --harness openclaw --output "$output" --timeout 150
Earlier validation on OpenClaw 2026.6.11, including the superseded overflow behavior

OpenClaw 2026.6.11 rewrites tool-call IDs when replaying custom-provider responses. This change loads a bundled provider plugin, in sandbox sessions only, whose replay policy keeps tool-call IDs and reasoning as the model produced them while OpenClaw's openai-completions turn repairs (assistant-first ordering, Gemini and Anthropic turn validation) stay on. The adapter requires the plugin's per-session readiness receipt and retains transcript evidence when the hook fails.

A short task budget can expire during CLI startup before the receipt exists. The guard previously turned that confirmed timeout into HTTP 500, skipping verification. The fix returns an incomplete response only when there is no receipt, output, token usage, or assistant/tool activity. Wrong receipts and partial trajectories still fail.

After #5119 and #5120 merged, model-error/capture-ownership handling and conformance registration are inherited from main. This PR adds the replay plugin and its regression coverage, preserves startup-timeout handling, documents validation commands, and removes duplicate registration/configuration/install tests from the merge. No separate public issue is needed for these reproduced adapter regressions.

Review follow-up at e6d5681f57764835bfe588f97a0568011ebcf375 (2026-11-12)

Closed the non-root Docker validation gap from review. The existing directory-creation fix remains unchanged. The new regression uses the real DockerProvider upload path, runs the bundled provider hook as UID/GID 65534, and checks that the plugin directory and readiness receipt belong to UID 65534 and the receipt contains the expected text. Removing the directory-creation fix makes this test fail with EACCES; restoring it passes.

Also repaired the pinned-CLI test fixture: when it moves the session into its temporary directory, it now moves the staged plugin files too. This lets the test reach the real OpenClaw termination check instead of failing the replay-receipt guard during its fake setup.

Validation on Linux ws, Python 3.13.14, Node 22.19.0, OpenClaw 2026.6.11:

  • 551 adapter tests passed; zero failures or skips, including the non-root Docker regression and real pinned-CLI process-supervision test.
  • Full pre-commit run --all-files passed (pre-commit 4.3.0), with no generated changes. git diff --check and DCO sign-off passed.
  • Source imports and the exact tested Git tree were verified. Test containers were removed.
  • The locally built Docker test image used cached python:3.13-slim plus the pinned Node binary; image ID sha256:f487d13ddd1472ab6a856a750b465fa58f4831636d96b123b7d0c5e26d5a60fd. The test disables networking and image pulls.
  • No new model smoke: this follow-up changes tests only. The real-model evidence below remains historical. Full repository CI on the new head remains pending.
export GYM_TEST_OPENCLAW_DOCKER_IMAGE=gym-openclaw-pr5379-nonroot:20261112
export GYM_TEST_OPENCLAW_NODE=/tmp/nemo-gym-openclaw-node-22.19.0-2026.6.11/node/bin/node
export GYM_TEST_OPENCLAW_ENTRYPOINT=/tmp/nemo-gym-openclaw-node-22.19.0-2026.6.11/openclaw/node_modules/openclaw/openclaw.mjs
python -m pytest responses_api_agents/openclaw_agent/tests \
  -q -o addopts= --import-mode=importlib -o log_cli=false -rs \
  --junitxml="$task_root/evidence/adapter.xml"

The Docker regression is optional unless GYM_TEST_OPENCLAW_DOCKER_IMAGE names an available local image with Bash and Node 22.19.0 or newer.

Review fixes at 4ecf184b6 (after merging main in 26b49e297):

  • Non-root sandboxes. Session preparation creates provider_plugin/ (with home/.openclaw) as the sandbox user. A provider's upload may create a missing parent directory as root, and the plugin writes its receipt beside itself, so on a non-root Docker sandbox every activation failed the receipt guard. This is the regression found in review.
  • Replay policy. The plugin turns off only tool-call ID sanitization and reasoning removal; the openai-completions turn repairs listed above stay on.
  • Receipt guard. A missing or wrong receipt fails with HTTP 502 that keeps the worker's own error, and MCP skip gaps are recorded before the guard raises.
  • Tests. The fake sandbox writes the receipt only when the plugin is staged and enabled. A node test checks the plugin's policy and receipt text. New cases cover a startup crash, stdout-only activity and MCP gaps. Tests duplicated by main are dropped.

Validation at 4ecf184b6 on macOS. Each new test fails with its fix removed.

  • The changed test files (test_sandbox.py, test_mcp_grants.py, test_bootstrap.py, test_provider_plugin.py): 329 passed.
  • responses_api_agents/openclaw_agent/tests: 481 passed, 37 skipped (Linux-only process supervision, runtime install and pinned-CLI tests), 1 failed. The failure is test_opensandbox_sdk_is_available_in_agent_environment, because the local venv has no opensandbox; the merged tree fails it the same way before these fixes.
  • tests/unit_tests/test_session_contract_repo.py, tests/unit_tests/tooling/test_add_legacy_agent_environment_servers.py and scripts/harness_conformance/tests/{test_openclaw_errors,test_runner,test_ci_install}.py: 281 passed, 10 skipped (the pinned-Linux-CLI conformance tests).
  • pre-commit run --files <the 8 changed files> and DCO sign-off: passed.

Validation at 7919a68de on macOS, after merging main (which adds this adapter's benchmark profile; the only conflict was the README, where both sections are kept):

  • responses_api_agents/openclaw_agent/tests: 483 passed, 37 skipped, 1 failed. The two new passes are main's test_benchmark_profile.py; the failure is the same missing opensandbox module.
  • scripts/harness_conformance/tests: 182 passed, 12 skipped; tests/unit_tests/environment/test_session_harness_benchmark_profiles.py: 18 passed.
  • pre-commit run --files responses_api_agents/openclaw_agent/README.md and DCO sign-off: passed.

Validation at 3b00cfdb2285712d96277b2de0100228b008b45f on Linux x86_64, Python 3.13.14, OpenClaw 2026.6.11, Node 22.19.0:

  • HARNESS=openclaw python -m pytest responses_api_agents/openclaw_agent/tests scripts/harness_conformance/tests tests/unit_tests/harness_capabilities tests/unit_tests/test_harness_conformance_ci.py tests/unit_tests/test_session_contract_repo.py --import-mode=importlib -q -o addopts= -o log_cli=false --tb=short -rs: 987 passed, 2 skipped (optional jj tests). The pinned CLI termination test was enabled with the runtime environment variables documented in the adapter README.
  • python scripts/run_harness_conformance.py --harness openclaw --output <fresh-output-directory>: all 8 scenarios pass every applicable P0 check.
  • The real CLI startup regression confirms incomplete response, verifier reward 0, no model attempts, and confirmed cleanup. The replay regression directly compares original and replayed IDs.
  • Two startup-timeout unit cases fail against the original guard and pass after correction.
  • pre-commit run --all-files, git diff --check, and DCO sign-off passed.

Compatibility: startup timeout retains the existing incomplete/gradable behavior. Missing replay assurance after model/tool activity remains an infrastructure failure, now HTTP 502 with the worker's error instead of 500; the Environment Server retries both. User plugins remain unsupported. No benchmark setup, verifier, dataset, or shared process-lifetime policy is changed.

Rollout evidence: the review smoke at 3b00cfdb2 (Linux ARM64, OpenClaw 2026.6.11, gpt-oss-120b) completed with reward 1: two captured model calls, two policy turns and one successful shell tool. The follow-up request kept the original tool-call ID and all 467 characters of reasoning, the plugin receipt and worker termination were confirmed, and rollout health was clean. It used the local sandbox provider inside a root Docker container, so it does not cover upload ownership in a non-root Docker sandbox, which 4ecf184b6 fixes.

Not yet run at 4ecf184b6 or 7919a68de: a real-model smoke, a non-root Docker sandbox run, the pinned Linux CLI tests and the conformance probes. Full repository CI, real-model/sandbox pairing qualification (TB 2.1 and GDPVal), and training token-ID/logprob fidelity remain separate gates. Known follow-ups outside this PR: telling a failed artifact read apart from a missing artifact in the startup-timeout check, and reporting aggregate usage as unknown when per-call usage coverage is incomplete.

Update at c739747a1a: merge main, context overflow, typed receipt failure

Merge. d67d0a5b7 merges main (acb67734cc). Two files conflicted:

  • app.py: main's sandbox_runtime_dir check now sits beside the runtime installer. The provider plugin upload runs after either path.
  • README.md: kept main's note that the HLE-style judges grant no tools, plus this PR's "Conformance checks" section.

test_sandbox.py and test_runner.py merged without conflicts.

Context overflow is graded as incomplete (1790174862). This changes scores: a context overflow goes from FAIL to graded incomplete. OpenClaw reports a context overflow as an error of kind context_overflow in its JSON output, whether its own precheck or a provider refusal caught it. Before this change, the adapter turned that into a failed response with ng_agent_outcome model_context_limit, and the Environment Server's default policy fails such a response: it is neither graded nor retried. The adapter also reached that path only through the exit-code gate; with any other exit code it answered HTTP 502.

The activation now answers HTTP 200, whatever the CLI's exit code. The response has:

  • status="incomplete"
  • incomplete_details.reason max_output_tokens, the reason vllm_model gives a context-length refusal (the Responses API has no context reason)
  • the partial output and usage
  • no ng_agent_outcome

The Environment Server therefore verifies it. A missing or failed cleanup receipt still fails the activation.

Typed replay-receipt failure (c739747a1a). The bare HTTP 502 for a missing or wrong replay-policy receipt is now a harness NgFailureEvent: agent_route_failed, operation openclaw.replay_policy, stage agent. The receipt is the harness's own evidence that it replays model turns under the policy the adapter configured, so a run without it contradicts that configuration. It is not a sandbox or provider fault, and not a negative cleanup receipt (harness_termination_unconfirmed), because termination was confirmed. The failure reason keeps the worker's own error.

The disposition is unchanged. The agent route answers 5xx and the typed failure travels in the failure header. The Environment Server turns it into a non-terminal episode failure, so the attempt stays ungraded and is rerun under the attempt cap. This replaces the HTTP 502 described under "Compatibility" above.

Validation at c739747a1a (macOS, primary venv with this worktree first on the path):

  • responses_api_agents/openclaw_agent/tests and scripts/harness_conformance/tests: 700 passed, 53 skipped, 1 failed. The failure is the same missing opensandbox module as before.
  • Against the merged tree's earlier app.py, 27 of the new or updated cases fail: 16 context-overflow cases and 11 receipt cases.
  • tests/unit_tests/test_public_api_facades.py, tests/unit_tests/tooling/test_migrate_imports.py and tests/unit_tests/test_session_contract_repo.py: 903 passed.
  • pre-commit run --files <changed files> and DCO sign-off: passed.

The Linux-only pinned-CLI regression test_openclaw_errors.py now expects both context cases (context-http, context-precheck) to reach the verifier as incomplete responses with reward 0. Neither case was run here.

Scripted-model smoke (no real model): not run. On macOS the session path cannot start, because the process supervisor needs /proc and the runtime installer requires Linux; there is no Docker here. The pinned Linux CLI tests above are pending CI or a Linux host.

@copy-pr-bot

copy-pr-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@yaoyu-33 yaoyu-33 added bug Something isn't working area:agent Agent harnesses and Responses API agent behavior complexity:medium Single-domain change with interacting parts or a moderate review surface labels Oct 30, 2026
@yaoyu-33
yaoyu-33 marked this pull request as ready for review November 3, 2026 05:33
@yaoyu-33 yaoyu-33 changed the title fix(openclaw): preserve model identity and register conformance probes fix(openclaw): preserve replay identity and startup timeout outcomes Nov 3, 2026

@giuliolovisotto giuliolovisotto 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.

Requesting changes for the non-root Docker regression below.

Validated 3b00cfdb2285712d96277b2de0100228b008b45f on Linux ARM64 with OpenClaw 2026.6.11 and Node 22.19.0:

  • 515 adapter tests passed; three additional pinned-CLI checks passed (startup timeout, replay identity, and supervised termination).
  • A fresh real-model smoke with gpt-oss-120b completed with reward 1: two captured model calls, two policy turns, and one successful shell tool. The output file was checked independently.
  • The follow-up request preserved the original tool-call ID and all 467 characters of reasoning exactly. The plugin receipt and worker termination were confirmed; rollout health was healthy with no findings or unobserved checks.

The smoke used the local sandbox provider inside a root Docker container, so it does not cover DockerProvider's file-upload ownership behavior.

@github-actions github-actions Bot added the sla:author-overdue Author response is over the one-business-day SLA label Nov 4, 2026
yaoyu-33 and others added 2 commits November 4, 2026 20:31
…d causes

- Create provider_plugin/ as the sandbox user during session preparation.
  A provider's upload may create a missing parent as root, and the plugin
  writes its readiness receipt beside itself, so non-root sandboxes failed
  every activation.
- Keep OpenClaw's openai-completions turn repairs in the plugin's replay
  policy (assistant-first ordering, Gemini and Anthropic turn validation);
  only tool-call ID sanitization and reasoning removal are turned off.
- Fail a missing or wrong readiness receipt with HTTP 502 that keeps the
  worker's own error, and record MCP skip gaps before the guard raises.
- Name the receipt path and text once in sandbox.py.
- Tests: seed upload parents exist after preparation; the fake sandbox
  writes the receipt only when the plugin is staged and enabled; plugin
  upload and config asserted; node test of the plugin's policy and
  receipt; startup-crash cause, stdout-only activity and MCP-gap cases;
  drop tests duplicated by main and use the nemo_gym.trajectory import.
- README: the plugin loads only in sandbox sessions; 502 on a missing
  receipt.

Signed-off-by: yaoyu-33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4ecf184

Keep main's benchmark-profile paragraphs in the sandbox section of the
OpenClaw README and the branch's conformance-checks section after them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7919a68

@github-actions github-actions Bot removed the sla:author-overdue Author response is over the one-business-day SLA label Nov 5, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 6, 2026 22:06
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 7, 2026
yaoyu-33 and others added 3 commits November 9, 2026 10:22
Resolve two conflicts:
- app.py: keep main's sandbox_runtime_dir check beside the runtime
  installer, then upload the provider plugin after either path.
- README.md: take main's note that HLE-style judges grant no tools, and
  keep this branch's Conformance checks section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
OpenClaw reported a context overflow (the CLI's typed `context_overflow`
error, from its own precheck or a provider refusal) as a failed response
with `ng_agent_outcome` `model_context_limit`, which the Environment
Server's default policy fails: neither graded nor retried. It also reached
that path only through the exit-code gate (exit 0, or exit 1 with a
FailoverError line); any other exit answered HTTP 502.

A context overflow is a limit, not a failure. Whatever the CLI's exit code,
the activation now answers HTTP 200 with `status="incomplete"`,
`incomplete_details.reason` `max_output_tokens` (the reason vllm_model gives
a context-length refusal; the Responses API names no context reason), the
partial output and usage, and no `ng_agent_outcome`, so the Environment
Server verifies it. A missing or failed cleanup receipt still fails the
activation.

This changes scores: a context-overflow row goes from an ungraded FAIL to a
graded incomplete response.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…s failure

When OpenClaw ends a run without the provider plugin's replay-policy
receipt, the activation answered a bare HTTP 502. The Environment Server
got no typed cause, so the row could not say why the attempt was rerun.

Raise it as a harness failure, `agent_route_failed` with operation
`openclaw.replay_policy` (stage agent): the receipt is the harness's own
evidence that it replays model turns under the policy the adapter wrote,
so a run without it contradicts that configuration. It is not a sandbox or
provider fault, and not a negative cleanup receipt
(`harness_termination_unconfirmed`): termination was confirmed. The reason
keeps the worker's own error, such as a startup crash.

The disposition is unchanged: the agent route answers 5xx with the typed
failure in its failure header, which the Environment Server turns into a
non-terminal episode failure, so the attempt stays ungraded and is rerun
under the attempt cap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c739747

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 16, 2026

@giuliolovisotto giuliolovisotto 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.

The original non-root Docker upload-parent issue is fixed in code, and the new DockerProvider regression covers receipt ownership. Thank you for adding that coverage.

One blocking issue remains: context overflow now bypasses the caller's configured outcome policy. In responses_api_agents/openclaw_agent/app.py, the typed context_overflow is returned as incomplete without ng_agent_outcome. agent_outcome_policy therefore returns VERIFY before consulting configuration. A caller that explicitly sets by_failure_kind={"model_context_limit": "fail"} and default_action="fail" still gets grading. test_context_overflow_is_an_incomplete_graded_response explicitly asserts this override is ignored.

Please preserve the model_context_limit classification and route the decision through the Environment Server's configured outcome policy. If grading is the desired default, express that through policy while retaining explicit fail/retry overrides. Otherwise this changes benchmark scoring even for callers who explicitly configured context overflow to fail.

Reviewed at e6d5681f57764835bfe588f97a0568011ebcf375, including the prior review and author replies. Fresh tests could not run because the available local environment lacks pytest; the reported Linux results were not independently reproduced in this review.

@github-actions github-actions Bot added sla:author-overdue Author response is over the one-business-day SLA and removed sla:review-overdue Review response is over the one-business-day SLA labels Nov 16, 2026
@zyzhou5

zyzhou5 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

When I was testing OpenClaw in Nano 4 RL training, I noticed the following token-capture issue. Please consider fixing it in your line of work:

  • When the model calls a dataset tool by its bare name (bash_command instead of browsecomp_advanced_harness_re__bash_command), OpenClaw deletes the call, asks the model again, and replays a mix of both replies. This PR's plugin could map the bare name to the prefixed tool.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:high Autobot PR risk: high label Dec 1, 2026

@giuliolovisotto giuliolovisotto 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.

Reviewed bc00627 against main and the previous reviewed head. The context-overflow blocker is resolved: model_context_limit and the original partial response reach the environment outcome policy, with explicit fail/verify/retry coverage and cleanup failures retaining precedence. The replay plugin also preserves IDs/reasoning and adds guarded aliases for uniquely named granted MCP tools. No blocking findings in the reviewed scope.

Local validation: 478 passed, 1 skipped across provider-plugin, sandbox, MCP-grant and agent-outcome tests; five configuration tests failed because the installed Gym distribution metadata requires an older OpenAI version than this checkout. JavaScript syntax and git diff --check passed. Linux CLI, non-root Docker and real-model checks were not independently rerun here.

@yaoyu-33
yaoyu-33 enabled auto-merge December 1, 2026 01:15
@github-actions github-actions Bot removed the sla:author-overdue Author response is over the one-business-day SLA label Dec 1, 2026

This branch was previously deployed

1 inactive (outdated) deployment
public — c739747a Deployed Nov 9, 2026 by copy-pr-bot[bot] via release / finalize / notify #11104
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 bug Something isn't working complexity:medium Single-domain change with interacting parts or a moderate review surface needs-review PR is ready for code review and waiting on a reviewer risk:high Autobot PR risk: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants