Skip to content

fix(agents): surface bucketed tool-loop warnings - #135103

Merged
steipete merged 1 commit into
mainfrom
steipete/tool-loop-model-warnings
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/tool-loop-model-warnings

Conversation

@steipete

@steipete steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Tool-loop warnings appeared in diagnostics but not in tool results, leaving the model without loop feedback until a critical block.

Why This Change Was Made

Return the existing bucketed warning as typed admission feedback and append a short system note after raw outcome recording. This gives the model a chance to change approach without changing outcome hashing or no-progress escalation. Keep warning buckets on the canonical session instead of losing lazy initialization on a projected history copy.

Discovery source: NetEase Youdao's LobsterAI patch stack (github.com/netease-youdao/LobsterAI). Only the model-visible warning and record-before-decoration idea is adopted; existing critical recovery remains intact.

User Impact

With rolling tool-loop detection enabled, affected OpenClaw tool results carry a short warning at the diagnostic bucket boundary. Normal and unrelated sibling results remain unchanged. No new config; critical blocking, one-shot recovery, and termination stay unchanged. Documentation explains the warning and hashing behavior.

Evidence

327 targeted tests passed across agent-core, admission/detection, embedded-runner wiring, and the wrapper E2E suite in supported focused source-fixture mode. The four admission/agent-core regressions were observed failing against the base for missing warning feedback; wrapper pre-fix failure is verified from the unchanged raw-result return in the base diff, with its full candidate suite green. The critical renderer/batch-completion function is byte-identical to base. Autoreview is scoped-clean at P0. pnpm check:changed passed with exit code 0.

Production delta: +60 lines; tests: +157; docs: +4. Growth implements typed transport and one shared result decorator without new detection/state paths. Full product-build, live-provider, and native-tool feedback proof are not claimed; native/CLI-only outcomes remain outside this result-decoration change.

Final Git verification

git commit -F .loop-warnings-commit.log passed; the pre-commit formatter completed successfully. git diff --exit-code HEAD returned 0, so the committed tree exactly matches the final verified candidate. git status -sb:

## steipete/tool-loop-model-warnings

git check-ignore WORKER_RESULT.md prints the report filename, and git ls-files WORKER_RESULT.md is empty. The report remains untracked through Git's info exclude, not .gitignore. No push, pull, PR, changelog, lockfile, baseline, or inventory changes.

Carry typed admission warnings into admitted tool results after raw
outcome recording, including single-call wrappers. Keep warning buckets
on canonical diagnostic sessions and leave critical recovery unchanged.

Preserve private result state and empty display-content normalization.
Cover thresholds, outcome hashes, model context, and both batch modes.
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review September 1, 2026 10:22
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 1, 2026
@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 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 6:29 AM ET / 10:29 UTC.

ClawSweeper review

What this changes

The PR makes existing bucketed tool-loop warnings visible to the model by appending a system note to the affected tool result after its raw outcome is recorded.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-authored PR open for normal merge review: current main logs bucketed loop warnings but does not return them to tool results, and the patch carries the existing warning through the embedded agent result lifecycle without changing critical-loop recovery.

Priority: P2
Reviewed head: 96022b86f128ba8d57316545045aa07a1c483532

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-covered repair with no concrete correctness or security finding in the reviewed patch.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR is maintainer-authored, so contributor real-behavior proof is not a gate; its supplied focused test evidence maps directly to admission, raw-outcome recording, and model-context result construction.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is maintainer-authored, so contributor real-behavior proof is not a gate; its supplied focused test evidence maps directly to admission, raw-outcome recording, and model-context result construction.
Evidence reviewed 5 items Current-main gap: The fetched current main detects and logs a bucketed warning but returns no warning payload, so the caller cannot decorate a tool result.
Introduced result transport: The PR returns a typed warning from admission, stores warnings on the batch, and decorates the finalized result only after outcome hooks.
Behavioral coverage: Focused tests cover both sequential and parallel batches, raw-result preservation, outcome-hook ordering, empty result content, warning thresholds, and unchanged outcome hashes.
Findings None None.
Security None None.

How this fits together

Tool-loop admission evaluates an agent’s recent tool-call history before execution. Its result controls whether tools run and what the next model turn receives.

flowchart LR
A[Model tool calls] --> B[Loop admission]
B --> C{Warning or critical loop}
C -->|warning| D[Run and record raw tool outcome]
D --> E[Append model warning]
E --> F[Next model turn]
C -->|critical| G[Block batch and recovery turn]
Loading

Before merge

  • Resolve merge risk (P1) - The change adds 60 production lines in the agent-loop lifecycle; focused coverage is strong, but exact-head CI should still confirm the integrated suites before merge.
  • Complete next step (P2) - An active maintainer-authored PR already owns the concrete repair; no separate ClawSweeper fix lane is needed.
Agent review details

Security

None.

PR surface

Source +60, Tests +157, Docs +4. Total +221 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 8 92 32 +60
Tests 3 163 6 +157
Docs 1 5 1 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 260 39 +221

Review metrics

Metric Value Why it matters
Production versus test delta production +60, tests +157, docs +4 The production growth is a bounded typed warning handoff and shared decorator; tests cover both execution modes and hash preservation.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the typed warning handoff and single post-record result decorator, then merge once exact-head CI confirms the covered agent paths.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the typed warning handoff and single post-record result decorator, then merge once exact-head CI confirms the covered agent paths.

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

Yes: on current main, reach a warning threshold and inspect the admitted tool result or next model context; the admission code logs the warning but returns no result feedback.

Is this the best way to solve the issue?

Yes: the patch reuses existing detection and critical recovery, adds feedback at the result boundary, and preserves raw outcome hashing before decoration.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs missing model feedback in the loop-protection path without changing critical blocking or introducing an urgent availability regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is maintainer-authored, so contributor real-behavior proof is not a gate; its supplied focused test evidence maps directly to admission, raw-outcome recording, and model-context result construction.

Label justifications:

  • P2: This repairs missing model feedback in the loop-protection path without changing critical blocking or introducing an urgent availability regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 PR is maintainer-authored, so contributor real-behavior proof is not a gate; its supplied focused test evidence maps directly to admission, raw-outcome recording, and model-context result construction.

Evidence

What I checked:

Likely related people:

  • steipete: 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.

@steipete
steipete merged commit 4602a60 into main Sep 1, 2026
333 of 340 checks passed
@steipete
steipete deleted the steipete/tool-loop-model-warnings branch September 1, 2026 10:51
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
Carry typed admission warnings into admitted tool results after raw
outcome recording, including single-call wrappers. Keep warning buckets
on canonical diagnostic sessions and leave critical recovery unchanged.

Preserve private result state and empty display-content normalization.
Cover thresholds, outcome hashes, model context, and both batch modes.
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 maintainer Maintainer-authored PR 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.

1 participant