Skip to content

fix(code-mode): stop bookkeeping changes hiding repeated tool loops - #159864

Merged
VACInc merged 5 commits into
mainfrom
openclaw/vito-session-loop-rca-20260927
Sep 27, 2026
Merged

VACInc merged 5 commits into
mainfrom
openclaw/vito-session-loop-rca-20260927

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: Code Mode can keep rediscovering the same tools or resuming unchanged work because changing execution titles, telemetry counters, and bridge IDs disguise repeated activity as progress.

User Impact

With loop detection enabled, repeated equivalent Code Mode activity reaches the existing warning/block/recovery path. Real output, returned data, errors, and changes to pending operations remain distinguishable. Receipts still show their original counters and IDs.

Scope: this does not classify arbitrary equivalent JavaScript rewrites, add a scheduler, alter notification settings, or make command processes survive a Gateway restart. No configuration migration, permission relaxation, or production deployment.

Why This Change Was Made

The detector compared Code Mode bookkeeping as though it were task output. Code Mode now supplies a private, immutable comparison snapshot; suspended work records the actual operation and arguments instead of a fresh bridge ID. Execution titles remain display metadata rather than action identity. Guest-owned fields with the same names retain their meaning. Automatically retained results are compared using the original guest value, not their fresh reference IDs.

Requested by @VACInc.

Work sessions

Evidence

  • Original-code regression through real Code Mode execution/catalog/before-tool admission: 2 intended failures, with 2 changing-output controls passing. Original code continued instead of blocking unchanged discovery and waits.
  • Final focused/sibling selection: 185/185 passed across 7 files in 29.21 s wrapper time, including Code Mode agent-loop, wait/cancellation, generic loop detection, result retention/ownership, wait-lane recovery and progress-card protections.
  • Test cost: pnpm test src/agents/code-mode.loop-detection.test.ts --maxWorkers=1 passed 6/6, 42.11 s wall, 511 ms test bodies on the final six-case fixture (29.26 s worker preparation). Original four-case cold run took 34.49 s wall, primarily worker preparation. Different cache states are not a claimed speedup.
  • Test audit: actual Code Mode controls and catalog receipts; no sleeps, production test seam, global worker policy, or new Gateway boot. Pending-work timing uses a fake clock.
  • Failure triage: an initial additional pending-work fixture incorrectly assumed explicit yielding and blocked calls consumed one resume each; it failed its completion assertion. Replaced that scheduling assumption with sequential controlled calls and fake time, preserving the required completion/progress assertion and production behavior. No blind reruns or widened deadlines.
  • Deslop: all changed hunks inspected; no unrelated refactor, type-laundering cast, compatibility shim, or unresolved cleanup finding.
  • Autoreview: independent P0–P2 review identified a retained-result reference-ID gap. A new real-control regression failed on that candidate, then passed after the terminal producer captured original value identity. Final seven-file review is scoped-clean, no actionable findings.
  • Core production types, all 25 selected test-type graphs, completed ratchet/boundary guards, and all three dead-export scans passed. The changed-check command then found one missing brace in the new fixture; a braces-only follow-up fixes it, and targeted lint passes with 0 errors/warnings. Functional review/test evidence is retained across that style-only change.
  • The native state-schema guard passed. The follow-up run was stopped during the repository-wide legacy-store guard at this publication checkpoint; later media/sidecar/import-cycle/auth guards were not run. Those checks are not claimed passed, and the original full changed-check command is not claimed green.
  • CI follow-through: incorporated canonical upstream repairs for Codex cleanup fixtures (687ab1d) and the Knip CLI entrypoint (0d02ab7). A later Codex fixture failed its global zero-timer assertion; real-storage setup is now scoped to the durable-receipt test instead of the three pure fake-clock cases. All delivery, release, and zero-timer assertions and timeouts remain unchanged. The original 24-file / 279-test group passes with Node 24.19.0 and two workers, matching CI’s runtime and worker budget. Targeted lint passes; independent P0–P2 review of the small isolation diff found no actionable issue. The exact two CI timers were not reproduced locally; this is a fixture-isolation repair, not a claimed production timer fix.
  • Current-head completion: CI run 36352097084 passed on 38489245064e7d2f75ee4dd8b085ef1a509b549e, including both openclaw/ci-gate checks. Final rollup: 143 passed, 48 skipped, no pending or failing checks. ClawSweeper review completed for that same head at 2026-09-27 21:38:49 UTC: no actionable findings, security findings, or before-merge items.

Merged by @VACInc at 2026-09-27 21:49:20 UTC after CI qualification: aea667c.


View the OpenClaw team session

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Sep 27, 2026
@VACInc
VACInc marked this pull request as ready for review September 27, 2026 19:59
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 5:38 PM ET / 21:38 UTC (Revision 4).

ClawSweeper review

What this changes

The branch gives Code Mode stable identities for repeated execution and wait outcomes, updates loop-detection documentation and regression tests, and narrows Codex test setup to the durable-receipt case.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still permits the reported Code Mode loop evasion, and this active PR remains a coherent fix candidate with no confirmed introduced defect.

Priority: P2
Reviewed head: 38489245064e7d2f75ee4dd8b085ef1a509b549e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused owner-boundary coverage and a narrow production change support a good rating; the latest fixture change has no confirmed defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The Code Mode tests exercise the production exec/wait controls through catalog and before-tool admission, and the PR reports improved after-fix results; the MEMBER/bot contributor-proof gate does not apply. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The Code Mode tests exercise the production exec/wait controls through catalog and before-tool admission, and the PR reports improved after-fix results; the MEMBER/bot contributor-proof gate does not apply. No stored-data contract changes.
Evidence reviewed 9 items Current-main gap: Current main hashes all exec parameters, including changing titles, and has no Code Mode private-outcome lookup; its completion path returns the displayed receipt directly.
Introduced comparison path: The pinned branch drops receipt telemetry, continuation IDs, and pending bridge IDs from its private comparison snapshot while retaining pending operation methods and arguments.
Original retained value: The completed-result producer records the guest's original value for loop comparison after creating the displayed retention receipt.
Findings None None.
Security None None.

How this fits together

Code Mode runs agent-supplied JavaScript through OpenClaw tools and returns results to the agent. The loop detector compares successive calls and results to decide whether to warn or block repeated work.

flowchart LR
A[Agent exec or wait call] --> B[Code Mode runtime]
B --> C[Displayed result]
B --> D[Private outcome identity]
A --> E[Loop detector]
D --> E
E --> F[Continue, warn, or block]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +64, Tests +174, Docs +10. Total +248 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 80 16 +64
Tests 2 177 3 +174
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 267 19 +248

Review metrics

Metric Value Why it matters
Focused regression cost 6 cases; 42.11 s wall, 511 ms test bodies The PR records that worker preparation dominates the new file's measured cost.

Technical review

Best possible solution:

Keep one Code Mode comparison path that ignores changing bookkeeping while preserving displayed receipts and distinguishing real changes in output, errors, values, and pending work.

Do we have a high-confidence way to reproduce the issue?

Yes. Current-main hashing includes changing exec titles and displayed receipt data, and the new owner-boundary tests provide a focused exec/wait reproduction path; this read-only review did not run them.

Is this the best way to solve the issue?

Yes. The patch records comparison identity at the Code Mode result producer and lets the existing loop detector consume it without changing the agent-visible receipt.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against da2bcd699bc1.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded Code Mode loop-protection defect when rolling detection is enabled.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The Code Mode tests exercise the production exec/wait controls through catalog and before-tool admission, and the PR reports improved after-fix results; the MEMBER/bot contributor-proof gate does not apply. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ToToKr: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-27T20:12:58.190Z sha 4e0605a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T20:53:35.329Z sha a0ec5f3 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T21:15:17.697Z sha 1ef2578 :: needs maintainer review before merge. :: none

Integrates upstream 687ab1d to repair the observed changed-extension CI failure.

Co-authored-by: VACInc <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Please review current head a0ec5f3. The Code Mode diff is unchanged; this head incorporates the canonical upstream Codex cleanup fixture repair (687ab1d) for the observed CI failure. Review only; no repair or merge requested.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

roboclaw-bot and others added 2 commits September 27, 2026 21:05
Resolves check-dependencies failure from the prior-CI verifier CLI missing its real entrypoint declaration.

Co-authored-by: VACInc <[email protected]>
Scope real run-attempt setup and its database worker teardown to the durable-receipt test. Keep all retry delivery, pin-release, and zero-timer assertions unchanged.

Co-authored-by: VACInc <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Current head: 3848924. The Code Mode patch is unchanged. The only new delta scopes real-database test setup to the durable-receipt case, leaving the pure fake-clock cases and all assertions intact. The original 24-file / 279-test group passes on Node 24.19.0 with two workers. Please review only; no repair or merge requested.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
…penclaw#159864)

* fix(code-mode): stop bookkeeping changes hiding repeated tool loops

Co-authored-by: VACInc <[email protected]>

* style: satisfy Code Mode regression fixture brace rule

Co-authored-by: VACInc <[email protected]>

* test(codex): isolate retry-clock fixtures from real storage setup

Scope real run-attempt setup and its database worker teardown to the durable-receipt test. Keep all retry delivery, pin-release, and zero-timer assertions unchanged.

Co-authored-by: VACInc <[email protected]>

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: VACInc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants