Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7a1801e
feat: add section in user guide on new functionality for Agent.as_tool()
Mar 19, 2026
482ff44
Add Dependabot configuration file (#684)
Unshure Mar 19, 2026
d4ba23c
docs: add guardLatestUserMessage to TypeScript Bedrock guardrails (#646)
Unshure Mar 19, 2026
ce9ab3b
chore: upgrade Astro to v6, Starlight to v0.38, Vite to v8, Node to v…
zastrowm Mar 20, 2026
f0a4404
feat: add tool cancellation typescript example (#687)
lizradway Mar 20, 2026
027afab
Create OVHcloud AI Endpoints community documentation (#335)
eliasto Mar 20, 2026
d4aacc9
docs(hooks): document exception property on AfterToolCallEvent (#482)
charles-dyfis-net Mar 20, 2026
ff81e19
docs: rename StructuredOutputException to StructuredOutputError for T…
pgrayy Mar 20, 2026
8c03236
docs: update TypeScript SDK import paths for model subpath exports (#…
pgrayy Mar 23, 2026
573c51d
docs: update OpenAI TypeScript examples from gpt-4o to gpt-5.4 (#697)
pgrayy Mar 23, 2026
4cfab3c
fix: convert metrics output section to collapsible details/summary (#…
zastrowm Mar 24, 2026
3a6e063
docs: update Kiro references (#702)
awsarron Mar 24, 2026
4cdbf07
docs: add getTracer custom spans example to traces page (#700)
lizradway Mar 25, 2026
4e07552
feat: add extension template docs (#704)
mkmeral Mar 25, 2026
1232ffe
docs: add TypeScript coverage to contribute, examples sections (#707)
pgrayy Mar 25, 2026
93d5af8
docs: update user guide for TypeScript SDK 1.0 RC (#708)
pgrayy Mar 25, 2026
f3eb75d
docs: add strands-google and strands-perplexity to community tools (#…
agent-of-mkmeral Mar 26, 2026
14f92c6
docs: update A2AExpressServer import path to sdk/a2a/express (#695)
pgrayy Mar 26, 2026
4ab85fa
docs: add TypeScript vended tools documentation (#685)
zastrowm Mar 27, 2026
f5fa437
feat(telemetry): add local trace docs (#705)
lizradway Mar 27, 2026
23612e7
fix: align docs with impl
Mar 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 100
commit-message:
prefix: ci
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 100
commit-message:
prefix: ci
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'

- name: Install dependencies
run: npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'

- name: Install dependencies
run: npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'

- name: Install dependencies
run: npm install
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.19.5
v22.12.0
126 changes: 18 additions & 108 deletions docs/examples/python/structured_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
This example demonstrates how to use structured output with Strands Agents to
get type-safe, validated responses using Pydantic models.
"""
import asyncio
import tempfile

from typing import List, Optional

from pydantic import BaseModel, Field
from strands import Agent


def basic_example():
"""Basic example extracting structured information from text."""
print("\n--- Basic Example ---")
Expand All @@ -22,80 +21,14 @@ class PersonInfo(BaseModel):
occupation: str

agent = Agent()
result = agent.structured_output(
PersonInfo,
"John Smith is a 30-year-old software engineer"
result = agent(
"John Smith is a 30-year-old software engineer",
structured_output_model=PersonInfo,
)

print(f"Name: {result.name}") # "John Smith"
print(f"Age: {result.age}") # 30
print(f"Job: {result.occupation}") # "software engineer"


def multimodal_example():
"""Basic example extracting structured information from a document."""
print("\n--- Multi-Modal Example ---")

class PersonInfo(BaseModel):
name: str
age: int
occupation: str

with tempfile.NamedTemporaryFile(delete=False) as person_file:
person_file.write(b"John Smith is a 30-year old software engineer")
person_file.flush()

with open(person_file.name, "rb") as fp:
document_bytes = fp.read()

agent = Agent()
result = agent.structured_output(
PersonInfo,
[
{"text": "Please process this application."},
{
"document": {
"format": "txt",
"name": "application",
"source": {
"bytes": document_bytes,
},
},
},
]
)

print(f"Name: {result.name}") # "John Smith"
print(f"Age: {result.age}") # 30
print(f"Job: {result.occupation}") # "software engineer"


def conversation_history_example():
"""Example using conversation history with structured output."""
print("\n--- Conversation History Example ---")

agent = Agent()

# Build up conversation context
print("Building conversation context...")
agent("What do you know about Paris, France?")
agent("Tell me about the weather there in spring.")

# Extract structured information without additional prompt
class CityInfo(BaseModel):
city: str
country: str
population: Optional[int] = None
climate: str

# Uses existing conversation context with a prompt
print("Extracting structured information from conversation context...")
result = agent.structured_output(CityInfo, "Extract structured information about Paris")

print(f"City: {result.city}")
print(f"Country: {result.country}")
print(f"Population: {result.population}")
print(f"Climate: {result.climate}")
print(f"Name: {result.structured_output.name}") # "John Smith"
print(f"Age: {result.structured_output.age}") # 30
print(f"Job: {result.structured_output.occupation}") # "software engineer"


def complex_nested_model_example():
Expand All @@ -121,47 +54,24 @@ class Person(BaseModel):
skills: List[str] = Field(default_factory=list, description="Professional skills")

agent = Agent()
result = agent.structured_output(
Person,
"Extract info: Jane Doe, a systems admin, 28, lives at 123 Main St, New York, USA. Email: jane@example.com"
)

print(f"Name: {result.name}") # "Jane Doe"
print(f"Age: {result.age}") # 28
print(f"Street: {result.address.street}") # "123 Main St"
print(f"City: {result.address.city}") # "New York"
print(f"Country: {result.address.country}") # "USA"
print(f"Email: {result.contacts[0].email}") # "jane@example.com"
print(f"Skills: {result.skills}") # ["systems admin"]


async def async_example():
"""Basic example extracting structured information from text asynchronously."""
print("\n--- Async Example ---")

class PersonInfo(BaseModel):
name: str
age: int
occupation: str

agent = Agent()
result = await agent.structured_output_async(
PersonInfo,
"John Smith is a 30-year-old software engineer"
result = agent(
"Extract info: Jane Doe, a systems admin, 28, lives at 123 Main St, New York, USA. Email: jane@example.com",
structured_output_model=Person,
)

print(f"Name: {result.name}") # "John Smith"
print(f"Age: {result.age}") # 30
print(f"Job: {result.occupation}") # "software engineer"
print(f"Name: {result.structured_output.name}") # "Jane Doe"
print(f"Age: {result.structured_output.age}") # 28
print(f"Street: {result.structured_output.address.street}") # "123 Main St"
print(f"City: {result.structured_output.address.city}") # "New York"
print(f"Country: {result.structured_output.address.country}") # "USA"
print(f"Email: {result.structured_output.contacts[0].email}") # "jane@example.com"
print(f"Skills: {result.structured_output.skills}") # ["systems admin"]


if __name__ == "__main__":
print("Structured Output Examples\n")

basic_example()
multimodal_example()
conversation_history_example()
complex_nested_model_example()
asyncio.run(async_example())

print("\nExamples completed.")
27 changes: 27 additions & 0 deletions docs/examples/typescript/structured_output/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Structured Output Example

Demonstrates how to use structured output with Strands Agents to get type-safe, validated responses using Zod schemas.

## Prerequisites

- Node.js 20+
- AWS credentials configured for Amazon Bedrock

## Setup

```bash
npm install
```

## Run

```bash
npm start
```

## What It Covers

- Basic structured output with Zod schemas
- Complex nested schemas

See the [Structured Output documentation](https://strandsagents.com/docs/examples/structured-output/) for more details.
17 changes: 17 additions & 0 deletions docs/examples/typescript/structured_output/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "structured-output-example",
"version": "1.0.0",
"description": "Structured output example using Strands Agents TypeScript SDK with Zod schemas",
"type": "module",
"scripts": {
"start": "npx tsx structured_output.ts"
},
"dependencies": {
"@strands-agents/sdk": "latest",
"zod": "^4.1.12"
},
"devDependencies": {
"tsx": "^4.21.0",
"typescript": "^5.3.3"
}
}
76 changes: 76 additions & 0 deletions docs/examples/typescript/structured_output/structured_output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Structured Output Example
*
* This example demonstrates how to use structured output with Strands Agents to
* get type-safe, validated responses using Zod schemas.
*/
import { Agent } from '@strands-agents/sdk'
import { z } from 'zod'

async function basicExample(): Promise<void> {
console.log('\n--- Basic Example ---')

const PersonInfo = z.object({
name: z.string(),
age: z.number(),
occupation: z.string(),
})

const agent = new Agent()
const result = await agent.invoke('John Smith is a 30-year-old software engineer', {
structuredOutputSchema: PersonInfo,
})

console.log(`Name: ${result.structuredOutput.name}`) // "John Smith"
console.log(`Age: ${result.structuredOutput.age}`) // 30
console.log(`Job: ${result.structuredOutput.occupation}`) // "software engineer"
}

async function complexNestedSchemaExample(): Promise<void> {
console.log('\n--- Complex Nested Schema Example ---')

const Address = z.object({
street: z.string(),
city: z.string(),
country: z.string(),
postalCode: z.string().optional(),
})

const Contact = z.object({
email: z.string().optional(),
phone: z.string().optional(),
})

const Person = z.object({
name: z.string().describe('Full name of the person'),
age: z.number().describe('Age in years'),
address: Address.describe('Home address'),
contacts: z.array(Contact).describe('Contact methods'),
skills: z.array(z.string()).describe('Professional skills'),
})

const agent = new Agent()
const result = await agent.invoke(
'Extract info: Jane Doe, a systems admin, 28, lives at 123 Main St, New York, USA. Email: jane@example.com',
{ structuredOutputSchema: Person },
)

console.log(`Name: ${result.structuredOutput.name}`) // "Jane Doe"
console.log(`Age: ${result.structuredOutput.age}`) // 28
console.log(`Street: ${result.structuredOutput.address.street}`) // "123 Main St"
console.log(`City: ${result.structuredOutput.address.city}`) // "New York"
console.log(`Country: ${result.structuredOutput.address.country}`) // "USA"
console.log(`Email: ${result.structuredOutput.contacts[0].email}`) // "jane@example.com"
console.log(`Skills: ${result.structuredOutput.skills}`) // ["systems admin"]
}

async function main(): Promise<void> {
console.log('Structured Output Examples\n')

await basicExample()
await complexNestedSchemaExample()

console.log('\nExamples completed.')
}

main()
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ nav:
- Amazon Bedrock: user-guide/concepts/model-providers/amazon-bedrock.md
- Amazon Nova: user-guide/concepts/model-providers/amazon-nova.md
- Anthropic: user-guide/concepts/model-providers/anthropic.md
- Gemini: user-guide/concepts/model-providers/gemini.md
- Google: user-guide/concepts/model-providers/google.md
- LiteLLM: user-guide/concepts/model-providers/litellm.md
- llama.cpp: user-guide/concepts/model-providers/llamacpp.md
- LlamaAPI: user-guide/concepts/model-providers/llamaapi.md
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@
"turndown": "^7.2.2",
"turndown-plugin-gfm": "^1.0.2",
"typedoc": "^0.28.14",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"vite": "^8.0.0"
},
"devDependencies": {
"@astrojs/starlight": "^0.37.3",
"@astrojs/starlight": "^0.38.1",
"@types/js-yaml": "^4.0.9",
"@types/mdast": "^4.0.4",
"@types/node": "^24.10.1",
"acorn": "^8.14.0",
"astro": "^5.6.1",
"astro": "^6.0.5",
"js-yaml": "^4.1.1",
"pino": "^9.7.0",
"pino-pretty": "^13.0.0",
Expand Down
6 changes: 4 additions & 2 deletions src/config/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ sidebar:
- docs/user-guide/concepts/tools/mcp-tools
- docs/user-guide/concepts/tools/executors
- docs/user-guide/concepts/tools/community-tools-package
- docs/user-guide/concepts/tools/vended-tools
- label: Plugins
items:
- docs/user-guide/concepts/plugins
Expand All @@ -77,7 +78,7 @@ sidebar:
- docs/user-guide/concepts/model-providers/amazon-bedrock
- docs/user-guide/concepts/model-providers/amazon-nova
- docs/user-guide/concepts/model-providers/anthropic
- docs/user-guide/concepts/model-providers/gemini
- docs/user-guide/concepts/model-providers/google
- docs/user-guide/concepts/model-providers/litellm
- docs/user-guide/concepts/model-providers/llamacpp
- docs/user-guide/concepts/model-providers/llamaapi
Expand Down Expand Up @@ -189,7 +190,7 @@ sidebar:
- docs/examples/python/file_operations
- docs/examples/python/agents_workflows
- docs/examples/python/knowledge_base_agent
- docs/examples/python/structured_output
- docs/examples/structured_output
- docs/examples/python/multi_agent_example/multi_agent_example
- docs/examples/python/graph_loops_example
- docs/examples/python/meta_tooling
Expand Down Expand Up @@ -217,6 +218,7 @@ sidebar:
- docs/community/model-providers/sglang
- docs/community/model-providers/vllm
- docs/community/model-providers/mlx
- docs/community/model-providers/ovhcloud-ai-endpoints
- docs/community/model-providers/xai
- label: Session Managers
items:
Expand Down
Loading
Loading