Repository navigation
fix(agents): strip external-content nonce so loop detection blocks repeated wrapped failures - #130261
Conversation
…tHash External-content wrappers carry a fresh anti-forgery nonce per result (createExternalContentMarkerId). The loop detector hashed the wrapper text including the nonce, so identical failing wrapped tool calls never reached the no-progress block threshold — the detector warned but never blocked, leaving the agent to loop until it gave up (openclaw#130210). Strip the wrapper nonce before hashing in extractTextContent, mirroring the existing stripVolatileSendIds treatment of per-call send ids (openclaw#89090). Only the hash is normalized; the delivered wrapper keeps its nonce, so anti-forgery is unaffected. Closes openclaw#130210 Co-Authored-By: Claude <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 27, 2026, 12:00 AM ET / 04:00 UTC. ClawSweeper reviewWhat this changesThe PR canonicalizes only external-content wrapper nonce IDs in private tool-outcome hashes so repeated equivalent wrapped errors and results reach the existing loop-block threshold. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the runtime repair is well-targeted and has inspectable after-fix local Chrome logs, but the branch contains a release-owned CHANGELOG.md edit that should be removed before merge. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherAgent tool execution records an outcome hash after each call; loop detection uses that private history to distinguish real progress from repeated failures. Network-originated errors are wrapped before model delivery, and their randomized wrapper IDs previously made identical failures appear different to the detector. flowchart LR
A[Agent tool call] --> B[Network result or error]
B --> C[External-content security wrapper]
C --> D[Private outcome hash]
D --> E[Loop detector]
E --> F{Repeated normalized outcome}
F -->|Yes| G[Block runaway execution]
F -->|No| H[Continue tool run]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +16, Tests +262, Docs +8. Total +286 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Remove the release-owned CHANGELOG.md entry, then retain the local private-outcome normalization and merge only after exact-head checks are green. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main includes each fresh external-wrapper ID in the raw outcome digest, while the wrapper generates a random 16-hex ID per result. The PR body also supplies an after-fix production-browser trace, but this review did not execute the external branch. Is this the best way to solve the issue? No as submitted: the private outcome-hash boundary is the best repair location, but the release-owned CHANGELOG.md edit should be removed because the PR body already carries the release context. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8dac217ce94e. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Reconcile the original contribution with the reviewed main baseline and normalize complete external-content envelopes only in private outcome hashes. Cover protected thrown errors, returned text, and structured results while preserving delivered content, argument hashes, and meaningful progress. This maintainer-reviewed rewrite retains the original PR as its first parent and the frozen trusted-main baseline as its second parent. Closes openclaw#130210 Co-authored-by: ruel225 <[email protected]>
|
@clawsweeper re-review Updated the existing PR with a maintainer-reviewed rewrite, preserving the original contributor and branch ancestry. The shared private outcome hash now covers protected thrown errors, returned text, and structured JSON results. Real isolated Chrome proof and configuration-default corrections are in the PR body; 178 focused tests and scoped type-aware lint pass. Full exact-head CI is still required before landing. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Narrow the generated marker capture before recording it so the real network-error loop regression also passes its owning test-type graph.
|
Merged via squash.
|
…peated wrapped failures (openclaw#130261) * fix(agents): strip external-content nonce before loop-detection resultHash External-content wrappers carry a fresh anti-forgery nonce per result (createExternalContentMarkerId). The loop detector hashed the wrapper text including the nonce, so identical failing wrapped tool calls never reached the no-progress block threshold — the detector warned but never blocked, leaving the agent to loop until it gave up (openclaw#130210). Strip the wrapper nonce before hashing in extractTextContent, mirroring the existing stripVolatileSendIds treatment of per-call send ids (openclaw#89090). Only the hash is normalized; the delivered wrapper keeps its nonce, so anti-forgery is unaffected. Closes openclaw#130210 Co-Authored-By: Claude <[email protected]> * test(agents): validate protected error marker capture Narrow the generated marker capture before recording it so the real network-error loop regression also passes its owning test-type graph. --------- Co-authored-by: ruel225 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Closes #130210.
What Problem This Solves
Fixes an issue where agents with rolling loop detection enabled repeatedly execute the same failing browser action without reaching the no-progress block threshold. Fresh external-content boundary nonces made equivalent tool outcomes look different, including protected thrown browser errors.
Why This Change Was Made
Normalize complete matching external-content envelope nonces only in the shared private outcome hash. This covers thrown errors, returned text, and structured JSON details, instead of changing only extracted result text. The existing stable serializer owns traversal; the shared SHA-256 helper replaces the local duplicate digest implementation.
Argument hashes and model-visible security envelopes remain unchanged. This is syntactic comparison, not authentication: literal or copied text matching the complete raw or JSON-escaped wrapper grammar also ignores nonce-only changes. Malformed pairs, empty IDs, invalid escaping, JSON field boundaries, and meaningful payload or metadata changes remain significant. Requiring a complete JSON document around an escaped envelope was considered and rejected: JSON parsing cannot establish provenance and would exclude valid serialized fragments in joined result text.
Thanks @ruel225 for the original diagnosis and contribution. The maintainer rewrite also fixes the protected thrown-error path and structured-result siblings that the initial text-only change missed.
User Impact
Equivalent wrapped failures now reach the existing no-progress limit while meaningful changes still count as progress. No defaults or configuration keys change: rolling-history detection requires
tools.loopDetection.enabled: true; the post-compaction guard remains enabled when that setting is unset, and explicitfalsedisables both. The documentation now states those existing defaults and the normalized-outcome contract accurately.Evidence
jsonResult,wrapWebContent, and outcome-recording contract checks pass at nested JSON depths 0 through 4 with fixed metadata. This is deterministic sibling proof, not a liveweb_fetchrun; the complete web-fetch loader was blocked by an existingunicorn-magicpackage-exports error. FreshfetchedAtortookMsvalues remain meaningful, so this PR does not claim that every repeated fetch with the same body is blocked.One browser-proof attempt timed out during setup before reaching the changed code; a fresh run with the unchanged standard timeout passed. The complete proof was repeated successfully after the runtime grammar refinements. No operator browser or running gateway was used.
Production LOC is +31/-15 (net +16), tests +262, plus focused documentation and one changelog line. The added production lines implement the single private envelope-comparison boundary, including paired-marker and JSON-string-boundary preservation; there is no new parser, object walker, configuration, dependency, or delivered-content transformation. Full exact-head hosted CI is green on
32cdc548b00676471d537bb226281ba319efdf4d: CI, Workflow Sanity.Inspectable isolated-Chrome proof: captured logs and result fields
The proof launched its own managed headless Chrome, local fixture server, browser bridge, and isolated temporary state. It invoked the real browser tool through the production before-tool wrapper and outcome recorder. The error case used an invalid key; the progress controls read a changing page counter and throw changing page errors. This is live local Chrome, not a mocked browser or an authenticated external-site test.
Baseline source:
2d386c2ea6e86404d779c5cfea97b2ca958499d7. Selected captured result fields:{"name":"identical-thrown","calls":39,"thrown":39,"blocked":0,"uniqueMarkerIds":39,"uniqueOutcomeHashes":39,"firstBlocked":null} {"name":"identical-returned","calls":39,"thrown":0,"blocked":0,"uniqueMarkerIds":39,"uniqueOutcomeHashes":39,"firstBlocked":null}After-fix command:
node --import tsx .artifacts/browser-loop-proof.mts --fixed(exit 0). Production source SHA-256:74a156483b012ed9ec4dd4bab01e882d8a824d55729168152dd9c3e9a1f516df; the subsequent CI test-typing correction does not change these runtime bytes. Captured production diagnostics:Selected captured after-fix result fields:
{"name":"identical-thrown","calls":39,"thrown":20,"blocked":19,"uniqueMarkerIds":20,"uniqueOutcomeHashes":1,"firstBlocked":21} {"name":"identical-returned","calls":39,"thrown":0,"blocked":19,"uniqueMarkerIds":20,"uniqueOutcomeHashes":1,"firstBlocked":21} {"name":"changing-returned","calls":39,"thrown":0,"blocked":0,"uniqueMarkerIds":39,"uniqueOutcomeHashes":39,"firstBlocked":null} {"name":"changing-thrown","calls":39,"thrown":39,"blocked":0,"uniqueMarkerIds":39,"uniqueOutcomeHashes":39,"firstBlocked":null} {"name":"disabled-identical","calls":25,"thrown":25,"blocked":0,"uniqueMarkerIds":25,"uniqueOutcomeHashes":1,"firstBlocked":null}Thus attempts 1–20 execute and retain fresh model-visible marker pairs; attempt 21 is the first blocked execution. Later blocked attempts eventually reach the separate global circuit-breaker count of 30. Changing outcomes still receive the pre-existing generic warning, but are not blocked.
CI repair and review disposition
The first exact-head CI run caught a test-only
string | undefinedcapture passed toSet<string>in the new boundary regression. The correction explicitly checks that capture before comparison and insertion, without a cast or weakened assertion. The 11 affected tests, owning agents-root test-type graph, scoped type-aware lint, and fresh independent reviews pass. All other selected lanes on that run passed; the complete revised-head CI run linked above now passes too.Exact local commands:
The latest ClawSweeper review found no patch-correctness or security issue. Its inspectable-proof request is addressed by the captured output above. The single changelog entry is retained under explicit maintainer direction; no released version is changed. The automated stored-data warning is not a schema or migration change: this patch changes the private comparison digest and does not add or modify a storage schema, migration, or persistence API.