Skip to content

Migrate Python templates from Stagehand SDK v2 to v3#41

Open
shrey150 wants to merge 2 commits intodevfrom
shrey/python-v3-migration
Open

Migrate Python templates from Stagehand SDK v2 to v3#41
shrey150 wants to merge 2 commits intodevfrom
shrey/python-v3-migration

Conversation

@shrey150
Copy link
Contributor

@shrey150 shrey150 commented Jan 21, 2026

Summary

Migrate templates to V3

Testing

  • MFA-handling: ✅ Full test passed
  • company-value-prop-generator: ✅ Full test passed
  • council-events: ✅ Full test passed
  • form-filling: ✅ Full test passed
  • polymarket-research: ✅ Full test passed
  • nurse-verification: ✅ Full test passed
  • Other templates: Code verified, require specific API keys or credentials

🤖 Generated with Claude Code

Restore important descriptive comments across all 18 Python templates:
- Replace "V3 BYOB architecture" with "cloud-based browser automation"
- Add "Connect to the browser via CDP" comments before sync_playwright sections
- Restore Pydantic model explanations and compatibility notes
- Restore caching behavior and context management documentation
- Restore login/navigation sequence explanations
- Keep all Pydantic models using model_json_schema() for extract

All templates tested for correctness where API keys available.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@shrey150 shrey150 changed the title Restore descriptive comments in Python v3 migration Migrate Python templates from Stagehand SDK v2 to v3 Jan 21, 2026
@jay-sahnan
Copy link
Contributor

jay-sahnan commented Jan 28, 2026

Great work on the migration! One suggestion for simplification:

Not all templates need Playwright connection

For templates that only use act(), extract(), and observe() (without needing Playwright-specific methods like wait_for_load_state(), locator(), or event listeners), you can use the pure Stagehand API without connecting Playwright.

Like: council-events, polymarket-research, form-filling, and license-verification all connect via Playwright CDP but only use Stagehand's act() and extract().

@jay-sahnan
Copy link
Contributor

Please can you also update the READMEs for each template for python, referencing the new docs and new syntax?

print("4. Verify Browserbase account has sufficient credits")
print("5. Check if the calendar page structure has changed")

client.sessions.end(id=session_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are double session end calls here, could this be put in a Finally block?

Address PR review feedback:
- Remove Playwright CDP connection from templates that only use act() and extract()
- Use client.sessions.navigate() instead of page.goto()
- Move session.end() to finally blocks to avoid duplicate calls
- Remove unnecessary inline schema comment
- Update READMEs with simplified quickstart instructions

Affected templates: council-events, license-verification, form-filling,
polymarket-research

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@shrey150 shrey150 requested a review from jay-sahnan February 3, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants