How strands-agents/harness-sdk works
Repository Scope and Entry Points
Strands Agents is a monorepo for model-driven AI-agent SDKs in Python and TypeScript, plus an MCP documentation server, developer CLI, documentation site, and AWS-backed integration-test infrastructure. Public SDK entry points are strands-py/src/strands/__init__.py and strands-ts/src/index.ts (with Node-specific exports in strands-ts/src/index.node.ts). The central invocation APIs are strands-py/src/strands/agent/agent.py and strands-ts/src/agent/agent.ts.
Agent Execution Core
Each SDK centers on an Agent that owns prompt/conversation state, a model, tools, and lifecycle controls. Agent invocation drives an iterative model/tool loop, producing results and streamed events. Python orchestration is split between strands-py/src/strands/agent/agent.py, strands-py/src/strands/event_loop/event_loop.py, and strands-py/src/strands/event_loop/streaming.py; TypeScript consolidates core invocation in strands-ts/src/agent/agent.ts with tool dispatch in strands-ts/src/agent/tool-caller.ts.
Model Provider Boundary
A shared model abstraction isolates agent logic from LLM transports, schemas, streaming, retries, and provider-specific error behavior. Python implementations include Bedrock, Anthropic, Gemini, OpenAI, and local/aggregator providers under strands-py/src/strands/models/model.py, strands-py/src/strands/models/bedrock.py, and strands-py/src/strands/models/openai.py. TypeScript counterparts are strands-ts/src/models/model.ts, strands-ts/src/models/bedrock.ts, and strands-ts/src/models/openai/model.ts. Amazon Bedrock is the default; external services include AWS, Anthropic, OpenAI, Google, and others through adapters.
Tools, MCP, and Execution Safety
Models select registered tool schemas; executors validate and invoke them sequentially or concurrently, returning results to the loop. Core Python paths are strands-py/src/strands/tools/registry.py, strands-py/src/strands/tools/executors/concurrent.py, and strands-py/src/strands/tools/mcp/mcp_client.py; TypeScript paths are strands-ts/src/registry/tool-registry.ts, strands-ts/src/tools/executors/concurrent.ts, and strands-ts/src/mcp/client.ts. Sandboxes separate tool execution from host environments using local POSIX, Docker, or SSH implementations: strands-py/src/strands/sandbox/docker.py and strands-ts/src/sandbox/docker.ts.
Extensibility, Control, and State
Hooks, middleware, plugins, and interventions provide interception boundaries around agent/model/tool stages for logging, authorization, human approval, steering, and cancellation. Key paths are strands-py/src/strands/_middleware/stages.py, strands-py/src/strands/interventions/registry.py, strands-ts/src/middleware/stages.ts, and strands-ts/src/interventions/handler.ts. Conversation/context managers constrain token growth, while session, storage, and memory layers persist or retrieve state; e.g., strands-py/src/strands/agent/conversation_manager/conversation_manager.py, strands-py/src/strands/memory/memory_manager.py, strands-ts/src/session/session-manager.ts, and strands-ts/src/storage/s3-storage.ts. Durable integrations include filesystem and Amazon S3; Bedrock Knowledge Bases are vended memory stores.
Multi-Agent, Observability, and Streaming
Agents can compose as tools or execute through graph, swarm, and Agent-to-Agent (A2A) protocols. Primary implementations are strands-py/src/strands/multiagent/graph.py, strands-py/src/strands/multiagent/a2a/server.py, strands-ts/src/multiagent/graph.ts, and strands-ts/src/a2a/express-server.ts. Telemetry traces and metrics agent decisions and operations through strands-py/src/strands/telemetry/tracer.py and strands-ts/src/telemetry/tracer.ts. Python additionally exposes experimental bidirectional text/audio agents for Gemini Live, Nova Sonic, and OpenAI Realtime under strands-py/src/strands/experimental/bidi/agent/agent.py.
Supporting Products and Delivery
strands-mcp/src/strands_mcp_server/__main__.py starts a Python MCP server that fetches, processes, indexes, caches, and serves project documentation. strandly/src/cli.ts is the workspace developer CLI. The Astro documentation application is rooted at site/src/pages/index.astro, content is defined in site/src/content.config.ts, and custom rendering/routing resides in site/src/route-middleware.ts. GitHub Actions package, test, release, and deploy the SDKs and site; AWS CDK integration-test resources are defined by test-infra/bin/test-infra.ts and test-infra/lib/stacks/test-infra-stack.ts.
Main entry points: agent.py Agent · event_loop.py Event loop · agent.ts Agent & tool caller · __init__.py Python public SDK
Components 22
Python SDK
- Python public SDK
strands-py/src/strands/__init__.py - Agent · Owns conversation, model, tools, and lifecycle.
strands-py/src/strands/agent/agent.py - Event loop · Runs the iterative model and tool loop.
strands-py/src/strands/event_loop/event_loop.py - Streaming
strands-py/src/strands/event_loop/streaming.py - Model abstraction · Normalizes transports, schemas, retries, and streaming.
strands-py/src/strands/models/model.py - Bedrock adapter · Default Amazon Bedrock integration.
strands-py/src/strands/models/bedrock.py - Tool registry & executor · Validates and concurrently invokes selected tools.
strands-py/src/strands/tools/executors/concurrent.py - MCP client
strands-py/src/strands/tools/mcp/mcp_client.py - Middleware & interventions · Intercepts stages for approval, steering, and cancellation.
strands-py/src/strands/_middleware/stages.py - Conversation & memory · Constrains context and retrieves or persists memory.
strands-py/src/strands/memory/memory_manager.py - Multi-agent graph
strands-py/src/strands/multiagent/graph.py - Telemetry
strands-py/src/strands/telemetry/tracer.py
TypeScript SDK
- TypeScript public SDK · Also has Node-specific exports.
strands-ts/src/index.ts - Agent & tool caller · Consolidates invocation and tool dispatch.
strands-ts/src/agent/agent.ts - Model abstraction
strands-ts/src/models/model.ts - Tool registry & executor
strands-ts/src/tools/executors/concurrent.ts - Session & S3 storage
strands-ts/src/storage/s3-storage.ts
Supporting products
- Documentation MCP server · Indexes, caches, and serves project documentation.
strands-mcp/src/strands_mcp_server/__main__.py - Strandly CLI
strandly/src/cli.ts - Documentation site
site/src/pages/index.astro
Delivery
- GitHub Actions · Packages, tests, releases, and deploys SDKs and site.
- AWS test infrastructure · Integration-test resources.
test-infra/lib/stacks/test-infra-stack.ts
Connections 21
- Python public SDK → Agent: exports
- Agent → Event loop: invokes
- Agent → Conversation & memory: manages context
- Agent → Middleware & interventions: runs through
- Event loop → Model abstraction: calls model
- Event loop → Tool registry & executor: dispatches tools
- Event loop → Streaming: emits events
- Model abstraction → Bedrock adapter: implements
- Tool registry & executor → MCP client: uses remote tools
- Agent → Multi-agent graph: composes agents
- Agent → Telemetry: traces
- TypeScript public SDK → Agent & tool caller: exports
- Agent & tool caller → Model abstraction: calls model
- Agent & tool caller → Tool registry & executor: dispatches tools
- Agent & tool caller → Session & S3 storage: persists state
- MCP client → Documentation MCP server: connects
- Strandly CLI → Python public SDK: supports development
- GitHub Actions → Python public SDK: packages and releases
- GitHub Actions → TypeScript public SDK: packages and releases
- GitHub Actions → Documentation site: deploys
- GitHub Actions → AWS test infrastructure: runs integration tests