Accept instruction and schema positionally in Python observe and extract - #2539
Merged
Conversation
|
Contributor
There was a problem hiding this comment.
No issues found across 16 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Caller as Python SDK Caller
participant Stagehand as Stagehand Class
participant Test as Signature Test (pytest)
Note over Caller,Stagehand: NEW: Positional calling convention
Caller->>Stagehand: observe("Find the button") NEW: positional instruction
Stagehand->>Stagehand: process observe
Stagehand-->>Caller: ObserveResult
Caller->>Stagehand: extract("Get title", PageInfo) NEW: pos instruction+schema
Stagehand->>Stagehand: execute extraction
Stagehand-->>Caller: ExtractResult
alt Keyword‑only (unchanged)
Caller->>Stagehand: observe(instruction="...", selector="...")
end
Note over Test: Enforces POSITIONAL_OR_KEYWORD before *
Test->>Stagehand: inspect.signature(observe)
Test-->>Test: assert 1st param is positional (instruction)
Test->>Stagehand: inspect.signature(extract)
Test-->>Test: assert 1st & 2nd params are positional (instruction, schema)
Test->>Stagehand: inspect.signature(act)
Test-->>Test: assert first param is positional (instruction)
Note over Test: All remaining params must be KEYWORD_ONLY
miguelg719
force-pushed
the
v4-spike-python-positional
branch
from
August 3, 2026 05:17
6122801 to
e4deddb
Compare
akeimach
approved these changes
Aug 3, 2026
…and extract Stagehand.observe and Stagehand.extract made instruction (and schema) keyword-only, while Stagehand.act and both the TypeScript and Go SDKs take them positionally. Move them ahead of the bare * so required semantic arguments are positional in every language, with options keyword-only. Backward compatible for callers already passing them as keywords. Updates the Python examples, README, and v4 docs snippets to the positional form, and adds a signature test so act/observe/extract cannot drift back.
miguelg719
force-pushed
the
v4-spike-python-positional
branch
from
August 3, 2026 21:54
afe2307 to
7daa322
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
instruction(andschema) ahead of the bare*inStagehand.observeandStagehand.extract, matchingactand the TypeScript and Go SDKsobserveandextracttake keyword-only argumentsact/observe/extractcannot drift back to keyword-onlyBackward compatible: callers already passing these as keywords are unaffected.
Validation
ruff format --check,ruff check,ty checkpytest(211 passed)vitest run rules/ast-grep packages/docs/tests(42 passed)