openclaw/src
Boris Cherny f6380ae4b7
fix(cache): compact newest tool results first to preserve prompt cache prefix (#58036)
* fix(cache): compact newest tool results first to preserve prompt cache prefix

compactExistingToolResultsInPlace iterated front-to-back, replacing the
oldest tool results with placeholders when context exceeded 75%. This
rewrote messages[k] for small k, invalidating the provider prompt cache
from that point onward on every subsequent turn.

Reverse the loop to compact newest-first. The cached prefix stays intact;
the tradeoff is the model loses recent tool output instead of old, which
is acceptable since this guard only fires as an emergency measure past
the 75% threshold.

* fix(cache): compact newest tool results first to preserve prompt cache prefix (#58036) Thanks @bcherny

---------

Co-authored-by: George Zhang <georgezhangtj97@gmail.com>
2026-04-03 17:19:15 -07:00
..
acp test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
agents fix(cache): compact newest tool results first to preserve prompt cache prefix (#58036) 2026-04-03 17:19:15 -07:00
auto-reply fix: persist fallback overrides safely 2026-04-04 09:00:16 +09:00
bindings
bootstrap
canvas-host
channels test(plugins): drop stale core test files 2026-04-04 00:11:54 +01:00
chat
cli test(ci): fix logs cli gateway mock typing 2026-04-04 00:28:25 +01:00
commands test: trim onboarding helper partial mock 2026-04-04 00:13:45 +01:00
compat
config test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
context-engine test(ci): harden context engine runtime bridge test 2026-04-03 21:12:56 +01:00
cron refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
daemon test(node): fix execFile mock typing 2026-04-03 19:53:38 +01:00
docs
flows refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
gateway fix(cli): add local logs fallback 2026-04-04 08:17:11 +09:00
generated refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
hooks fix(config): hide legacy internal hook handlers 2026-04-04 04:26:51 +09:00
i18n
image-generation fix(plugins): reuse active registry during tool resolution (#52262) 2026-04-03 17:16:33 -04:00
infra fix: restore gateway watch boot path 2026-04-04 01:10:49 +01:00
interactive
link-understanding
logging fix(cli): add local logs fallback 2026-04-04 08:17:11 +09:00
markdown test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
mcp
media test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
media-understanding refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
node-host
pairing
plugin-sdk fix(ci): restore plugin contract surfaces 2026-04-04 00:24:57 +01:00
plugins fix: restore gateway watch boot path 2026-04-04 01:10:49 +01:00
process test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
routing test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
scripts
secrets refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
security test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
sessions refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
shared
tasks test(ci): fix windows update and task cleanup cases 2026-04-03 22:22:51 +01:00
terminal
test-helpers test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
test-utils test(plugins): drop stale core test files 2026-04-04 00:11:54 +01:00
tts
tui
types
utils
web-fetch
web-search
wizard
channel-web.ts
docker-build-cache.test.ts fix: stabilize live and docker test lanes 2026-04-03 21:43:36 +01:00
docker-image-digests.test.ts
docker-setup.e2e.test.ts
dockerfile.test.ts
entry.respawn.test.ts
entry.respawn.ts
entry.test.ts
entry.ts
entry.version-fast-path.test.ts
extensionAPI.ts
global-state.ts
globals.ts fix(types): annotate portable exported helper types 2026-04-04 03:57:47 +09:00
index.test.ts
index.ts refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
install-sh-version.test.ts
library.test.ts
library.ts refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
logger.test.ts
logger.ts
logging.ts
param-key.ts
plugin-activation-boundary.test.ts
poll-params.test.ts
poll-params.ts
polls.test.ts
polls.ts
runtime.ts
ui-app-settings.agents-files-refresh.test.ts
utils.test.ts test(plugins): finish moving contract coverage 2026-04-04 00:11:39 +01:00
utils.ts refactor(plugins): move extension seams into extensions 2026-04-04 00:10:16 +01:00
version.test.ts
version.ts