fix(cli): support multi-value selection in browse select#2012
fix(cli): support multi-value selection in browse select#2012BABTUNA 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. |
2cfc3b0 to
0229a82
Compare
There was a problem hiding this comment.
1 issue found across 5 files
Confidence score: 3/5
- There is a concrete medium-severity bug in
packages/core/lib/v3/agent/GoogleCUAClient.ts: screenshot pruning appliesmaxImagesper history entry rather than per screenshot, so limits can be exceeded in multi-call turns. - Given the high confidence (9/10) and user-visible behavior drift from configured image caps, this introduces some regression risk and keeps this in the “some risk” range rather than a safe low-risk merge.
- Pay close attention to
packages/core/lib/v3/agent/GoogleCUAClient.ts- pruning logic may retain more screenshots than configured when a turn includes multiple calls.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/core/lib/v3/agent/GoogleCUAClient.ts">
<violation number="1" location="packages/core/lib/v3/agent/GoogleCUAClient.ts:713">
P2: Screenshot pruning enforces `maxImages` per history entry instead of per actual screenshot, so multi-call turns can retain more images than configured.</violation>
</file>
Architecture diagram
sequenceDiagram
participant User as CLI / Consumer
participant Agent as GoogleCUAClient (Agent)
participant Hist as Session History (In-Memory)
participant Page as Browser Page (Playwright)
participant LLM as Gemini API
Note over User,Page: NEW: Multi-Select Flow (CLI)
User->>Page: browse select <selector> <val1> <val2>
Page->>Page: resolveSelector()
Page->>Page: NEW: deepLocator(selector)
alt Multiple values provided
Page->>Page: CHANGED: selectOption(["val1", "val2"])
else Single value provided
Page->>Page: CHANGED: selectOption("val1")
end
Page-->>User: Return selected values
Note over Agent,LLM: NEW: Agent History Pruning Flow (Memory Management)
Agent->>LLM: generateContent(history)
LLM-->>Agent: Function Call (e.g., screenshot)
Agent->>Page: Execute tool
Page-->>Agent: Tool Result (includes inlineData/Image)
Agent->>Hist: Append Tool Result to history
rect rgb(240, 240, 240)
Note over Agent,Hist: NEW: maybeRemoveOldScreenshots()
Agent->>Hist: Count entries with screenshots
opt Screenshot count > maxImages (Default: 3)
loop Older History entries
Agent->>Hist: NEW: Strip 'inlineData' (images)
Note right of Hist: Preserves metadata but frees memory
end
Agent->>User: Log pruning event (Level 2)
end
end
Agent->>LLM: Next turn with pruned history
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| }); | ||
|
|
||
| if (hasScreenshot) { | ||
| screenshotCount++; |
There was a problem hiding this comment.
P2: Screenshot pruning enforces maxImages per history entry instead of per actual screenshot, so multi-call turns can retain more images than configured.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/lib/v3/agent/GoogleCUAClient.ts, line 713:
<comment>Screenshot pruning enforces `maxImages` per history entry instead of per actual screenshot, so multi-call turns can retain more images than configured.</comment>
<file context>
@@ -662,6 +673,74 @@ export class GoogleCUAClient extends AgentClient {
+ });
+
+ if (hasScreenshot) {
+ screenshotCount++;
+ if (screenshotCount > this.maxImages) {
+ // Remove inlineData from old screenshots
</file context>
There was a problem hiding this comment.
whoops that was from a commit that shouldn't have belong to this PR my bad G
Summary
one.
Problem
browse select accepts variadic values (<values...>), but implementation
only forwarded values[0], so multi-select usage was broken :{.
Changes
with: