fix(agents): merge upstream agent runtime refactor with Sprint 3.5-3.7 customizations#88
Merged
Merged
Conversation
4 tasks
- tool-loop-detection.test.ts: merge both test suites (upstream + ours); add noRapidSuccessionConfig to prevent rapid_succession from interfering with tests for other detectors (global_circuit_breaker, known_poll_no_progress, generic_repeat); add imports for CALL_TRACE_SIZE, RAPID_SUCCESSION_THRESHOLD, buildCallTrace - pi-tools.before-tool-call.test.ts: add noRapidSuccessionContext for tests that drive other detectors; fix toolName expectation bash→exec (normalizeToolName alias); update createGenericReadRepeatFixture to accept context - pi-embedded-runner/history.ts: apply upstream normalizeProviderId refactor (channel lookup now normalized) while keeping our limitHistoryByTokenBudget - src/agents/provider-id.ts: bring in from upstream (new utility file required by history.ts normalizeProviderId import)" Agent-Logs-Url: https://github.com/Piboonsak/openclaw_github/sessions/b0c56fb0-0133-4173-b3fb-103abe8cd68d
Copilot
AI
changed the title
[WIP] Fix agents: merge agent runtime changes with upstream refactor
fix(agents): merge upstream agent runtime refactor with Sprint 3.5-3.7 customizations
Apr 6, 2026
Piboonsak
marked this pull request as ready for review
April 6, 2026 07:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tool-loop-detectionandpi-tools.before-tool-callwhile our Sprint 3.5–3.7 PRs (feat(agents): rapid-succession storm detector + callTrace to prevent nested-agent tool storms #56 storm detector, feat(agent): enable reasoning mode as default #78 reasoning mode) added tests/features to the same files. Ourrapid_successiondetector (fires at ≥15 consecutive same-tool calls, any args) broke pre-existing tests that make 15–30+ consecutive calls to exercise other detectors. Additionally,normalizeToolName("bash") → "exec"viaTOOL_NAME_ALIASEScaused a toolName assertion mismatch in storm tests.tool-loop-detectiontests and 7before-tool-calltests were failing in CI; storm detection and reasoning-mode features were unverifiable.normalizeProviderIdrefactor tohistory.ts; addedprovider-id.tsfrom upstream.tool-loop-detection.ts(our new file, untouched per spec);model-selection.ts(PR feat(agent): enable reasoning mode as default #78 reasoning default already applied);pi-tools.before-tool-call.ts(PR feat(agents): rapid-succession storm detector + callTrace to prevent nested-agent tool storms #56 callTrace already applied);compact.ts/errors.ts(upstream versions require 10+ new dependency files — deferred).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
None. All changes are internal test fixes and upstream normalization logic for provider ID lookup in history config.
Security Impact (required)
Repro + Verification
Environment
Steps
pnpm test -- src/agents/tool-loop-detection.test.ts src/agents/pi-tools.before-tool-call.test.tsExpected
tool-loop-detectiontests passbefore-tool-calltests passActual
Before: 8 failures in
tool-loop-detection.test.ts, 7 inpi-tools.before-tool-call.test.tsAfter: 208/208 tests pass across all affected files
Evidence
Before (sample failures):
Fix pattern —
tool-loop-detection.test.ts:Fix pattern —
before-tool-call.test.ts:Human Verification (required)
history.tsprovider lookup normalization tested via 138 pi-embedded-runner tests.can disable specific detectorstest now also disablesrapidSuccession: falseso all-off config truly returnsstuck: false;callTrace in all detectorstests updated similarly.compact.ts/errors.tsupstream replacements (deferred due to missing dependency chain).Compatibility / Migration
Failure Recovery (if this breaks)
git revert HEAD— test-only + provider-id utility changes, no runtime behavior changed.src/agents/tool-loop-detection.test.ts,src/agents/pi-tools.before-tool-call.test.ts,src/agents/pi-embedded-runner/history.ts,src/agents/provider-id.tsRAPID_SUCCESSION_THRESHOLDis lowered belowWARNING_THRESHOLD(10), thenoRapidSuccessionConfigguard in non-storm tests becomes unnecessary but harmless.Risks and Mitigations
rapidSuccessionmight mask a real storm if the tool name changes.rapid_succession detectorsuite (8 tests) always runs withenabled: trueand exercises the full detector path includingbash→execnormalization.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.anthropic.com/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js --local 18_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 18_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js push�� 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js b/openclaw_githu/home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice ngs.cjs orks.js b/node_modules/.node b/node_modules/.--conditions(dns block)api.openai.com/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js orks.js 18_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 18_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js -E 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js x ngs.cjs orks.js b/node_modules/.node b/node_modules/.--conditions(dns block)api.telegram.org/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js(dns block)chatgpt.com/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js --local 18_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 18_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js push�� 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js b/openclaw_githu/home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice ngs.cjs orks.js b/node_modules/.node b/node_modules/.--conditions(dns block)example.com/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js --global pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js --no��(dns block)/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js --global(dns block)/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js --global 18_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 18_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js --no�� laywright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs laywright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js bin/git tool-call.test.t/opt/hostedtoolcache/node/24.14.1/x64/bin/node --local(dns block)files.slack.com/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js -p 4513 fgrep -lxm�� 1 -- ndor/bin/bash /var/lib/dpkg/indocker /var/lib/dpkg/inps /var/lib/dpkg/in-a sh(dns block)private.test/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js(dns block)/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js orks.js b/node_modules/.--ping b/node_modules/.pnpm/[email protected] d/bi�� 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js ache/node/24.14.1/x64/bin/node ngs.cjs orks.js b/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-p--experimental-import-meta-resolve b/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-p--require(dns block)/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw_github/openclaw_github/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._c9688654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js t/dist/workers/f--version b/openclaw_github/node_modules/.--noprofile 1/x64/bin/node cker�� 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/suppress-warnings.cjs 88654361f600a6ea7cb5666ec9fae/node_modules/vitest/dist/workers/forks.js b/node_modules/.bin/node t/suppress-warni/opt/hostedtoolcache/node/24.14.1/x64/bin/node t/dist/workers/f--conditions pnpm/[email protected] pnpm/[email protected](dns block)If you need me to access, download, or install something from one of these locations, you can either: