Add back default extract schema - #2562
Conversation
|
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
46af76b to
1fa988f
Compare
|
@miguelg719 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Architecture diagram
sequenceDiagram
participant TSClient as TypeScript SDK Client
participant PyClient as Python SDK Client
participant GoClient as Go SDK Client
participant Stagehand as Stagehand (core)
participant ProtocolRPC as Protocol RPC Client
participant DocSite as Documentation Site
Note over TSClient,GoClient: PR: Default extract schema across all 3 SDKs
alt TypeScript call with no schema
TSClient->>TSClient: Uses defaultExtractSchema (z.object({ extraction: z.string() }))
TSClient->>Stagehand: extract(instruction, schema = undefined)
Stagehand->>Stagehand: resolvedSchema = defaultExtractSchema
Stagehand->>Stagehand: Generate JSON schema from resolvedSchema
Stagehand->>ProtocolRPC: stagehand.extract with schema = { type: "object", properties: { extraction: { type: "string" } }, required: ["extraction"], additionalProperties: false }
ProtocolRPC-->>Stagehand: ExtractResult { data: { extraction: "..." } }
Stagehand->>Stagehand: Parse response with resolvedSchema
Stagehand-->>TSClient: ExtractResult<typeof defaultExtractSchema>
else Python call with default schema class
PyClient->>PyClient: Uses DefaultExtract model
PyClient->>Stagehand: extract(instruction, schema = DefaultExtract)
Stagehand->>Stagehand: schema is DefaultExtract → use _DEFAULT_EXTRACT_SCHEMA dict
Stagehand->>ProtocolRPC: stagehand.extract with schema = { "type": "object", "properties": { "extraction": { "type": "string" } }, "required": ["extraction"], "additionalProperties": false }
ProtocolRPC-->>Stagehand: ExtractResult { data: { extraction: "..." } }
Stagehand-->>PyClient: ExtractResult[DefaultExtract]
else Go call with nil schema
GoClient->>GoClient: schema parameter = nil
GoClient->>Stagehand: Extract(instruction, schema = nil)
Stagehand->>Stagehand: schema == nil → Use defaultExtractSchema() JSON
Stagehand->>ProtocolRPC: stagehand.extract with schema = { "type": "object", "properties": { "extraction": { "type": "string" } }, "required": ["extraction"], "additionalProperties": false }
ProtocolRPC-->>Stagehand: ExtractResult { Data: { extraction: "..." } }
Stagehand-->>GoClient: ExtractResult
end
Note over GoClient,GoClient: Explicit empty schema path (Go only)
alt Go: schema = json.RawMessage{} (empty)
GoClient->>Stagehand: Extract(instruction, schema = {})
Stagehand->>Stagehand: schema is not nil → Preserve empty schema
Stagehand->>ProtocolRPC: stagehand.extract with schema = {}
ProtocolRPC-->>Stagehand: ExtractResult { Data: {} }
Stagehand-->>GoClient: ExtractResult with empty data
end
Note over TSClient,PyClient: TypeScript: generic overload guard
alt TS caller tries generic without runtime schema
TSClient->>TSClient: extract<CustomSchema>(instruction, undefined)
TSClient->>TSClient: @ts-expect-error – TypeScript prevents this
Note over TSClient: Compile-time type safety preserved
end
DocSite->>DocSite: Updated docs: schema param marked optional, describes default
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
e874cab to
ba30761
Compare
There was a problem hiding this comment.
All reported issues were addressed across 14 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
a876f77 to
fdbf349
Compare
fdbf349 to
838df58
Compare
Summary
Verification
Notes
Summary by cubic
Restore a protocol-level default extract schema so extract() works without a schema and returns { extraction: string } by default across
@browserbasehq/stagehand,@browserbasehq/stagehand-python, and@browserbasehq/stagehand-go. Makes the schema optional in the protocol and server, adds type-safe defaults/overloads, and updates docs/tests for Linear STG-2747.New Features
{ extraction: string }), makeschemaoptional, and apply the default in the router and wire models.@browserbasehq/stagehand): default toDefaultExtractDataSchemawhen no Zod schema is provided, accept options as the second arg, validate with the chosen schema, and only sendschemawhen custom.@browserbasehq/stagehand-python): addDefaultExtractmodel and overload; generated params default to the protocol schema; only sendschemawhen custom.@browserbasehq/stagehand-go): omitschemaby default viaomitempty; client sets params only when a custom schema is provided.schemaoptional and document the default; adjust TS docs/tests to reflect schema-bearing overload return type; add server/protocol and SDK tests for default behavior.Bug Fixes
{}) and ensure it is sent on the wire.Written for commit 838df58. Summary will update on new commits.