You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes stale visual feedback after Google CUA custom tools by attaching a fresh screenshot to custom tool function responses.
Also normalizes side-effect-only custom tool results so tools like Playwright fill() no longer report undefined back to the model, and keeps the CUA client's current URL synchronized whenever the screenshot provider captures the active page.
Motivation
In #1635, custom tools can mutate the page successfully, but the next Google CUA turn may not receive a fresh visual observation. That can make the model conclude that a tool did nothing and then retry the same work with lower-level computer actions.
The repro also uses tools whose implementations return undefined, which is common for side-effect-only browser operations. Passing that raw value back makes a successful action look ambiguous in the model transcript.
Changes
Attach one post-action screenshot to Google custom tool functionResponse parts.
Reuse that screenshot when a step includes both custom tools and computer-use function calls, avoiding duplicate screenshots for the same post-action state.
Add a shared custom tool result formatter so undefined becomes Tool executed successfully across Google, OpenAI, and Anthropic CUA clients.
Update the V3 CUA screenshot provider to refresh the client URL from the active page whenever it captures a screenshot.
Add unit coverage for Google custom tool screenshots, undefined custom tool results, mixed custom/computer-use responses, and screenshot-provider URL synchronization.
Result: build passed; 5 unit test files passed with 23 tests; Prettier passed; git diff --check passed.
Risk
The Google CUA path now includes an image in custom tool function responses, which is the intended behavior for this issue but may slightly increase payload size after custom tools. The screenshot is captured once per post-action state and reused for mixed responses to keep that cost bounded.
For OpenAI and Anthropic, this PR only normalizes successful undefined custom tool results; it does not add screenshots to their custom tool outputs.
Fixes stale screenshots in Google CUA after custom tools by attaching a fresh post-action screenshot and reusing it within the step. Also normalizes side-effect-only tool results and keeps the client URL in sync when screenshots are captured.
Bug Fixes
Google CUA: Attach one post-action screenshot to custom tool functionResponse, and reuse it for any computer-use responses in the same step.
Custom tools: Convert undefined returns to "Tool executed successfully" across Google, OpenAI, and Anthropic via a shared formatter.
Screenshot provider: Update the CUA client’s current URL from the active page on each capture.
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.
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
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.
Summary
Fixes stale visual feedback after Google CUA custom tools by attaching a fresh screenshot to custom tool function responses.
Also normalizes side-effect-only custom tool results so tools like Playwright
fill()no longer reportundefinedback to the model, and keeps the CUA client's current URL synchronized whenever the screenshot provider captures the active page.Motivation
In #1635, custom tools can mutate the page successfully, but the next Google CUA turn may not receive a fresh visual observation. That can make the model conclude that a tool did nothing and then retry the same work with lower-level computer actions.
The repro also uses tools whose implementations return
undefined, which is common for side-effect-only browser operations. Passing that raw value back makes a successful action look ambiguous in the model transcript.Changes
functionResponseparts.undefinedbecomesTool executed successfullyacross Google, OpenAI, and Anthropic CUA clients.Test Plan
Result: build passed; 5 unit test files passed with 23 tests; Prettier passed;
git diff --checkpassed.Risk
The Google CUA path now includes an image in custom tool function responses, which is the intended behavior for this issue but may slightly increase payload size after custom tools. The screenshot is captured once per post-action state and reused for mixed responses to keep that cost bounded.
For OpenAI and Anthropic, this PR only normalizes successful
undefinedcustom tool results; it does not add screenshots to their custom tool outputs.Related Issue
Fixes #1635
Summary by cubic
Fixes stale screenshots in Google CUA after custom tools by attaching a fresh post-action screenshot and reusing it within the step. Also normalizes side-effect-only tool results and keeps the client URL in sync when screenshots are captured.
functionResponse, and reuse it for any computer-use responses in the same step.Written for commit 7350c86. Summary will update on new commits. Review in cubic