Skip to content

fix(stagehand): cap the stagehand dependency below the breaking 4.x API - #2153

Merged
vdusek merged 1 commit into
masterfrom
worktree-fix-stagehand-import
Aug 12, 2026
Merged

fix(stagehand): cap the stagehand dependency below the breaking 4.x API#2153
vdusek merged 1 commit into
masterfrom
worktree-fix-stagehand-import

Conversation

@vdusek

@vdusek vdusek commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

The scheduled E2E tests fail on every stagehand template job with:

ImportError: cannot import name 'AsyncStagehand' from 'stagehand'

stagehand 4.0.0, released on 2026-08-10, is a breaking API redesign. AsyncStagehand and AsyncSession are gone in favour of a single Stagehand plus Page / Locator, and the whole stagehand.types.session_* module tree that _stagehand_types.py imports was removed. The stagehand extra declared stagehand>=3.19.5 with no upper bound, so the Actor image resolved 4.0.0 and the plugin's top-level import failed, surfaced through try_import as the misleading message above.

Our own CI never saw it, because uv.lock pins 3.22.0 and only the Actor image resolves the dependency fresh. That is also why some stagehand jobs still passed: they reused image layers cached before 4.0.0 was published.

This caps the extra at <4.0.0, matching the existing sqlalchemy[asyncio]>=2.0.0,<3.0.0 style. Migrating the integration to the 4.x API is a separate piece of work.

Verified by mirroring the Actor Dockerfile's pip install ./wheel[stagehand,httpx]: the capped wheel resolves stagehand 3.22.0 and imports StagehandCrawler, StagehandBrowserPlugin, StagehandOptions and StagehandPage cleanly, while a wheel built from master resolves 4.0.0 and reproduces the traceback above.

Failing run: https://github.com/apify/crawlee-python/actions/runs/31583394515

✍️ Drafted by Claude Code

@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels Aug 12, 2026
@vdusek vdusek self-assigned this Aug 12, 2026
@github-actions github-actions Bot added this to the 147th sprint - Tooling team milestone Aug 12, 2026
@vdusek vdusek mentioned this pull request Aug 12, 2026
@vdusek
vdusek marked this pull request as ready for review August 12, 2026 12:03
@vdusek
vdusek requested a review from Pijukatel August 12, 2026 12:03
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.66%. Comparing base (091410f) to head (b14d9e4).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2153      +/-   ##
==========================================
+ Coverage   93.51%   93.66%   +0.15%     
==========================================
  Files         181      181              
  Lines       12653    12653              
==========================================
+ Hits        11832    11851      +19     
+ Misses        821      802      -19     
Flag Coverage Δ
unit 93.66% <ø> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek changed the title fix: cap the stagehand dependency below the breaking 4.x API fix(stagehand): cap the stagehand dependency below the breaking 4.x API Aug 12, 2026
@vdusek
vdusek merged commit 263fff4 into master Aug 12, 2026
36 checks passed
@vdusek
vdusek deleted the worktree-fix-stagehand-import branch August 12, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants