Skip to content

fix(agents): stop stable tool argument churn - #112620

Merged
vincentkoc merged 18 commits into
openclaw:mainfrom
IWhatsskill:fix/tool-loop-argument-churn
Jul 27, 2026
Merged

vincentkoc merged 18 commits into
openclaw:mainfrom
IWhatsskill:fix/tool-loop-argument-churn

Conversation

@IWhatsskill

@IWhatsskill IWhatsskill commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

[AI-assisted]

What Problem This Solves

Closes #112479.

A run can repeatedly call the same tool while cycling through different arguments that all produce the same stable no-progress result. Exact-argument loop detection sees only short independent streaks, while ordinary tool and model events keep refreshing the generic activity clock, so the run can continue consuming tokens without producing a useful reply.

Why This Change Was Made

The detector now emits a warning-only argument-churn signal after at least two argument variants have each repeated three times with one shared stable result hash. The tool call remains allowed. That semantic signal owns a separate liveness clock which survives short tool/model handoffs and is suspended during policy waits; if the churn stays continuous until the existing stale-run boundary, owner-bound recovery aborts the embedded run and drains its lane. A novel argument, a distinct result, later model progress after tool activity stops, disabled loop detection, run replacement, or lifecycle cleanup clears the churn evidence.

Root Cause

Exact (toolName, argsHash, resultHash) streaks cannot represent semantically identical no-progress work split across several argument hashes. Reusing the generic run activity timestamp also cannot solve this because each mechanical tool/model event makes a continuously churning run look fresh.

Safety boundary

Argument churn is warning-only and never vetoes the next tool call. Cross-variant no-progress requires one shared stable result hash, while compatibility escapes clear the semantic clock. Existing critical exact-repeat, polling, ping-pong, and global breakers keep their precedence.

Runtime ownership

The detector classifies churn, the before-tool-call boundary records the warning and policy-wait tokens, diagnostic activity owns the semantic clock, and existing owner-bound stuck-session recovery performs the abort and lane drain.

User Impact

A continuously churning opted-in agent can now be reclaimed without prematurely blocking a legitimate call. Recurring multi-variant work with distinct successful outcomes, fresh arguments, later useful model progress, overlapping approvals, parallel calls, replacement runs, and configurations with loop detection disabled remain compatible.

Evidence

Provenance

  • Base: e79faff8aa755b201302edd286976a03f9ed79ea
  • Proof head: 0ab630c2cb130604d6e46557e4c74135b5e0243d
  • Revalidated: after merging current upstream main

Direct behavior

  • Recurring multi-variant compatibility runtime transcript (EXECUTED) — Observed: on behavior-proof head 54b94d469297f9a65082314d941b13756a05a72c, the production wrapped-tool path executed 30 recurring calls whose argument variants returned distinct successful outcomes, then executed a novel call; the warning remained non-vetoing, later model progress released stale churn, and the escape call cleared churn. Result: {"proof":"recurring_multi_variant_compatibility","recurringCallsExecuted":30,"novelCallExecuted":true,"warningWasNonVetoing":true,"finalProgressReleasedChurn":true,"escapeClearedChurn":true}. Proves legitimate recurring multi-variant work is not classified as shared semantic no progress and the compatibility escapes remain live. Preserves tool execution, novel-call escape, and later-progress ownership.
  • Continuous churn recovery runtime transcript (EXECUTED) — Observed: on behavior-proof head 54b94d469297f9a65082314d941b13756a05a72c, the production wrapper recorded 42 same-tool calls spread across six simulated minutes with one shared stable result, while the active embedded-run registry and real command lane contained an owner-bound active run plus queued work. Result: {"proof":"continuous_churn_recovery","toolCallsExecutedBeforeRecovery":42,"staleReason":"tool_loop:argument_churn","staleAgeMs":360000,"recoveryStatus":"aborted","recoveryAction":"abort_embedded_run","activeResult":"aborted","queuedResult":"drained","finalLaneDepth":0}. Proves continuous semantic churn ages independently of mechanical progress and reaches the existing recovery path, which aborts the owning embedded run and drains queued work. Preserves warning-only admission before recovery and owner-bound lane cleanup.

Automated verification

Behavior-proof head wrapped runtime

pnpm exec vitest run --config test/vitest/vitest.e2e.config.ts src/agents/agent-tools.before-tool-call.e2e.test.ts
  • pnpm exec vitest run --config test/vitest/vitest.e2e.config.ts src/agents/agent-tools.before-tool-call.e2e.test.ts — 1 file passed with 92/92 tests and 0 failures. Proves the complete wrapped before-tool-call boundary passes, including churn admission, final-parameter reconciliation, overlapping policy waits, failures, disabled gating, run scoping, and compatibility escapes. Preserves all existing hook, approval, diagnostic, veto, and execution contracts in the file.

Behavior-proof head detector and recovery

node scripts/run-vitest.mjs src/agents/tool-loop-detection.test.ts src/logging/diagnostic-run-activity.test.ts src/logging/diagnostic-stuck-session-recovery.integration.test.ts
  • node scripts/run-vitest.mjs src/agents/tool-loop-detection.test.ts src/logging/diagnostic-run-activity.test.ts src/logging/diagnostic-stuck-session-recovery.integration.test.ts — 3 files passed with 82/82 tests and 0 failures (62 detector, 13 activity, 7 recovery integration). Proves shared-outcome churn is classified narrowly, activity clock ownership is lifecycle-safe, and real embedded-run/lane recovery is integrated. Preserves exact-repeat, polling, ping-pong, unknown-tool, run-scope, result-hash, index, and recovery behavior.
node scripts/run-vitest.mjs src/logging/diagnostic-stuck-session-recovery.runtime.test.ts src/logging/diagnostic-stability.test.ts
  • node scripts/run-vitest.mjs src/logging/diagnostic-stuck-session-recovery.runtime.test.ts src/logging/diagnostic-stability.test.ts — 2 files passed with 41/41 tests and 0 failures (28 recovery runtime, 13 stability). Proves the adjacent runtime recovery and stability contracts remain green. Preserves existing stale-session classifications, recovery outcomes, and stability recording.

Behavior-proof head static verification

pnpm tsgo:core && pnpm tsgo:core:test
  • pnpm tsgo:core && pnpm tsgo:core:test — Core typecheck and Core test typecheck both completed with exit code 0. Proves production and test changes satisfy the repository TypeScript contracts. Preserves core compile-time boundaries.
pnpm exec oxlint $(git diff --name-only 97d3d60b5120a59e8cb9ccbdfca12455acaf909e...HEAD -- '*.ts')
  • pnpm exec oxlint $(git diff --name-only 97d3d60b5120a59e8cb9ccbdfca12455acaf909e...HEAD -- '*.ts') — 0 warnings and 0 errors across all 17 changed files. Proves the full production and regression surface satisfies affected lint rules. Preserves repository lint policy without new suppressions.
pnpm check:max-lines-ratchet
  • pnpm check:max-lines-ratchet — completed with exit code 0. Proves the final patch does not regress the repository max-lines ratchet. Preserves source-size guardrails.
git diff --check origin/main...HEAD
  • git diff --check origin/main...HEAD — completed with exit code 0 and no whitespace errors. Proves the exact final patch is whitespace-clean. Preserves the bounded 17-file change set.

Final-head post-merge CI repair

node scripts/run-vitest.mjs src/logging/diagnostic-run-activity.test.ts
  • node scripts/run-vitest.mjs src/logging/diagnostic-run-activity.test.ts — 1 file passed with 13/13 tests and 0 failures. Proves the final head preserves run-id index cleanup through observable lifecycle behavior after removing the test-only production export. Preserves embedded-run replacement, completion, churn ownership, and stale-run lookup cleanup.
pnpm deadcode:full
  • pnpm deadcode:full — completed with exit code 0 and no unused exports. Proves the final feature surface no longer exposes internal-only churn helpers or test-only index counters. Preserves the runtime behavior while keeping the production API narrow.
pnpm plugin-sdk:api:check
  • pnpm plugin-sdk:api:check — completed with exit code 0 against the regenerated module/text-runtime hash. Proves the intentional public diagnostic union addition is recorded in the Plugin SDK API contract. Preserves Plugin SDK baseline enforcement after the current-main merge.
pnpm tsgo:core pnpm tsgo:core:test
  • pnpm tsgo:core pnpm tsgo:core:test — Core typecheck and Core test typecheck both completed with exit code 0. Proves the current-main merge and CI repair satisfy production and test TypeScript contracts. Preserves core compile-time boundaries at final head 0ab630c2cb130604d6e46557e4c74135b5e0243d.
git diff --check
  • git diff --check — completed with exit code 0 and no whitespace errors. Proves the final merged worktree is whitespace-clean. Preserves the current-main merge and bounded CI repair.

Preserved boundaries

  • Argument churn is warning-only; it never directly vetoes a tool call.
  • Every stable argument variant must share one result hash before it can contribute semantic no-progress evidence.
  • Distinct successful outcomes, novel arguments, and later model progress after tool activity stops release or restart the churn clock.
  • Pending same-tool siblings and overlapping policy waits cannot prematurely clear or expose churn liveness.
  • Existing critical exact-repeat, polling, ping-pong, unknown-tool, and global circuit-breaker decisions keep precedence.
  • Run replacement, run completion, recovery, and diagnostic cleanup clear owner-specific churn and policy-wait state.
  • The rolling classifier remains gated by tools.loopDetection.enabled.

Proof gap

A credentialed live-provider/model Gateway run was not run, so provider-specific planning and live-provider behavior are not claimed. The exact-head direct transcripts exercise the production wrapped-tool, diagnostic activity, embedded-run ownership, stuck-session recovery, and command-lane boundaries with deterministic tool results; the complete focused automated suites supplement that runtime proof.

Artifacts

  • None attached.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jul 22, 2026
@IWhatsskill
IWhatsskill marked this pull request as ready for review July 22, 2026 09:26
@IWhatsskill
IWhatsskill marked this pull request as draft July 22, 2026 21:54
@IWhatsskill
IWhatsskill marked this pull request as ready for review July 23, 2026 10:21
@IWhatsskill
IWhatsskill marked this pull request as draft July 23, 2026 12:46
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 27, 2026, 1:17 PM ET / 17:17 UTC.

ClawSweeper review

What this changes

The PR adds warning-only detection of repeated same-tool argument variants with a shared no-progress result and uses that signal to let existing stuck-session recovery abort the owning embedded run and drain its command lane.

Merge readiness

⚠️ Needs maintainer review before merge - 5 items remain

Keep this PR open for maintainer review. The final maintainer repair deliberately limits write no-progress evidence to details.changed === false, but the linked report describes alternating successful writes; that reported loop remains outside the new churn classifier even though this PR claims to close it.

Priority: P1
Reviewed head: bbabe7efe1d579e8d40140a319c3f435b87eb873
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The proof is strong for the no-op churn path, but the final implementation does not cover the linked successful-write case it claims to close.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies after-fix production-boundary transcripts for continuous no-progress churn recovery and recurring multi-variant compatibility, while the final maintainer comment reports focused Testbox verification after the threshold, write-outcome, and ordering repairs.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies after-fix production-boundary transcripts for continuous no-progress churn recovery and recurring multi-variant compatibility, while the final maintainer comment reports focused Testbox verification after the threshold, write-outcome, and ordering repairs.
Evidence reviewed 4 items Linked-report mismatch: The linked issue reports repeated successful writes to alternating paths that never produce a reply. The final PR change only recognizes a write as semantic no-progress when its structured result has changed === false, so successful changing writes do not contribute to the new argument-churn liveness signal.
Final-head maintainer intent: The maintainer’s final comment explicitly says successful writes retain target identity while only built-in write no-ops are normalized for churn. That confirms the exclusion is intentional, rather than a missing test or accidental result-hash mismatch.
Prior finding resolved: The previous P1 about the retired configurable warning threshold is addressed by the final head’s shared built-in threshold helper and the maintainer comment states that the removed numeric tuning surface is intentionally not restored.
Findings 1 actionable finding [P1] Do not close the successful-write report with a no-op-only detector
Security None None.

How this fits together

Agent tool calls go through the before-tool-call policy boundary, which records loop evidence and executes the tool. Diagnostic activity converts sustained semantic churn into stale-run evidence, and stuck-session recovery then acts on the associated embedded run and queued command lane.

flowchart LR
  A[Agent tool call] --> B[Before-tool-call policy]
  B --> C[Loop detector]
  C --> D[Semantic churn activity]
  D --> E[Stuck-session recovery]
  E --> F[Embedded run]
  E --> G[Command lane drain]
Loading

Decision needed

Question Recommendation
Should argument-churn recovery treat repeated successful write calls that change distinct targets as semantic no-progress for the linked bug, or should this PR be explicitly limited to no-op writes and stop claiming to close that issue? Narrow the PR’s claim: Keep changed === false as the only write no-progress contract, remove the closing claim, and leave the linked issue open for the successful-write loop.

Why: The final implementation intentionally excludes successful writes, while the linked report’s observed loop consists of successful alternating writes. Choosing a broader rule changes when agent runs may be aborted and queued work drained.

Before merge

  • Do not close the successful-write report with a no-op-only detector (P1) - The linked report’s loop consists of successful alternating write calls, but this predicate marks only details.changed === false as no-progress. Those successful writes therefore never build argument-churn liveness, so the documented run remains unrecovered while the PR body says it closes the issue. Either keep that issue open and narrow the claim, or add a safe semantic-progress contract with regression coverage for the reported path.
  • Resolve merge risk (P1) - The PR body says it closes [Bug]: Loop detection evaded by varying tool arguments; stuck-session recovery treats looping tool calls as progress #112479, but the reported successful alternating writes are intentionally excluded from the new no-progress classifier; merging unchanged would close the report without recovering its documented behavior.
  • Resolve merge risk (P1) - Broadening write classification to treat changing writes as semantic no-progress could abort legitimate multi-target work and drain its queued lane, so the exact write-result contract needs an explicit maintainer decision.
  • Complete next step (P2) - A maintainer must choose whether successful writes to distinct targets are intentionally outside semantic no-progress recovery before an automated repair can safely proceed.

Findings

  • [P1] Do not close the successful-write report with a no-op-only detector — src/agents/tool-loop-write-outcome.ts:4
Agent review details

Security

None.

PR surface

Source +661, Tests +1257, Generated 0. Total +1918 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 17 697 36 +661
Tests 4 1262 5 +1257
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 1 1 0
Other 0 0 0 0
Total 22 1960 42 +1918

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Narrow the linked-bug claim (recommended)
    Keep the no-op-only classifier, remove the closing syntax for the successful-write report, and retain that issue for a separately scoped solution.
  2. Adopt a broader write contract
    Implement a narrowly defined semantic-progress rule for repeated changing writes, with focused compatibility and recovery proof before merge.
  3. Pause the PR
    Pause this branch if maintainers do not want agent recovery to infer no-progress from successful writes to distinct targets.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Remove the closing claim for the successful-write report and state that this PR only detects stable no-op outcomes.

Technical review

Best possible solution:

Decide whether repeated successful writes to distinct targets with otherwise repeated intent are in scope for recovery. If they are not, narrow the PR and leave #112479 open; if they are, define a conservative write-specific semantic-progress contract and prove it preserves legitimate multi-target writes before merging.

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

No live current-head reproduction was executed in this read-only review, but the source path is high-confidence: successful writes lack noProgress, so they terminate the new churn tail exactly as the linked report describes.

Is this the best way to solve the issue?

No. The no-op-only rule is a plausible bounded improvement, but it does not solve the linked successful-write loop while the PR claims to close that report; either the scope or the semantic-progress contract must change.

Full review comments:

  • [P1] Do not close the successful-write report with a no-op-only detector — src/agents/tool-loop-write-outcome.ts:4
    The linked report’s loop consists of successful alternating write calls, but this predicate marks only details.changed === false as no-progress. Those successful writes therefore never build argument-churn liveness, so the documented run remains unrecovered while the PR body says it closes the issue. Either keep that issue open and narrow the claim, or add a safe semantic-progress contract with regression coverage for the reported path.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The PR targets an agent run that can spin without replying, but its final scope leaves the linked successful-write reproduction unrecovered.
  • merge-risk: 🚨 compatibility: The patch changes which existing tool outcomes contribute to liveness and can alter when legacy looping patterns are reclaimed.
  • merge-risk: 🚨 availability: A churn classification that remains active through the stale boundary aborts the embedded run and drains its command lane.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies after-fix production-boundary transcripts for continuous no-progress churn recovery and recurring multi-variant compatibility, while the final maintainer comment reports focused Testbox verification after the threshold, write-outcome, and ordering repairs.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix production-boundary transcripts for continuous no-progress churn recovery and recurring multi-variant compatibility, while the final maintainer comment reports focused Testbox verification after the threshold, write-outcome, and ordering repairs.

Evidence

What I checked:

  • Linked-report mismatch: The linked issue reports repeated successful writes to alternating paths that never produce a reply. The final PR change only recognizes a write as semantic no-progress when its structured result has changed === false, so successful changing writes do not contribute to the new argument-churn liveness signal. (src/agents/tool-loop-write-outcome.ts:4, bbabe7efe1d5)
  • Final-head maintainer intent: The maintainer’s final comment explicitly says successful writes retain target identity while only built-in write no-ops are normalized for churn. That confirms the exclusion is intentional, rather than a missing test or accidental result-hash mismatch. (src/agents/tool-loop-write-outcome.ts:4, bbabe7efe1d5)
  • Prior finding resolved: The previous P1 about the retired configurable warning threshold is addressed by the final head’s shared built-in threshold helper and the maintainer comment states that the removed numeric tuning surface is intentionally not restored. (src/agents/tool-loop-thresholds.ts:1, bbabe7efe1d5)
  • Current-main baseline: Current main still has the existing exact-argument no-progress path and no argument-churn classifier, so this PR remains a candidate fix rather than obsolete work already implemented on main. (src/agents/tool-loop-detection.ts:2722, 8f8e40dabe0a)

Likely related people:

  • vincentkoc: Authored the final three commits that define write no-progress semantics and activity ordering, and is assigned to this PR. (role: recent area contributor; confidence: high; commits: a773be865012, ac0464376b1a, bbabe7efe1d5; files: src/agents/tool-loop-write-outcome.ts, src/agents/tool-loop-detection.ts, src/logging/diagnostic-run-activity.ts)
  • steipete: The merged configuration-surface reduction removed loop-detection numeric tuning and established the built-in threshold contract this PR reuses. (role: adjacent owner; confidence: medium; commits: 783a5d21cfc1; files: src/agents/tool-loop-thresholds.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve the successful-write scope mismatch by narrowing the linked claim or adding a maintainer-approved semantic-progress rule and focused proof.

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 (6 earlier review cycles)
  • reviewed 2026-07-25T02:42:25.287Z sha e1c1e98 :: needs real behavior proof before merge. :: [P1] Honor the configured circuit-breaker threshold
  • reviewed 2026-07-27T08:53:18.381Z sha c972d8b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T08:59:41.435Z sha c972d8b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T09:08:37.531Z sha c972d8b :: needs real behavior proof before merge. :: [P1] Do not equate stable variants with no progress
  • reviewed 2026-07-27T14:59:44.261Z sha 54b94d4 :: needs changes before merge. :: [P1] Honor the configured churn warning threshold
  • reviewed 2026-07-27T15:53:52.700Z sha 0ab630c :: needs changes before merge. :: [P1] Honor the configured churn warning threshold

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 27, 2026
@IWhatsskill
IWhatsskill marked this pull request as ready for review July 27, 2026 14:50
@IWhatsskill
IWhatsskill marked this pull request as draft July 27, 2026 14:51
@IWhatsskill
IWhatsskill marked this pull request as ready for review July 27, 2026 14:52
@IWhatsskill
IWhatsskill marked this pull request as draft July 27, 2026 14:53
@IWhatsskill
IWhatsskill marked this pull request as ready for review July 27, 2026 14:54
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Jul 27, 2026
@vincentkoc vincentkoc self-assigned this Jul 27, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer fixes pushed in bbabe7efe1d:

  • Normalized the built-in write no-op contract (details.changed === false) so path-bearing display text no longer defeats alternating-path churn detection. Successful writes retain target identity, generic stable successes cannot drive churn liveness, and repeated errors remain explicit no-progress outcomes.
  • Threaded the canonical built-in warning threshold through post-policy reconciliation. Numeric loop tuning was retired by refactor(config): config-surface reduction tranche 2 — purge tuning knobs behind built-in defaults #111382, so this deliberately does not restore a dead config surface.
  • Added monotonic activity ordering so later progress supersedes churn even when both events share a millisecond, including merged session refs.

Proof: Blacksmith Testbox passed 66 detector tests, 93 wrapped-tool E2E tests, 15 run-activity tests, and 7 stuck-recovery integration tests. Focused lint/format/diff checks passed. Fresh uncommitted and whole-branch autoreview are clean with no actionable findings.

@vincentkoc
vincentkoc merged commit 79c517d into openclaw:main Jul 27, 2026
118 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

@steipete

Copy link
Copy Markdown
Contributor

Post-merge maintainer resolution of the open ClawSweeper P1 ("Do not close the successful-write report with a no-op-only detector"), from an independent pre-land review that ran concurrently with the merge:

The changed === false write contract does cover the reported loop, and closing #112479 was correct. The finding rests on the issue's 2026.6.11 transcript, where every repeated write logged Successfully wrote 1214 bytes .... That behavior no longer exists on main: since #97044 (ab966c214be08d, merged 2026-06-27, not an ancestor of v2026.6.11 — verified with git merge-base --is-ancestor), the built-in write tool classifies an identical-content rewrite as a terminal no-op with details.changed === false (write.ts precheck.state === "same" branch).

Replaying the reported repro (identical content alternating between /tmp/symmetry-issue-body.md and /tmp/symmetry-issue.md) on current main + this PR:

  • first write per path: changed: true — real progress, correctly excluded;
  • every subsequent write: changed: false no-op → normalized to the shared digestStable({ status: "unchanged" }) hash with noProgress: true (src/agents/tool-loop-detection.ts:315);
  • both argument variants accumulate ≥3 stable calls with one shared outcome → the churn classifier fires (src/agents/tool-loop-argument-churn.ts), the semantic liveness clock ages independently of mechanical tool events, and stuck-session recovery aborts the run and drains the lane — exactly the recovery the reporter asked for.

The regression tests cover this exact shape (tool-loop-detection.test.ts: "normalizes built-in write no-ops that only differ by echoed path", plus the alternating-path churn/reconciliation cases), and the PR's continuous-churn e2e transcript proves the recovery end of the pipeline.

What remains intentionally excluded is repeated content-changing writes to distinct targets. That is not what #112479 reported, and classifying genuinely changing writes as no-progress could abort legitimate multi-target work — the conservative exclusion is the right product call.

Independent structured review (Codex gpt-5.6-sol, xhigh reasoning) over the full origin/main...bbabe7e bundle also came back clean: no accepted/actionable findings, "patch is correct (0.97)."

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 28, 2026
* fix(agents): detect stable tool argument churn

* fix(agents): refine argument churn evidence

* fix(agents): route argument churn through recovery

* fix(agents): reconcile rewritten loop arguments

* fix(agents): defer churn recovery across policy waits

* fix(agents): preserve churn clocks across policy waits

* fix(agents): harden concurrent churn policy tracking

* fix(agents): avoid stale churn false positives

* fix(agents): satisfy loop diagnostic CI guards

* fix(agents): normalize write churn outcomes

* fix(logging): order churn activity events

* fix(agents): classify churn no-progress outcomes

---------

Co-authored-by: IWhatsskill <[email protected]>
Co-authored-by: Vincent Koc <[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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Loop detection evaded by varying tool arguments; stuck-session recovery treats looping tool calls as progress

3 participants