Description
When replaying cached agent executions, steps are executed immediately after each other without waiting for page navigation to complete. This causes subsequent steps to run on the wrong page, leading to failed workflows.
Steps to Reproduce
- Record an agent workflow that includes navigation (e.g., login → click link → search)
- Run the workflow again to trigger cache replay
- Observe that steps after navigation-triggering actions fail or execute on the wrong page
Expected Behavior
After an action triggers page navigation (detected by URL change), replay should wait for the page to fully load before executing the next step.
Actual Behavior
Replay proceeds immediately to the next step without waiting for navigation, causing:
- Actions to execute on the previous page
- XPath selectors to fail or match wrong elements
- Workflow failures despite having valid cached data
Root Cause
In AgentCache.ts, the replay methods (replayAgentActStep, replayAgentFillFormStep, replayAgentKeysStep) execute cached actions but don't wait for navigation to complete before continuing to the next step.
Proposed Fix
After executing each action during replay:
- Capture URL before action
- Execute the action
- Check URL after action
- If URL changed, call
page.waitForLoadState("load") before continuing
This ensures the page is fully loaded before the next step executes.
Related
This issue was discovered while testing the fix for #1558 (custom tool caching). Both issues affect agent cache replay reliability.
Description
When replaying cached agent executions, steps are executed immediately after each other without waiting for page navigation to complete. This causes subsequent steps to run on the wrong page, leading to failed workflows.
Steps to Reproduce
Expected Behavior
After an action triggers page navigation (detected by URL change), replay should wait for the page to fully load before executing the next step.
Actual Behavior
Replay proceeds immediately to the next step without waiting for navigation, causing:
Root Cause
In
AgentCache.ts, the replay methods (replayAgentActStep,replayAgentFillFormStep,replayAgentKeysStep) execute cached actions but don't wait for navigation to complete before continuing to the next step.Proposed Fix
After executing each action during replay:
page.waitForLoadState("load")before continuingThis ensures the page is fully loaded before the next step executes.
Related
This issue was discovered while testing the fix for #1558 (custom tool caching). Both issues affect agent cache replay reliability.