fix(core): replay cached CUA back/forward navigation steps#2014
fix(core): replay cached CUA back/forward navigation steps#2014BABTUNA wants to merge 1 commit intobrowserbase:mainfrom
Conversation
|
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Runner as Replay Runner
participant Cache as AgentCache
participant Ctx as V3Context
participant Page as Browser Page
Note over Runner,Page: Replay of Cached Agent Steps
Runner->>Cache: executeCachedSteps(entry)
loop For each Step in entry.steps
alt Step: goto
Cache->>Ctx: awaitActivePage()
Ctx-->>Cache: page
Cache->>Page: goto(url, { waitUntil })
else Step: navback (Legacy)
Cache->>Ctx: awaitActivePage()
Ctx-->>Cache: page
Cache->>Page: goBack({ waitUntil })
else NEW: Step: back
Cache->>Cache: replayAgentBackStep()
Cache->>Ctx: awaitActivePage()
Ctx-->>Cache: page
Cache->>Page: NEW: goBack({ waitUntil })
Page-->>Cache: navigation complete
else NEW: Step: forward
Cache->>Cache: replayAgentForwardStep()
Cache->>Ctx: awaitActivePage()
Ctx-->>Cache: page
Cache->>Page: NEW: goForward({ waitUntil })
Page-->>Cache: navigation complete
else Other steps (act, keys, etc.)
Cache->>Cache: process step...
end
end
Cache-->>Runner: result (success/failure)
why
CUA replay currently records
back/forwardsteps butAgentCacheonlyreplays
navback.This causes cached CUA runs to silently skip history navigation actions,
which can drift page state and break deterministic replay.
what changed
backforwardAgentCachereplay switch to execute:backviapage.goBack(...)forwardviapage.goForward(...)navbackreplay behavior for compatibility.gotonavbackbackforwardtest plan
prettier --checkon touched fileseslinton touched filestsc -p packages/core/tsconfig.json --noEmitpackages/core/tests/unit/cache-llm-resolution.test.tsSummary by cubic
Fixes cached CUA replays skipping browser history.
AgentCachenow replaysbackandforwardsteps to keep page state deterministic.backandforwardreplay step types and handle them inAgentCacheviapage.goBack/page.goForwardwithwaitUntil(defaultdomcontentloaded).navbackbehavior for compatibility.goto,navback,back, andforward.Written for commit c3362fc. Summary will update on new commits. Review in cubic