Move custom code to dedicated files and cleanup v1 vs v2 checks
Merged
PI
7mo ago+572+572+012345678901234567890123456789-232-232-012345678901234567890123456789
Summary by cubic
Moved Pydantic extract logic into a dedicated module and auto-patched Session/AsyncSession to use it. Hard-required pydantic v2 at import time and added tests for extract behavior.
-
Refactors
- Added
src/stagehand/_session_extract.pyand auto-installed the extract patch insessions_helpers. - Centralized Pydantic response validation in
_pydantic_extract.pywith cached model config andstrict_response_validation. - Enforced
pydanticv2 in_compat.pywith a clear ImportError. - Simplified
session.pyby delegating extract logic and removing v1/v2 conditionals; added focused tests for session extract.
- Added
-
Migration
stagehandnow requirespydantic>=2,<3. Install or upgrade to v2.- Removed the
pydantic-v2extra frompyproject.toml; use standardpydanticv2 installation.