Add structured output tutorial (22-structured-output)#272
Open
builder-ujaladi wants to merge 1 commit into
Open
Add structured output tutorial (22-structured-output)#272builder-ujaladi wants to merge 1 commit into
builder-ujaladi wants to merge 1 commit into
Conversation
Adds a new 01-learn tutorial covering Strands structured output: returning validated, typed Pydantic objects from agents instead of free-form text. Registered in the 01-learn index. The tutorial covers: - Basic structured output (sync + async) with a flat Pydantic model - Complex schemas: nested models, lists, Optional, field constraints, Literal, and Enum - Validation & self-correction: an exact-length field_validator that the LLM reliably fails on first attempt, plus a cell that prints the agent.messages retry trail so the fail-then-correct loop is visible - Tools + structured output: calculator tool feeding a typed result - A note on streaming (structured output arrives only in the final event) Incorporates peer-review feedback: - Simplified the architecture diagram to the core concept (prompt + model -> agent -> typed object) - Demoted streaming from a standalone section to a note - Added interpretation callouts after each output cell connecting the result back to the Pydantic feature being shown - Reworked self-correction so the validator genuinely fires and the retry trail is shown via agent.messages Verified end-to-end against Amazon Bedrock (Claude Sonnet 4.5).
|
Latest scan for commit: ✅ Security Scan Report (PR Files Only)Scanned Files
Security Scan Results
Threshold: High No security issues detected in your changes. Great job! This scan only covers files changed in this PR. |
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
Adds a new
01-learntutorial covering Strands structured output — returning validated, typed Pydantic objects from agents instead of free-form text. Also registers it in the01-learnindex.What's included
Optional, field constraints,Literal, andEnumfield_validatorthe LLM reliably fails on first attempt, plus a cell that prints theagent.messagesretry trail so the fail-then-correct loop is visiblecalculatortool feeding a typed resultPeer-review feedback addressed
agent.messagesTesting