skills/strandagents/SKILL.md
Strands Agents SDK: build Python AI agents with OpenAI, tools, Docker
npx skillsauth add jcsaaddupuy/badrobots strandagentsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Strands Agents is a lightweight, model-driven Python SDK for building AI agents. It scales from simple conversational assistants to complex autonomous workflows with support for multiple LLM providers, custom tools, multi-agent systems, and production deployment.
Use this skill when:
See references/quickstart.md for installation and basic usage.
from strands import Agent
from strands.models import OpenAIModel
# Create agent with OpenAI
model = OpenAIModel(
model_id="gpt-4o",
client_args={"api_key": "your-api-key"}
)
agent = Agent(model=model)
response = agent("Hello, world!")
The Agent class is the core component that orchestrates conversations with LLMs:
from strands import Agent
agent = Agent(
model=model, # LLM model provider
system_prompt="...", # System instructions
tools=[...], # Available tools
messages=[...], # Initial conversation history
state={...}, # Persistent state
hooks=[...], # Lifecycle hooks
conversation_manager=..., # Context window management
trace_attributes={...} # OpenTelemetry attributes
)
Strands supports multiple LLM providers:
OpenAIModel - See references/openai.mdAnthropicModelBedrockModel (default)GeminiModelOllamaModel (local)LiteLLMModel (100+ providers)Custom tools extend agent capabilities. See references/tools.md for complete guide.
from strands import Agent, tool
@tool
def get_weather(city: str) -> dict:
"""Get weather for a city."""
return {"status": "success", "content": [{"text": f"Sunny in {city}"}]}
agent = Agent(tools=[get_weather])
See references/openai.md for:
See references/tools.md for:
@tool decoratorSee references/security.md for:
See references/docker.md for:
See references/multi-agent.md for:
See references/observability.md for:
See references/testing.md for:
See references/mcp.md for:
See references/agentcore.md for:
BedrockAgentCoreApp@app.entrypoint decoratorRequestContext and session_id from headers/ping)# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install Strands
pip install strands-agents strands-agents-tools
# For development
hatch shell
pre-commit install -t pre-commit -t commit-msg
from strands import Agent
from strands.models import OpenAIModel
import os
# Configure model
model = OpenAIModel(
model_id="gpt-4o",
client_args={"api_key": os.environ.get("OPENAI_API_KEY")}
)
# Create agent
agent = Agent(
model=model,
system_prompt="You are a helpful assistant."
)
from strands import tool
@tool
def my_tool(param: str) -> dict:
"""Tool description for LLM.
Args:
param: Parameter description.
"""
return {"status": "success", "content": [{"text": f"Result: {param}"}]}
agent = Agent(model=model, tools=[my_tool])
# Run tests
hatch test
# With coverage
hatch test -c
# Integration tests
hatch run test-integ
See references/docker.md for production deployment.
from strands import Agent
from strands.models import OpenAIModel
model = OpenAIModel(model_id="gpt-4o")
agent = Agent(model=model, system_prompt="You are a helpful assistant.")
while True:
user_input = input("You: ")
if user_input.lower() == "exit":
break
response = agent(user_input)
print(f"Agent: {response}")
from strands import Agent, tool
from strands.models import OpenAIModel
@tool
def calculate(expression: str) -> dict:
"""Evaluate mathematical expression."""
result = eval(expression)
return {"status": "success", "content": [{"text": str(result)}]}
model = OpenAIModel(model_id="gpt-4o")
agent = Agent(model=model, tools=[calculate])
response = agent("What is 15 * 23?")
from strands import Agent
from strands.models import OpenAIModel
import asyncio
async def stream():
model = OpenAIModel(model_id="gpt-4o")
agent = Agent(model=model)
async for event in agent.stream_async("Tell me a story"):
if "data" in event:
print(event["data"], end="", flush=True)
asyncio.run(stream())
from strands import Agent, tool
from strands.models import OpenAIModel
# Create specialist
specialist = Agent(
model=OpenAIModel(model_id="gpt-4o"),
system_prompt="You are a research specialist."
)
# Wrap as tool
@tool
def research(query: str) -> dict:
"""Research a topic."""
result = specialist(query)
return {"status": "success", "content": [{"text": str(result)}]}
# Create coordinator
coordinator = Agent(
model=OpenAIModel(model_id="gpt-4o"),
tools=[research]
)
response = coordinator("Research AI trends")
echo $OPENAI_API_KEY.env file for local developmentresult.metricsimport os
import logging
from strands import Agent, tool
from strands.models import OpenAIModel
from strands.telemetry import StrandsTelemetry
from strands.hooks import HookProvider, HookRegistry, AfterInvocationEvent
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Setup telemetry
StrandsTelemetry().setup_console_exporter().setup_otlp_exporter()
# Metrics hook
class MetricsHooks(HookProvider):
def register_hooks(self, registry: HookRegistry, **kwargs) -> None:
registry.add_callback(AfterInvocationEvent, self.log_metrics)
def log_metrics(self, event: AfterInvocationEvent) -> None:
if event.result:
logger.info(
"tokens_in=<%d>, tokens_out=<%d>, latency_ms=<%d> | invocation completed",
event.result.metrics.input_tokens,
event.result.metrics.output_tokens,
event.result.metrics.total_time
)
# Custom tool
@tool
def process_data(data: str) -> dict:
"""Process data with validation."""
if not data or len(data) > 1000:
return {"status": "error", "content": [{"text": "Invalid data"}]}
# Process
result = data.upper()
return {"status": "success", "content": [{"text": result}]}
# Create production agent
def create_agent():
api_key = os.environ.get("OPENAI_API_KEY")
if not api_key:
raise ValueError("OPENAI_API_KEY not set")
model = OpenAIModel(
model_id="gpt-4o",
client_args={"api_key": api_key},
params={"temperature": 0.7, "max_tokens": 2048}
)
return Agent(
model=model,
tools=[process_data],
hooks=[MetricsHooks()],
trace_attributes={
"environment": "production",
"version": "1.0.0"
}
)
if __name__ == "__main__":
agent = create_agent()
response = agent("Process this data: hello world")
print(response)
This skill is based on Strands Agents SDK Python documentation (latest as of January 2026). Check the GitHub repository for updates.
development
DuckDB patterns for JSON/JSONL analysis, array unnesting, and common gotchas. Use when querying JSON files, nested data, or encountering "UNNEST not supported here" errors.
development
Mealie recipe manager API: recipes, shopping lists, meal plans. Requires MEALIE_BASE_URL and MEALIE_API_KEY.
business
TimeWarrior time tracking: start/stop intervals, query durations by tag or issue, compute totals for issue tracker time reporting
development
Bookmark manager for saving, searching, and annotating web content. Use when: (1) saving a webpage for later reference, (2) searching previously saved bookmarks, (3) adding highlights/annotations to saved content, (4) user asks to 'bookmark this' or 'save this article'. Requires READECK_BASE_URL and READECK_API_KEY environment variables.