fix(core): update cache when validation fails after DOM changes #1729
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
Fixes a bug where cached xpath entries are not updated when they become invalid due to DOM changes, causing subsequent executions to repeatedly fail.
Problem
When page DOM structure changes (e.g., elements are moved or removed), the cached xpath becomes invalid. Previously:
rectMatchesCacheFeature) failsThis created a loop where users had to manually delete cache files to fix the issue.
Root Cause
In
packages/core/src/agent/task-builder.ts:506, the cache write condition included:This check was designed to avoid redundant cache writes for plan hit scenarios (when LLM provides bbox), but it incorrectly blocked cache updates when:
Solution
Modified the cache write condition to:
This change:
Changes
Core Logic
packages/core/src/agent/task-builder.ts!locateCacheAlreadyExiststo(!isPlanHit || !locateCacheAlreadyExists)Tests
packages/core/tests/unit-test/bbox-locate-cache.test.tsTest Results
✅ All tests pass (275 tests, 0 failures)
Behavior Change
Before Fix
After Fix
Impact
Related Issue
Reported by user: Cache not updated after DOM structure changes (from 4 grade options to 1 grade option), causing persistent failures despite AI successfully re-locating elements.