Skip to content

feat(agents): rapid-succession storm detector + callTrace to prevent nested-agent tool storms#56

Merged
Piboonsak merged 2 commits into
mainfrom
copilot/add-loop-detection-circuit-breaker
Apr 5, 2026
Merged

feat(agents): rapid-succession storm detector + callTrace to prevent nested-agent tool storms#56
Piboonsak merged 2 commits into
mainfrom
copilot/add-loop-detection-circuit-breaker

Conversation

Copilot AI commented Apr 5, 2026

Copy link
Copy Markdown

Closes #52

…events

- Add `rapid_succession` LoopDetectorKind that fires when the same tool
  is called N consecutive times (any args), catching nested-agent tool
  storms before outcome data is available
- Add `RAPID_SUCCESSION_THRESHOLD` (default 15) and `CALL_TRACE_SIZE` (10)
  constants with export
- Add `buildCallTrace()` helper that builds a compact tool-name trace from
  session history for debugging
- Add `callTrace?: string[]` to `LoopDetectionResult`, `DiagnosticToolLoopEvent`,
  and `logToolLoopAction` params — all existing detectors now emit traces
- Add `rapidSuccession?: boolean` detector toggle and `rapidSuccessionThreshold?`
  to `ToolLoopDetectionConfig` / `ToolLoopDetectionDetectorConfig`
- Update Zod schema, config labels, and help text for new fields
- Pass `callTrace` through `pi-tools.before-tool-call.ts` to the diagnostic event
- Add unit tests for rapid_succession detector, buildCallTrace, and callTrace
  presence in all detector results
- Add integration tests in pi-tools.before-tool-call.test.ts

Agent-Logs-Url: https://github.com/Piboonsak/openclaw_github/sessions/1ef9598b-f74a-4354-be83-070ea797fa7d

Co-authored-by: Piboonsak <[email protected]>
Copilot AI changed the title [WIP] Add loop detection and circuit breaker for agent tool storms feat(agents): rapid-succession storm detector + callTrace to prevent nested-agent tool storms Apr 5, 2026
Copilot AI requested a review from Piboonsak April 5, 2026 13:37
@Piboonsak
Piboonsak marked this pull request as ready for review April 5, 2026 13:52
@Piboonsak
Piboonsak merged commit e0b58f3 into main Apr 5, 2026
@Piboonsak
Piboonsak deleted the copilot/add-loop-detection-circuit-breaker branch April 5, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Nested agent tool storm — prevent model failover cascade and credit burn

2 participants