Repository navigation
Conversation
…vigated tab When a tool call does not specify tab_id, resolveVisibleTargetTab picked the Agent Window's live active tab every time. The Agent Window holds several tabs (a user-opened tab or extension popup can become active), so a session that navigated or observed a page could silently retarget the next untargeted call to a different document — evaluate ran against an unrelated page with no error, and the caller got no tab identity to notice. The session now remembers the tab it last navigated or observed (SessionContext.lastTabId, set by handleNavigate and handleVomObservation) and untargeted resolution anchors to it, falling back to the live active tab only when the anchored tab has closed or left the Agent Window. Fixes Tencent#420
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
When a tool call does not specify
tab_id,resolveVisibleTargetTabpicked the Agent Window's live active tab on every call. The Agent Window holds several tabs — a user-opened tab or an extension popup can become the active one — so a session that navigated or observed a page could silently retarget the next untargeted call to a different document. Concretely (issue #420): after acdp_extension_access_denied/ re-navigate,bsk evaluateran against an unrelated tab with no error, and the caller got no tab identity in the result to notice.Why
This is a correctness / safety hazard for in-page agents: a script written for one page (fill forms, read values) runs in another, with no indication. The issue's Expected is explicit: "
evaluate,clickandfillin a session always target the session's own tab, the one its lastnavigateorobservereported."What changed
SessionContext.lastTabId— the tab the session last navigated / observed / read.handleNavigateandhandleVomObservationrecord the resolved target inlastTabIdafter their scope checks pass.resolveVisibleTargetTab(used by every untargeted tool call) anchors tolastTabIdwhen set, and falls back to the live active tab only when the anchored tab has closed or left the Agent Window.An explicit
tab_idis unchanged and always wins. The CDP-accessible fallback inresolveCdpAccessibleTargetTab(restricted-URL recovery for observe/snapshot) is untouched.How verified
apps/extension/src/tools/__tests__/shared.test.ts: anchor wins over a drifted active tab; fallback to active when anchored tab closed; fallback when anchored tab left the window; active tab used when nothing anchored yet.src/tools/__tests__suite: 1183 passed, 196 skipped (e2e requiring a real browser), 0 failed.tsc --noEmitclean.Notes
tab_idor anavigate/observeto it first — matching the issue's Expected.