Skip to content

[NVBug 6899731] Flag OpenClaw-synthesized replies instead of recording them as natural model turns #4525

Open

Description

@qiaochuz-nv

Queue rank 36/48 · Difficulty 3/5 · Status on main: not_fixed

NVBug: https://nvbugspro.nvidia.com/bug/6899731 · Priority: Unprioritized · ARB: Ananth Subramaniam
GitHub: none found. Related: PR #4234 (open, timeouts only), PR #3637 (merged), PR #3621 (merged)

Summary

openclaw_agent records assistant text that OpenClaw synthesizes itself (gap-fill copies and incomplete-turn error payloads) as completed model turns. The rollout is saved as a natural finish: finished_naturally=True, failure_kind=None, turns_used counts the synthetic message. Downstream consumers cannot tell these reward-0 rows from genuine completions. Reward and mask_sample stay correct; only the reporting is wrong.

Reproduction

Model-free (recommended): the repro drives parse_openclaw_output / parse_openclaw_session_items with an OpenClaw-shaped transcript+envelope; no server, no model. Live: run environments/openclaw_math README flow; task 0 often ends with an assistant message equal to an earlier one after .strip(), or equal to "Agent couldn't generate a response.", with finished_naturally=true.

Root cause (confirmed)

Three spots in responses_api_agents/openclaw_agent/app.py, all unchanged on main:

  • parse_openclaw_session_items (:191-316, return at 316) keeps any assistant event with text; never checks api/provider/stopReason, so the gap-fill api:"cli" message becomes a model turn.
  • _text_from_openclaw_payloads (:111-119) ignores payloads[].isError, so the incomplete_turn error text becomes msg-0.
  • run() (:1452-1460) derives turns_used and finished_naturally purely from output shape.

Status on main (not_fixed)

HEAD 75bb53e. All three lines match the bug verbatim. example_rollouts.jsonl line 3 still shows the error payload as finished_naturally=True turns_used=1 (sha256 2078d53d…). Since efe58ab only #3637 and #3621 touched app.py. #3637 (merged 2026-10-10) applies its api!="cli" filter (:788) only to the usage-accounting assistants list, not to output or finished_naturally. #4234 is OPEN and covers only Gym-enforced timeouts. No fixing PR found.

Proposed fix

In app.py: (1) in parse_openclaw_session_items, exclude api=="cli" (and provider=="openclaw" transcript-only) assistant events from turns and the ends-with-assistant check; (2) in _text_from_openclaw_payloads/parse_openclaw_output, skip isError payloads and surface meta.error.kind; (3) thread a failure signal through _run_openclaw/_create_response to run(): set finished_naturally=False with failure_kind="openclaw_agent:incomplete_turn" (namespaced form allowed, failure_kinds.py:59) plus failure_reason and a WARNING log, when meta.error is set, the final message is synthetic, or exit!=0 with no output. Optionally regenerate example_rollouts.jsonl. Add unit tests in tests/test_app.py for both forms.

Validation

QA: testcases/environments/openclaw_math.py:240 unconditional expect.true(row["finished_naturally"]) masks the bug; after fix, assert False / failure field set when the final turn is synthetic. Re-run case "the README OpenClaw math stack evaluates all five examples…". Also run pytest on test_app.py.

Triage

Difficulty 3/5 — localized to one file but spans 3 functions, a reporting-contract decision coordinated with open PR #4234, new tests, and reference-data regen. Needs GPU/model: no.

Reviewer notes

Verifier confirmed not_fixed (all three functions live; #3637's api!="cli" filter at :788 affects only the usage list; #4234 open) and difficulty 3. Corrections: parse_openclaw_session_items spans :191-316 with the return at 316 (not 191-312), and #3637 merged 2026-10-10 (so "merged" is correct over the bug record's "open").

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions