Skip to content

Commit f09bab5

Browse files
committed
revert changes to agent_example_local.py
1 parent b390a4b commit f09bab5

1 file changed

Lines changed: 7 additions & 47 deletions

File tree

examples/agent_example_local.py

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,12 @@
2626

2727
load_dotenv()
2828

29-
ANTHROPIC_MODEL = "claude-sonnet-4-20250514"
30-
REPRO_INSTRUCTION = (
31-
"Step 1: Use the goto tool to open https://example.com/.\n"
32-
"Step 2: After it loads, scroll down and click the 'More information...' link "
33-
"to open the iana.org page, then report the heading text you see."
34-
)
35-
ERROR_SIGNATURES = [
36-
"messages.1.content.1.tool_use.caller",
37-
"Extra inputs are not permitted",
38-
]
39-
4029
# Configure logging with the utility function
4130
configure_logging(
4231
level=logging.INFO, # Set to INFO for regular logs, DEBUG for detailed
4332
quiet_dependencies=True, # Reduce noise from dependencies
4433
)
4534

46-
47-
def require_env_var(var_name: str) -> str:
48-
"""Fetch a required env var with a helpful error for local runs."""
49-
value = os.getenv(var_name)
50-
if not value:
51-
raise RuntimeError(
52-
f"{var_name} is not set. Add it to your .env before running this example."
53-
)
54-
return value
55-
56-
5735
async def main():
5836
# Build a unified configuration object for Stagehand
5937
config = StagehandConfig(
@@ -75,37 +53,19 @@ async def main():
7553
await stagehand.page.goto("https://google.com/")
7654
console.print("✅ [success]Navigated to Google[/]")
7755

78-
console.print(
79-
"\n▶️ [highlight]Using Anthropic CUA agent[/]: reproducing the tool_use caller bug"
80-
)
81-
anthropic_api_key = require_env_var("ANTHROPIC_API_KEY")
56+
console.print("\n▶️ [highlight] Using Agent to perform a task[/]: playing a game of 2048")
8257
agent = stagehand.agent(
83-
model=ANTHROPIC_MODEL,
84-
instructions=(
85-
"You are controlling a fullscreen local browser with the Anthropic computer-use tools. "
86-
"Read the current page carefully, decide on your next action, and avoid asking follow-up questions."
87-
),
88-
options={"apiKey": anthropic_api_key}
58+
model="gemini-2.5-computer-use-preview-10-2025",
59+
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.",
60+
options={"apiKey": os.getenv("GEMINI_API_KEY")}
8961
)
9062
agent_result = await agent.execute(
91-
instruction=REPRO_INSTRUCTION,
92-
max_steps=5,
63+
instruction="Play a game of 2048",
64+
max_steps=20,
9365
auto_screenshot=True,
9466
)
9567

9668
console.print(agent_result)
97-
if agent_result.message and any(
98-
signature in agent_result.message for signature in ERROR_SIGNATURES
99-
):
100-
console.print(
101-
"🐛 [error]Reproduced the Anthropic `tool_use.caller` validation error.[/]\n"
102-
" Check the logs above for 'Extra inputs are not permitted' to link back to the GitHub issue."
103-
)
104-
else:
105-
console.print(
106-
"⚠️ [warning]Bug signature not detected in this run. "
107-
"Re-run the example or tweak the instructions if you need the failing payload."
108-
)
10969

11070
console.print("📊 [info]Agent execution result:[/]")
11171
console.print(f"🎯 Completed: [bold]{'Yes' if agent_result.completed else 'No'}[/]")
@@ -140,4 +100,4 @@ async def main():
140100
padding=(1, 10),
141101
),
142102
)
143-
asyncio.run(main())
103+
asyncio.run(main())

0 commit comments

Comments
 (0)