Join our Newsletter — 33% off our NHI Course
Home› Guides› Lightweight Python Agent Frameworks: Haystack, Pydantic AI, smolagents…
Guide AI Platforms

Lightweight Python Agent Frameworks: Haystack, Pydantic AI, smolagents and Strands Compared

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 15 November 2026 13 min read
On this page

Haystack, Pydantic AI, smolagents and Strands Agents are four open source Python libraries for building AI agents that run inside your own code, without a hosted control plane, and teams choosing between them need the same facts for each. They come from deepset, Pydantic, Hugging Face and Amazon Web Services respectively, and each takes a different starting point: pipelines, typed agents, code-writing agents and a model-driven agent loop. This page sets the four side by side on identical fields: owner, licence, Python requirement, current version, model support, tools and MCP, multi-agent patterns, code execution, observability and commercial add-ons. It is written for developers and architects shortlisting a framework and for the people who approve open source dependencies. Every fact comes from each project's own repository, documentation or release page. Frameworks are listed alphabetically; order is never a ranking. Last checked: 2026-11-15.

This is an independent reference page from NHI Mgmt Group based on public provider documentation; it is not sponsored or endorsed by any provider.

Key takeaways

  • All four are permissively licensed. Haystack, smolagents and Strands Agents use Apache-2.0; Pydantic AI uses MIT.
  • Python floors differ. Haystack and Pydantic AI require Python 3.11 or later; smolagents and Strands Agents require 3.10 or later.
  • Each starts from a different core idea. Haystack builds on pipelines and components, Pydantic AI on a typed agent loop, smolagents on agents that write their actions as Python code, and Strands Agents on a model-driven loop with an assembled harness.
  • All four connect to MCP servers. Each documents an MCP client path, and Haystack and Strands Agents also document ways to expose agents or knowledge as MCP servers.
  • Support policies differ. Each project publishes its own version or security policy (major-version timelines, supported lines, backports), so pinning and upgrade planning matter as much as features.

What counts as a lightweight Python agent framework?

On this page the term means an open source Python library that you import into your own application to run an agent loop: the model call, tool execution, state and stopping rules. The library runs in your process and you choose where to host it. That separates these four from managed agent platforms, where the provider runs the agent for you, and from heavier stacks that bundle hosting and graph runtimes. The Agent Frameworks vs Managed Agent Platforms guide explains that split, and the AI Agent Frameworks and Platforms Hub (2026) lists the wider field.

How each project describes itself, in its own words:

  • Haystack: "an open-source AI orchestration framework for building production-ready LLM applications in Python", with "modular pipelines and agent workflows with explicit control over retrieval, routing, memory, and generation".
  • Pydantic AI: "the Python AI SDK: a typed, extensible agent loop with every model a string swap away".
  • smolagents: "a library that enables you to run powerful agents in a few lines of code", whose agent logic "fits in ~1,000 lines of code".
  • Strands Agents: "an open-source SDK for building and running AI agents in Python and TypeScript" for teams that "would otherwise write your own agent loop", running "in your process with no hosted control plane".

Key facts side by side

As of 15 November 2026, from each project's repository (README, LICENSE, pyproject) and release page.

FieldHaystackPydantic AIsmolagentsStrands Agents
MaintainerdeepsetPydantic Services Inc.Hugging FaceAmazon Web Services
Repositorydeepset-ai/haystackpydantic/pydantic-aihuggingface/smolagentsstrands-agents/harness-sdk (monorepo, strands-py/)
PyPI packagehaystack-aipydantic-ai (and pydantic-ai-slim)smolagentsstrands-agents (SDK); strands-harness (harness)
LicenceApache-2.0MITApache-2.0Apache-2.0
Python requirement3.11 or later3.11 or later3.10 or later3.10 or later
Other languagesPython onlyPython onlyPython onlyTypeScript SDK and harness in the same monorepo
Latest release seenv3.4.1, 21 October 2026 (marked Latest on GitHub); docs carry a 3.5 version and main branch reads 3.6.0-rc0v2.67.0, 10 November 2026v1.26.0 (marked Latest on GitHub); main branch reads 1.27.0.dev01.x line, which SECURITY.md lists as the supported version
Core abstractionPipeline of components; Agent componentAgent with typed output_type and capabilitiesCodeAgent and ToolCallingAgentAgent; create_harness()
PriceFree and open sourceFree and open sourceFree and open sourceFree and open source

Models and providers

None of the four ships a model. Each connects to providers through its own classes or prefixes. As of 15 November 2026:

FieldHaystackPydantic AIsmolagentsStrands Agents
How a model is chosenA chat generator component, such as OpenAIChatGenerator, passed as chat_generatorA string in the form <provider>:<model>A model class, such as InferenceClientModel, LiteLLMModel, OpenAIModel or TransformersModelA model class, such as BedrockModel, GeminiModel or OllamaModel
Providers named in the docsOpenAI, Mistral, Anthropic, Cohere, Hugging Face, Google, Azure OpenAI, AWS Bedrock, local models "and many others"A directory covering model developers, cloud platforms (Bedrock, Vertex AI, Azure, Snowflake and others), inference platforms and gatewaysHugging Face Inference Providers, local Transformers and Ollama models, and other APIs through LiteLLMBuilt-in Python providers including Amazon Bedrock, Anthropic, Cohere, Google, LiteLLM, llama.cpp, Mistral, Ollama, OpenAI, SageMaker and Writer, plus community providers
Default providerSet by the component you chooseSet by the model string you chooseInferenceClientModel() uses a default model when none is givenAmazon Bedrock
Self-hosted modelsLocal models via integrationsOllama, vLLM and any endpoint through OpenAICompatibleProviderTransformersModel, Ollama, OpenAI-compatible servers via api_baseOllama, llama.cpp; vLLM and SGLang as community providers
FailoverSwap components without rewriting the system (README)ModelFallback capability and FallbackModelSwitch model classSwap provider class

The Strands README notes that the default Bedrock provider needs AWS credentials and model access enabled in the chosen region.

Agents, tools and multi-agent patterns

Haystack

The Agent component takes a chat_generator, tools, a system_prompt and a state_schema whose typed keys tools share and that come back in the result alongside messages and last_message. Tools can wrap pipeline components with ComponentTool. The README lists lifecycle hooks (before_llm, before_tool, on_exit), counters for step_count and token_usage, concurrent tool calls, SkillToolset for progressive skill discovery and ready-made agents in Agent Pack. Multi-step and multi-agent designs are built as pipelines with loops, branches and conditional routing.

Pydantic AI

An Agent is defined with a model string and an output_type, so every run returns a validated, typed result. Tools are functions registered with @agent.tool that receive a RunContext carrying dependencies; arguments are validated before your code runs. The Pydantic AI Harness adds capabilities such as memory, guardrails, sub-agents, planning, context compaction and a complete coding agent (Coder). Pydantic Graph, a separate package, gives typed control flow when one agent loop is not enough, and durable execution is available through Temporal, DBOS and Prefect extras.

smolagents

CodeAgent writes its actions as Python code, so tool calls become Python function calls with loops and conditionals; ToolCallingAgent uses standard JSON or text tool calling. Tools can come from an MCP server (ToolCollection.from_mcp), from LangChain (Tool.from_langchain) or from a Hugging Face Space (Tool.from_space), and agents and tools can be pushed to and pulled from the Hub. The README states that multi-agent hierarchies are supported, and the documentation includes a multi-agent orchestration example.

Strands Agents

An Agent takes tools defined with the @tool decorator, and load_tools_from_directory=True watches a ./tools/ directory and reloads tools as files change. The README lists lifecycle controls (turn limits, token budgets, cancellation, stop reasons), structured output, multi-agent patterns, memory and sessions, streaming, guardrails, hooks that intercept any step, and steering handlers. The harness package, started with create_harness(), assembles model, tools, memory, sessions and context management with preset defaults.

FieldHaystackPydantic AIsmolagentsStrands Agents
Tool definitionTool objects; ComponentTool wraps components@agent.tool with RunContextTool classes and functions@tool decorator
Structured outputTyped state_schema keysoutput_type (Pydantic models)Python return values from code actionsStructured output (README)
MCP clientMCPTool, MCPToolsetmcp extraToolCollection.from_mcpMCPClient; works with mcp 1.x and 2.x
Expose as a serverHayhooks: REST, MCP and OpenAI-compatible endpointsWeb, CLI and AG-UI interfaces (ui, ag-ui, web, cli extras)Push to the Hugging Face Hub as a Spacea2a extra; separate MCP server for coding agents
AsyncOne Pipeline runs sync or asyncrun() and run_sync()run(), with stream_outputs=True for streamingStreaming built in

Code execution and sandboxing

Agents that run model-written code or shell commands need an execution boundary. Each project documents its own options:

  • Haystack: agents act through tools and pipeline components that you supply; the Agent page describes intercepting tool calls for human review before they run, with details on the Human in the Loop page.
  • Pydantic AI: the Harness offers workspace-rooted file access and an allowlisted shell, and Pydantic publishes Monty, a separate open source sandboxed Python interpreter for model-written code.
  • smolagents: code can run in sandboxed environments via Blaxel, E2B, Modal or Docker. The README states that the built-in LocalPythonExecutor "is not a security sandbox" and must not be used to run untrusted code.
  • Strands Agents: the organisation publishes separate Box and Shell projects alongside the SDK, and the README lists guardrails that "catch mistakes before they run".

The AI Agent Sandboxing and Code Execution Guide covers how to choose an isolation boundary for any of them.

Observability and telemetry

FieldHaystackPydantic AIsmolagentsStrands Agents
Tracing standardPipelines and agents described as "transparent and traceable"OpenTelemetry instrumentation; works with any OTel backendOpenTelemetry through the OpenInference SmolagentsInstrumentorObservability APIs built into the SDK; docs recommend OpenTelemetry
InstallCore packagelogfire extra for Pydantic Logfiretelemetry extraotel extra
Default behaviourAnonymous usage statistics on component initialisation; opt out with HAYSTACK_TELEMETRY_ENABLED=FalsePlain OpenTelemetry instrumentation, per the READMEOpt-in: tracing starts when you run the instrumentorThe README says the agent loop "traces every decision by default"
Backends namedNot stated on the telemetry pagePydantic Logfire or any OTel backendArize Phoenix, Langfuse, MLflowOpenTelemetry collectors

Haystack's telemetry page says events carry an anonymous ID, environment details and, for pipelines with an Agent, the chat generator type, model and tool names, and exclude IP addresses, hostnames, file paths, queries and document contents. For what span attributes mean, see OpenTelemetry GenAI Semantic Conventions for Security Teams.

Commercial products around each framework

The libraries are free. Each maintainer also describes paid or hosted products, listed here as each project describes them; prices are not stated on the pages checked.

  • Haystack: Haystack Enterprise Starter (support, templates and deployment guides) and Haystack Enterprise Platform, offered as a managed cloud service or self-hosted, with a free trial.
  • Pydantic AI: Pydantic Logfire, described as an AI engineering platform, and the Pydantic AI Gateway, "one key for every model with real-time cost monitoring and budget control".
  • smolagents: Hugging Face Inference Providers, reached through InferenceClientModel, and Hub hosting for shared agents and tools.
  • Strands Agents: the README states the SDK runs "in your process with no hosted control plane"; Amazon Bedrock is the default model provider.

Versions and support policy

  • Haystack: the 3.x line, with release candidates before each minor release (3.2.0 on 24 September, 3.3.0 on 1 October, 3.4.0 on 15 October and 3.4.1 on 21 October 2026, as shown on GitHub). Nightly pre-releases install with pip install --pre haystack-ai.
  • Pydantic AI: V1 was released in September 2025 and V2.0 became stable on 23 June 2026. The version policy says Pydantic "will not intentionally make breaking changes in minor releases", that V1 receives security fixes for at least six months after V2's stable release, and that the next major version will not ship sooner than three months after V2.0. A V1 maintenance release (v1.107.10) appeared on 4 November 2026.
  • smolagents: the 1.x line; the security policy states that fixes ship in the latest release and are not backported to older releases.
  • Strands Agents: SECURITY.md lists 1.x.x as supported and versions below 1.0 as unsupported. Python SDK versions are set from git tags.

How to choose: factual criteria

These criteria come from the documented differences above. They describe fit, not quality.

If your requirement isCheck this in each framework
Python 3.10 supportsmolagents and Strands Agents state 3.10 or later; Haystack and Pydantic AI state 3.11 or later
A TypeScript version of the same frameworkStrands Agents publishes Python and TypeScript SDKs; Haystack, Pydantic AI and smolagents are Python libraries
Retrieval-heavy pipelinesHaystack's pipeline and component model; the other three connect retrieval through tools
Typed, validated outputsPydantic AI's output_type; equivalent patterns in each framework's structured output docs
Agents that act by writing codesmolagents' CodeAgent and its sandbox executors
A preset harness to start fromPydantic AI Harness (Coder), Strands harness (create_harness()), Haystack Agent Pack
Licence compatibilityMIT (Pydantic AI) or Apache-2.0 (Haystack, smolagents, Strands Agents); check against your open source policy
Upgrade stabilityEach project's version policy and release cadence; pin versions in all cases

For a TypeScript shortlist, see TypeScript Agent Frameworks Compared; for a multi-agent framework with its own history, see What Is AG2? The Community Fork of AutoGen; for managed options, see AI Agent Platforms Compared.

Security guidance

This page compares what the frameworks are. Framework-specific hardening is covered in the Pydantic AI Security Guide and the AWS Strands Agents SDK Security Guide, and the discipline as a whole in the Securing Agent Frameworks Guide. The common customer-side controls are the same for all four: give each agent only the tools and credentials it needs, keep provider keys out of code, run model-written code and shell commands in an isolated environment rather than the host, require human approval for irreversible actions, filter the tools exposed from each MCP server (see the MCP Security Guide), decide deliberately what trace content reaches your observability backend, and apply each project's security updates promptly.

Practitioner checklist

  • Confirm the Python version in your runtime against each framework's floor (3.11 for Haystack and Pydantic AI, 3.10 for smolagents and Strands Agents).
  • Record the licence (Apache-2.0 or MIT) in your open source register before adoption.
  • Pin exact versions in lock files and read release notes before each upgrade.
  • Decide on the code execution boundary before enabling any code or shell tool, and never treat a local executor as a sandbox.
  • Set telemetry deliberately: opt out of Haystack usage statistics where policy requires, and configure tracing exporters and content capture for the others.
  • Filter MCP tools per server and review each server as a dependency.
  • Check the default model provider (Bedrock for Strands Agents, Hugging Face inference for smolagents' default model) so traffic goes where you expect.
  • Map each framework's support policy (backports, major version timelines) to your patching cycle.

Standards and references

Related NHI Mgmt Group resources: AI Agent Frameworks and Platforms Hub (2026) · AI Agent Platforms Compared · Securing Agent Frameworks Guide · Agent Frameworks vs Managed Agent Platforms

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 15 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.