Strands Agents SDK

repository·main·Indexed 27 days ago

https://github.com/strands-agents/harness-sdk

A model-driven SDK for building and running AI agents with high control, available for Python (3.10+) and TypeScript (Node.js 20+). It provides a unified interface for providers including Amazon Bedrock, Anthropic, OpenAI, and Gemini. Features include support for MCP, multi-agent workflows, structured output, bidirectional streaming for real-time audio, and a middleware system for intercepting execution stages. Includes a dedicated MCP server for curated documentation access via search_docs and fetch_doc tools.

Tokens
362.3K
Snippets
872
Records
1.5K
Agent score
92%

What's inside Strands Agents

  1. Overview of strands-evals subcommands

    main

    The strands-evals CLI exposes five primary subcommands:

    CommandPurpose
    strands-evals runExecute an Experiment against an --agent factory or --task callable, or run a single ad-hoc case via --input + --evaluator/--expected-output/--rubric.
    strands-evals validateSchema-check a serialized Experiment JSON file. Useful as a CI gate before run.
    strands-evals reportRender an existing EvaluationReport JSON via Rich, or dump it as JSON.
    strands-evals diagnoseRun detect_failures, analyze_root_cause, or the full diagnose_session pipeline on a Session JSON file.
    strands-evals generateSynthesize an Experiment via ExperimentGenerator from a free-form --context or an existing --experiment file.
  2. Overview of Red-Teaming Attack Strategies

    main

    The strands_evals.experimental.redteam module provides several AttackStrategy implementations to drive adversarial conversations against a target. Strategies are categorized into two types:

    1. Attacker LLM-driven: These use a second model to adaptively write adversarial prompts turn-by-turn (e.g., CrescendoStrategy, GoatStrategy, PairStrategy).
    2. Scripted: These use fixed templates and do not require a second model, making them cheaper and deterministic (e.g., BadLikertJudgeStrategy, SequentialBreakStrategy).

    Note: All strategies are currently experimental and reside in strands_evals.experimental.redteam.

  3. Overview of Strands Shell

    main

    Strands Shell is an in-process, Bourne-compatible virtual shell designed for agents to execute commands (like grep, sed, jq, curl, and find) with extremely low latency (under 1ms). Unlike Docker or cloud sandboxes, it provides isolation via an in-process Virtual Filesystem (VFS) and a mediation Kernel rather than OS-level primitives. This makes it ideal for high-frequency command loops where container cold starts are prohibitive.

    Key Characteristics:

    • Isolation: Uses an in-memory VFS and a mediation layer (Kernel) instead of namespaces or MicroVMs.
    • Performance: Construction and command execution cost under 1ms.
    • Platforms: Supports macOS, Linux, and WASM.
    • Interfaces: Accessible via MCP server, Python API, or Node.js API.
  4. Key features of strands-perplexity

    main

    The strands-perplexity tool provides the following capabilities:

    • Real-time Web Search: Access ranked web search results from Perplexity's continuously refreshed index.
    • Citations Included: Every result includes URLs for proper attribution.
    • Regional Search: Filter results by country using ISO country codes.
    • Language Filtering: Filter results by language using ISO 639-1 codes.
    • Domain Filtering: Include or exclude specific domains from results.
    • Multi-query Support: Execute up to 5 related queries in a single request.
  5. Core concepts of Strands Evals: Cases, Experiments, and Evaluators

    main

    Strands Evals uses three foundational concepts to structure agent evaluation:

    1. Case: The atomic unit of evaluation representing a single test scenario. It contains the input (e.g., a user query), optional expected outputs, expected tool sequences (trajectories), and metadata.
    2. Experiment: A test suite that bundles multiple Case objects with one or more Evaluators. It orchestrates the process of running the agent and scoring the results.
    3. Evaluator: The judge that examines the agent's output and trajectory. Most evaluators are LLM-based, allowing for nuanced judgment on qualities like helpfulness or coherence rather than simple string matching.
    from strands_evals import Case
    
    case = Case(
        name="Weather Query",
        input="What is the weather like in Tokyo?",
        expected_output="Should include temperature and conditions",
        expected_trajectory=["weather_api"]
    )
  6. Understand the Graph Multi-Agent Pattern

    main

    The Graph pattern is a deterministic directed graph orchestration system. It allows you to organize agents, custom nodes, or other multi-agent systems (like Swarm or nested Graph instances) into a structured workflow.

    Key Features:

    • Deterministic execution: Order is determined by the graph structure and edge dependencies.
    • Output propagation: Data from one node is passed as input to connected nodes.
    • Topology support: Supports both Directed Acyclic Graphs (DAG) and cyclic topologies (for feedback loops).
    • Nested patterns: A Graph can be used as a node within another Graph.
    • Conditional traversal: Supports dynamic workflows via conditional edges.
    • Distributed workflows: Supports remote agents via A2AAgent.
  7. Understand Observability in Strands Agents

    main

    Observability in the Strands Agents SDK is used to measure system behavior and performance through instrumentation, data collection, and analysis. It is designed to help developers debug agent behavior and measure production performance by capturing both standard application telemetry and AI-specific signals.

    Key telemetry primitives include:

    • Traces: Represent end-to-end requests. They consist of spans representing intermediate steps like model and tool invocations. Spans can be enriched with context such as system prompts, model parameters (temperature, top_p, top_k, max_tokens), token usage, and tool inputs/outputs.
    • Metrics: Measurements of events. Essential metrics include:
      • Agent Metrics: Tool invocation counts, execution time, error rates, latency (TTFB/TTLB), and agent loop counts.
      • Model Metrics: Token usage, model latency, and API errors/rate limits.
      • System Metrics: CPU/Memory utilization and availability.
      • Customer Metrics: Feedback (thumbs up/down), interaction length, and active user counts.
    • Logs: Structured or unstructured text records emitted at specific timestamps for debugging.
  8. Core Concepts of Strands Agents

    main

    Strands Agents uses a model-driven approach to build AI agents by combining three core components:

    1. Model: Supports various providers including Amazon Bedrock (for tool use and streaming), Anthropic (Claude family), Llama API, Ollama (for local development), and others via LiteLLM (e.g., OpenAI). You can also define custom model providers.
    2. Tools: Agents can use Model Context Protocol (MCP) servers, Strands' 20+ pre-built tools (file manipulation, API requests, AWS interactions), or any Python function decorated with @tool.
    3. Prompt: A natural language prompt defining the task, often supplemented by a system prompt to provide general instructions and desired behavior.

    The agent operates in an agentic loop: Strands invokes the LLM with the prompt, context, and tool descriptions. The LLM can respond in natural language, plan steps, reflect, or select tools. When a tool is selected, Strands executes it and returns the result to the LLM until the task is complete.

  9. Understand the Strands SDK Versioning Policy

    main

    The Strands SDK follows Semantic Versioning (SemVer) to manage updates and breaking changes:

    • Major (X.0.0): Includes breaking changes, feature removals, or API changes that require user action to fix.
    • Minor (1.Y.0): Includes new features, backward-compatible additions, deprecation warnings, and "pay for play" breaking changes.
    • Patch (1.1.Z): Includes bug fixes, security patches, and documentation updates.

    Support Policy: Major versions are supported for at least 6 months after the release of the next major version. Support includes bug fixes and security patches, but new features are not back-ported to previous major versions.

  10. Understand Agent SOPs (Standard Operating Procedures)

    main

    Agent SOPs are a standardized markdown format designed to define AI agent workflows using natural language. They serve as a middle ground between rigid, code-defined state machines and fully autonomous, model-driven agents.

    Key features of the SOP format include:

    • Structured steps with RFC 2119 constraints: Uses keywords like MUST, SHOULD, and MAY to provide precise control over agent behavior while preserving reasoning capabilities.
    • Parameterized inputs: Supports parameters instead of hardcoded values, allowing SOPs to function as flexible templates for different projects or requirements.
    • AI-assisted authoring: The format is designed so that coding agents can read the specification and generate new workflows from natural language descriptions.
    • Progress tracking and resumability: Enables agents to document their progress, which aids in debugging and allows workflows to be resumed if interrupted.
  11. Consolidate Strands SDK Repos into a Mono Repository

    main

    The Strands Agents project is transitioning from multiple separate repositories to a single mono repository to improve development velocity. This consolidation aims to reduce context switching for developers and agents, unify documentation with code, and simplify cross-language feature parity (Python and TypeScript).

    Repositories included in the Monorepo:

    • sdk-python (core SDK)
    • sdk-typescript (core SDK)
    • docs (documentation site)
    • samples (usage examples)
    • mcp-server (Model Context Protocol server)
    • devtools (parts of development tooling)

    Repositories remaining independent:

    • evals (evaluations)
    • agent-builder (agent construction)
    • agent-sop (Standard Operating Procedures)
    • tools (standalone tools)
    • .github and extension-template-python (org-level config/templates)