Make the v4 examples consistent around .data wrapping - #2646
Open
akeimach wants to merge 1 commit into
Open
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 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)
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.
why
Standardizing the example snippets with
.datawrappingwhat changed
test plan
Summary by cubic
Standardized all v4 examples to read and print from
.datainstead of the full response, ensuring consistent payload handling across Go, Python, and TypeScript. Addresses Linear STG-2796.packages/sdk-go/examples): useresult.Datain prints/checks foract,observe, and aggregated outputs; adoptextractResult/observeResult/actResultnames.packages/sdk-python/examples): useresult.dataformodel_dumpand validations; rename toextract_result/observe_result/act_result; updatecustom_llm,custom_logging,extract,model_gateway,observe.packages/sdk-ts/examples): logresult.dataand validate on.data; rename toextractResult/observeResult/actResult; updateact,observe,extract,modelGateway,customLlm,customLogging.Written for commit 55e390b. Summary will update on new commits.