Skip to content

Make the v4 examples consistent around .data wrapping - #2646

Open
akeimach wants to merge 1 commit into
v4-spikefrom
alyssamaruyama/stg-2796-make-the-v4-examples-consistent-around-data-wrapping
Open

Make the v4 examples consistent around .data wrapping#2646
akeimach wants to merge 1 commit into
v4-spikefrom
alyssamaruyama/stg-2796-make-the-v4-examples-consistent-around-data-wrapping

Conversation

@akeimach

@akeimach akeimach commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

why

Standardizing the example snippets with .data wrapping

what changed

test plan


Summary by cubic

Standardized all v4 examples to read and print from .data instead of the full response, ensuring consistent payload handling across Go, Python, and TypeScript. Addresses Linear STG-2796.

  • Refactors
    • Go (packages/sdk-go/examples): use result.Data in prints/checks for act, observe, and aggregated outputs; adopt extractResult/observeResult/actResult names.
    • Python (packages/sdk-python/examples): use result.data for model_dump and validations; rename to extract_result/observe_result/act_result; update custom_llm, custom_logging, extract, model_gateway, observe.
    • TypeScript (packages/sdk-ts/examples): log result.data and validate on .data; rename to extractResult/observeResult/actResult; update act, observe, extract, modelGateway, customLlm, customLogging.

Written for commit 55e390b. Summary will update on new commits.

Review in cubic

@changeset-bot

changeset-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 55e390b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Dev as Developer
    participant Ex as Example Script (Go / Python / TS)
    participant SDK as v4 SDK Client
    participant Result as Result Envelope (.data wrapper)

    Note over Dev,Result: Consistent .data payload handling across all v4 SDK examples

    Dev->>Ex: Run example (extract / observe / act)
    Ex->>SDK: Call stagehand.extract() / observe() / act()
    SDK->>Result: Wrap operation output into envelope
    Result-->>SDK: Result object (payload in .data)
    SDK-->>Ex: Return Result object

    Ex->>Result: Read result.data (NEW: access .data instead of whole result)
    Result-->>Ex: Typed operation payload

    alt Observe / Extract flow
        Ex->>Ex: Check result.data is non-empty (NEW)
        Ex->>Ex: Serialize result.data to JSON (model_dump / JSON.stringify / MarshalIndent)
    else Act flow
        Ex->>Ex: Check result.data.success flag (NEW)
        Ex->>Ex: Serialize result.data to JSON
        opt failure
            Ex->>Ex: Read result.data.message for error output
        end
    end

    Ex->>Dev: Print JSON output (NEW: printed payload is .data only)
Loading

Re-trigger cubic

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.

1 participant