add ignoreLocators to act - #2655
Conversation
|
d588415 to
86105f1
Compare
720514d to
e5dff1f
Compare
5a7e4f2 to
34695fc
Compare
There was a problem hiding this comment.
All reported issues were addressed across 25 files
Architecture diagram
sequenceDiagram
participant SDK as Client SDK (TS/Py/Go)
participant RPC as Stagehand RPC
participant Svc as Act Service
participant Page as Page Snapshot
participant Cache as Cache Service
participant LLM as LLM Provider
Note over SDK,LLM: NEW: Locator-scoped act flow
SDK->>SDK: Resolve target page (explicit or active)
alt Locator not owned by target page
SDK-->>SDK: Throw "locator must belong to page"
else Valid locators
SDK->>SDK: Serialize locator & ignoreLocators to descriptors
SDK->>RPC: NEW: stagehand.act(pageId, instruction, options {locator, ignoreLocators})
RPC->>Svc: Dispatch act request
Svc->>Svc: Build snapshotOptions {focusLocator, ignoreLocators}
Svc->>Cache: NEW: Build cache key with locator + ignoreLocators
alt Cache hit
Cache-->>Svc: Cached action result
Svc-->>RPC: Cached result
else Cache miss
Svc->>Page: NEW: captureSnapshot(snapshotOptions)
Page-->>Svc: Locator-scoped DOM tree
Svc->>LLM: Generate act plan (instruction + scoped DOM)
LLM-->>Svc: Plan result (elementId, method, args)
Svc->>Page: NEW: captureSnapshot(snapshotOptions) for change verification
Page-->>Svc: Diff tree
Svc->>Cache: NEW: Store result with locator-aware key
Svc-->>RPC: Result
end
RPC-->>SDK: ActResult
end
Note over Svc: Recorded Action replays use its own selector,<br/>ignoring locator scoping
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
fbf39ac to
6362f37
Compare
34695fc to
19116e1
Compare
b7166c0 to
6e038da
Compare
There was a problem hiding this comment.
All reported issues were addressed across 27 files
Architecture diagram
sequenceDiagram
participant User as SDK User Code
participant SDK as SDK Client (TS/Py/Go)
participant Batch as Callback Batch (TS)
participant RPC as JSON-RPC Protocol
participant ActSvc as Extension actService
participant CacheSvc as Cache Service
participant Page as Page.captureSnapshot
participant LLM as Model (LLM)
Note over User,LLM: Locator-scoped instruction-based act() flow
User->>SDK: act(instruction, { page, locator, ignoreLocators })
SDK->>SDK: Resolve target page (explicit or active page)
alt Locator from a different page
SDK-->>User: Error: locator must belong to target page
end
alt Instruction is an Action (recorded observe result)
SDK->>RPC: stagehand.act (no locator options)
Note over ActSvc,LLM: Action.selector replayed directly - scoping not applied
else Instruction is a string
SDK->>SDK: Serialize locator descriptors ({selector, nth})
SDK->>RPC: stagehand.act(pageId, instruction, options with locator/ignoreLocators)
alt User composes callback batch
User->>Batch: act(instruction, { locator, ignoreLocators })
Batch->>Batch: resolveOperationPage + serializeClientLocatorOptions("act", ...)
Batch->>RPC: stagehand.act (same wire shape)
end
RPC->>ActSvc: act(params)
ActSvc->>CacheSvc: shouldBypassCacheForLocatorScope(options)
CacheSvc-->>ActSvc: locator or ignoreLocators present?
alt Locator scope set
Note over ActSvc,CacheSvc: Cache reads/writes skipped (status DISABLED)
end
ActSvc->>ActSvc: buildActCacheData(params) - omits locator keys
ActSvc->>Page: captureSnapshot({ focusLocator, ignoreLocators })
Page-->>ActSvc: Combined tree scoped to focus, excludes ignored subtrees
ActSvc->>LLM: Build act prompt from filtered snapshot
LLM-->>ActSvc: Action plan (elementId within scope)
ActSvc->>Page: captureSnapshot({ focusLocator, ignoreLocators }) for verification
Page-->>ActSvc: Next scoped tree
ActSvc->>ActSvc: diffTrees + build step-two prompt
LLM-->>ActSvc: Verify action result
ActSvc-->>RPC: ActResult (metadata.cache.status: DISABLED)
RPC-->>SDK: ActResult
SDK-->>User: ActResult
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
why
act/extract/observewhat changed
this PR extends locator-based scoping to instruction-based/nondeterministic
actignoreLocatorsto theactprotocol optionslocatorandignoreLocatorsthrough act snapshot capture so the model only sees the intended page contextactSDK Shape
TypeScript:
Python:
Go:
behavioural notes:
Action.selectordata directly. Locator scoping only affects instruction-based/nondeterministicactpageremains optional. If omitted, Stagehand resolves the active page & validates locators against that pageselector& optionalnthinternallyignoreLocatorsremoves matched nodes & descendants from the act planning snapshotlocatorandignoreLocators, so scoped planning does not reuse incompatible cached actionsactStagehandClientActOptionsnow uses explicit client fields instead of embedding generated protocolActOptionstest plan
locatorandignoreLocatorsLocatorinputs, descriptor serialization, and cross-page validation*PageLocatorconversion, cross-page validation, and generated model compatibility for the SDK/internal packagesSummary by cubic
Adds locator scoping to instruction-based
act()with a newignoreLocatorsoption so the model plans within a focused DOM and excludes ignored regions. Scopedact()bypasses server-side caching and sends locators to snapshot capture for both planning and verification.New Features
ignoreLocatorstoactoptions; passlocatorandignoreLocatorsto snapshot capture for planning and the verification step.act()bypasses server-side result caching and reportsmetadata.cache.status: DISABLED.ignore_locatorstoActOptionsin the v4 schema.act()only; replays of recordedActions use their own selectors.SDKs
sdk-ts:actaccepts locator wrappers and serializes them in direct calls and callback batches (page resolution + locator serialization foract,observe,extract); cross-page validation added.sdk-python:actacceptslocatorandignore_locatorsas page-bound locators with cross-page validation.sdk-go:StagehandClientActOptionsuses flattened fields (Page,Locator,IgnoreLocators,Timeout,Variables,Model,Cache);actserializesPageLocators with cross-page validation.act()scoping examples, cache bypass behavior, and Go option shape; speed and caching guides show scopedact()usage.Written for commit 6e038da. Summary will update on new commits.