[AI-assisted] fix(agents): invalidate context engine cache#78163
[AI-assisted] fix(agents): invalidate context engine cache#78163jalehman merged 2 commits intoopenclaw:mainfrom
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. source-level: current main keeps Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the narrow cache invalidation after live Gateway/context-engine proof shows reset and assemble-failure paths no longer reuse stale pre-reset messages, and after required checks are green or explicitly deemed unrelated. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main keeps Is this the best way to solve the issue? Yes, the code direction is the narrow maintainable fix: track the source length that produced the cached assembled view and clear the cache on shrink or engine failure. The remaining blocker is proof and gate readiness, not a definite implementation defect. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 97b07eaeaf38. |
2663018 to
ec9e105
Compare
|
Rebased this branch onto current New head: Focused validation after the rebase:
|
ec9e105 to
c575501
Compare
|
Rebased this branch onto current New head: Focused validation after the rebase:
|
|
Fresh CI on
This PR only changes:
I am not folding unrelated gateway cron test fixes into this context-engine PR; leaving this for upstream/main or maintainer rerun. |
f1a4693 to
546fced
Compare
546fced to
6ed3add
Compare
|
Merged via squash.
Thanks @brokemac79! |
Summary
Fixes #77968.
Real behavior proof
Behavior or issue addressed:
installContextEngineLoopHookcould return a previously cached assembled context view after the live source history shrank or after a laterassemble()failure, allowing stale pre-reset context to be reused.Real environment tested: Local Windows checkout of this PR branch at commit
2663018ee2, using Node/pnpm from the repository toolchain.Exact steps or command run after this patch: Inspected the patched hook and ran
git diff --check,corepack pnpm exec oxfmt --check --threads=1 src/agents/pi-embedded-runner/tool-result-context-guard.ts src/agents/pi-embedded-runner/tool-result-context-guard.test.ts CHANGELOG.md,corepack pnpm test src/agents/pi-embedded-runner/tool-result-context-guard.test.ts, andcorepack pnpm check:changed.Evidence after fix: Focused regression tests now prove the cache invalidates in both reported failure modes:
The focused test shard passed:
Observed result after fix: When source history shrinks, the hook clears the cached assembled view and returns the fresh source messages. When
assemble()throws after a previous successful cached view, the hook clears that cache and subsequent unchanged iterations no longer reuse stale assembled messages.What was not tested: I did not run a live Gateway session reset with a real context-engine plugin. This proof uses the core hook's focused regression tests and source-level behavior.
Validation
git diff --checkcorepack pnpm exec oxfmt --check --threads=1 src/agents/pi-embedded-runner/tool-result-context-guard.ts src/agents/pi-embedded-runner/tool-result-context-guard.test.ts CHANGELOG.mdcorepack pnpm test src/agents/pi-embedded-runner/tool-result-context-guard.test.tscorepack pnpm check:changed