Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/horned-giga-cockatoo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stagehand": patch
---

Added support for Gemini Computer Use models
6 changes: 3 additions & 3 deletions examples/agent_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def main():
self_heal=True,
system_prompt="You are a browser automation assistant that helps users navigate websites effectively.",
model_client_options={"apiKey": os.getenv("MODEL_API_KEY")},
verbose=1,
verbose=2,
)

# Create a Stagehand client using the configuration object.
Expand All @@ -64,9 +64,9 @@ async def main():

console.print("\n▶️ [highlight] Using Agent to perform a task[/]: playing a game of 2048")
agent = stagehand.agent(
model="computer-use-preview",
model="gemini-2.5-computer-use-preview-10-2025",
instructions="You are a helpful web navigation assistant that helps users find information. You are currently on the following page: google.com. Do not ask follow up questions, the user will trust your judgement.",
options={"apiKey": os.getenv("MODEL_API_KEY")}
options={"apiKey": os.getenv("GEMINI_API_KEY")}
)
agent_result = await agent.execute(
instruction="Play a game of 2048",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Python SDK for Stagehand"
readme = "README.md"
classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]
requires-python = ">=3.9"
dependencies = [ "httpx>=0.24.0", "python-dotenv>=1.0.0", "pydantic>=1.10.0", "playwright>=1.42.1", "requests>=2.31.0", "browserbase>=1.4.0", "rich>=13.7.0", "openai>=1.99.6", "anthropic>=0.51.0", "litellm>=1.72.0,<1.75.0", "nest-asyncio>=1.6.0",]
dependencies = [ "httpx>=0.24.0", "python-dotenv>=1.0.0", "pydantic>=1.10.0", "playwright>=1.42.1", "requests>=2.31.0", "browserbase>=1.4.0", "rich>=13.7.0", "openai>=1.99.6", "anthropic>=0.51.0", "litellm>=1.72.0,<1.75.0", "nest-asyncio>=1.6.0", "google-genai>=1.40.0"]
[[project.authors]]
name = "Browserbase, Inc."
email = "support@browserbase.com"
Expand Down
9 changes: 7 additions & 2 deletions stagehand/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@
)
from .anthropic_cua import AnthropicCUAClient
from .client import AgentClient
from .google_cua import GoogleCUAClient
from .openai_cua import OpenAICUAClient

MODEL_TO_CLIENT_CLASS_MAP: dict[str, type[AgentClient]] = {
"computer-use-preview": OpenAICUAClient,
"computer-use-preview-03-11": OpenAICUAClient,
"claude-3-5-sonnet-latest": AnthropicCUAClient,
"claude-3-7-sonnet-latest": AnthropicCUAClient,
"claude-sonnet-4-20250514": AnthropicCUAClient,
"claude-sonnet-4-5-20250929": AnthropicCUAClient,
"gemini-2.5-computer-use-preview-10-2025": GoogleCUAClient,
}
MODEL_TO_PROVIDER_MAP: dict[str, AgentProvider] = {
"computer-use-preview": AgentProvider.OPENAI,
"computer-use-preview-03-11": AgentProvider.OPENAI,
"claude-3-5-sonnet-20240620": AgentProvider.ANTHROPIC,
"claude-3-7-sonnet-20250219": AgentProvider.ANTHROPIC,
"claude-sonnet-4-20250514": AgentProvider.ANTHROPIC,
"claude-sonnet-4-5-20250929": AgentProvider.ANTHROPIC,
"gemini-2.5-computer-use-preview-10-2025": AgentProvider.GOOGLE,
# Add more mappings as needed
}

Expand Down
2 changes: 1 addition & 1 deletion stagehand/agent/anthropic_cua.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
)

dimensions = (
(viewport["width"], viewport["height"]) if viewport else (1024, 768)
(viewport["width"], viewport["height"]) if viewport else (1288, 711)
) # Default dimensions
if self.config:
if hasattr(self.config, "display_width") and self.config.display_width is not None: # type: ignore
Expand Down
Loading