Articles

How to build an AI agent: the best tools to use in 2026

25 July 2026Braintrust Team13 min
TL;DR

Building a custom AI agent requires teams to manage planning, tool calls, state, memory, retries, and multi-step execution. Choosing the wrong framework can leave developers maintaining orchestration code and debugging failures across long agent runs.

Agent frameworks organize those responsibilities through state graphs, role-based coordination, lightweight SDKs, typed Python runtimes, or TypeScript-native workflows. The right option depends on the control the agent requires, the complexity of its tasks, and the language the team already uses in production.

This guide compares five tools for building agents in code and explains where each works best. Braintrust adds tracing, evaluation, and release control across all covered frameworks, allowing teams to test agent behavior before deployment and continue measuring it in production. Start free with Braintrust.


What it takes to build an AI agent

An AI agent uses a language model to complete a task across multiple steps. It can decide what to do next, call tools such as APIs and databases, carry context from earlier actions, and continue until it reaches an outcome. A support agent might retrieve an order, check the refund policy, and draft a response in one run. A research agent might search the web, review several sources, and produce a summary.

Building an agent from scratch requires developers to manage the model loop, tool execution, state, memory, retries, and error handling. Agent frameworks provide these components so teams can focus on the agent's task logic, permissions, and access to company data.

The tools in this guide follow four common framework styles:

  • Step-by-step control: Developers define the agent as a graph of actions and specify how it moves between them. LangGraph is the main option in this category.
  • Role-based teams: Developers assign distinct roles, such as researcher, writer, and reviewer, and coordinate their work across a shared task. CrewAI follows this structure.
  • Lightweight SDKs: Smaller libraries provide the core agent loop, tool calling, and delegation features without requiring a larger orchestration framework. The OpenAI Agents SDK and Pydantic AI fit this category.
  • TypeScript-native frameworks: These tools provide agent and workflow primitives for teams building primarily in JavaScript or TypeScript. Mastra is the main example covered here.

5 tools to build AI agents in 2026

1. LangGraph: step-by-step control for complex agents

LangGraph graph-based agent orchestration

What it is: Developed by the LangChain team, LangGraph is a low-level orchestration runtime for long-running, stateful agents. Developers represent execution as a graph of nodes and transitions, while checkpointers persist state between steps.

Known for: The runtime supports durable execution, branching, streaming, short-term and long-term memory, and human approval during a run. Persisted state also allows an interrupted agent to resume without restarting the complete workflow.

Commonly used for: Agents with branching logic, retries, long-running tasks, human review, or multiple participants whose execution order must remain explicit.

Worth noting: Prompts and agent architecture remain under the development team's control. That flexibility requires more orchestration design and configuration than frameworks that offer predefined agent patterns do.

Testing and monitoring: Braintrust traces LangGraph through the LangChain callback system, capturing graph execution, node transitions, and model calls in Python and TypeScript.

2. CrewAI: role-based multi-agent teams

CrewAI role-based agent crews

What it is: CrewAI is a Python framework for coordinating agents that have defined roles, goals, tools, and assigned tasks. Crews manage collaboration between agents, while Flows provide stateful, event-driven control for workflows that combine application code and crews.

Known for: The role-and-task structure makes specialist responsibilities explicit. A crew can assign research, analysis, writing, or review work to separate agents and coordinate how their outputs contribute to the final result.

Commonly used for: CrewAI suits workflows that naturally divide among specialist agents, including research pipelines, report generation, and internal business processes.

Worth noting: Crews handle agent collaboration, while explicit branching, state management, and event-based routing are handled through Flows. Applications that require both coordination forms must specify how the crew and flow layers interact.

Testing and monitoring: Braintrust records a CrewAI run as a nested trace that includes crew kickoff, task execution, agent reasoning, model calls, and tool usage.

3. OpenAI Agents SDK: a lightweight agent loop for OpenAI-first teams

OpenAI Agents SDK primitives

What it is: Available for Python and TypeScript, the OpenAI Agents SDK uses a small set of primitives for agent development. Agents combine models, instructions, and tools, while runners manage model turns, tool execution, handoffs, guardrails, sessions, and completion.

Known for: Teams can build single-agent and multi-agent applications from a handful of primitives, with no separate orchestration layer to configure. The SDK also includes persistent sessions, human approval, MCP support, structured outputs, and built-in tracing.

Commonly used for: OpenAI-centered applications, including setups where a coordinating agent delegates work to specialists through handoffs or exposes other agents as tools.

Worth noting: Non-OpenAI models can be connected, but hosted capabilities such as OpenAI web search and file search require compatible OpenAI models.

Testing and monitoring: Braintrust instruments the OpenAI Agents SDK, combining agent runs, tool calls, guardrails, nested model calls, and final outputs into a single trace.

4. Pydantic AI: type-safe agent building in Python

Pydantic AI typed agent framework

What it is: Pydantic AI is a Python framework from the team behind Pydantic. It applies Python type hints and Pydantic validation to agent dependencies, tool inputs, and structured outputs.

Known for: Model responses can be validated against declared schemas before another service, database, or workflow receives them. Request, token, and tool-call limits can also be applied to individual runs.

Commonly used for: Python services where agent outputs must conform to application types and validation requirements.

Worth noting: Multi-agent applications are supported through agent delegation, application-controlled handoffs, and Pydantic Graph. Development teams still need to select and define the coordination pattern used by the application.

Testing and monitoring: Pydantic AI emits OpenTelemetry instrumentation, and Braintrust captures agent runs, underlying model calls, and tool calls for tracing and evaluation.

5. Mastra: a TypeScript-native agent framework

Mastra TypeScript agent framework

What it is: For teams working primarily in TypeScript, Mastra provides agents, tools, workflows, and memory within one framework. Its workflow engine supports conditional branches, parallel steps, loops, and suspended runs that can resume later.

Known for: Both model-directed agent loops and explicitly defined workflows can remain in the same language as a Node.js or full-stack TypeScript application. Mastra also supports multiple model providers and several memory configurations.

Commonly used for: Products where the agent, API, workflow logic, and shared application types are all maintained in TypeScript.

Worth noting: Persistent memory and durable workflow state depend on a configured storage adapter, which must be selected and managed as part of the production architecture.

Testing and monitoring: Mastra's observability integration with Braintrust can automatically capture agent execution, model calls, and tool usage.

Other AI agent frameworks worth knowing

Several additional frameworks deserve consideration for teams working in Microsoft, AWS, Alibaba, or Google environments. Braintrust provides tracing integrations for each option, although the supported integration language varies by framework.

Microsoft Agent Framework: Created as the successor to AutoGen and Semantic Kernel, Microsoft Agent Framework supports Python and .NET. It combines agent abstractions with session state, middleware, telemetry, typed interfaces, and graph-based workflows for explicit multi-agent execution. Braintrust adds tracing for the .NET framework, including agent invocations, model calls, and tools.

Strands Agents SDK: Started by AWS, Strands is an open-source framework available for Python and TypeScript. Its model-directed agent loop can be extended with graphs, swarms, workflows, agents used as tools, session management, and OpenTelemetry instrumentation. Amazon Bedrock is the default provider, although other model providers are supported. Braintrust adds end-to-end tracing for the TypeScript SDK.

AgentScope: Alibaba's open-source AgentScope framework focuses on developing and operating multi-agent applications. Its Python implementation includes asynchronous agents, parallel tool calls, state management, concurrent pipelines, and real-time interruption of agents and tools. Braintrust supports tracing for AgentScope 1.x and 2.x.

Google ADK: Google's Agent Development Kit supports single-agent, multi-agent, and graph-based applications across Python, TypeScript, Go, Java, and Kotlin. It integrates closely with Gemini and Google Cloud services while retaining support for other model providers. Braintrust adds tracing for TypeScript applications, including tool calls and multi-step execution.

Best tools to build AI agents in 2026

The table below shows how the five frameworks differ across execution control, multi-agent coordination, provider support, language compatibility, validation, and testing. Every framework can send agent traces to Braintrust.

CapabilityLangGraphCrewAIOpenAI Agents SDKPydantic AIMastra
Graph or state control✅ Core graph design with checkpointed state✅ Flows manage state, routing, persistence, and resumption⚠️ Sessions and resumable run state, but no graph API✅ Pydantic Graph supports graph-based state machines✅ Stateful workflows support branching, parallel steps, and resumption
Role-based teams⚠️ Multi-agent coordination requires custom graphs, subgraphs, or handoffs✅ Roles, tasks, and crews are central to the framework⚠️ Supports handoffs and agents used as tools, without a dedicated role abstraction⚠️ Supports agent delegation, programmatic handoffs, and graph-based coordination⚠️ Supervisor agents coordinate registered subagents
Provider dependenciesNone; model-agnostic through LangChain integrationsNone; supports multiple model providers and custom LLM implementationsOpenAI-native, with adapters and custom providers available for other modelsNone; model-agnostic with built-in support for multiple providersNone; its model router supports models from multiple providers
TypeScript support✅ Python and TypeScript❌ Python only✅ Python and TypeScript❌ Python only✅ TypeScript-native
Type safety and validation⚠️ Typed state schemas, with runtime validation through Pydantic or standard schemas such as Zod⚠️ Pydantic or JSON task outputs, plus task guardrails⚠️ Typed structured outputs and input, output, and tool guardrails✅ Typed dependencies, tool inputs, and validated outputs are central to the framework✅ TypeScript types with Zod, JSON Schema, or other supported schema libraries
How it is testedBraintrust tracing through LangChain callbacks, followed by Braintrust evalsBraintrust nested tracing for crews, tasks, agents, and tools, followed by Braintrust evalsBraintrust trace processor for agent runs, handoffs, guardrails, and tools, followed by Braintrust evalsBraintrust tracing for agent, model, and tool calls, followed by Braintrust evalsBraintrust observability exporter for agents, workflows, steps, models, and tools, followed by Braintrust evals

Matching AI agent tools to use cases

Selecting an agent framework starts with the application's execution pattern and the language the team already uses. Use the categories below to narrow the shortlist.

Complex production agents: When execution must branch, pause, resume, or pass through human approval, LangGraph provides explicit control over state and transitions. Checkpointing preserves progress across interrupted runs and supports long-running workflows with multiple decision paths.

Role-based multi-agent workflows: CrewAI works well when a task can be cleanly divided among specialists responsible for research, analysis, writing, or review. Crews coordinate agents and assigned tasks, while Flows add stateful, event-driven control around crew execution.

OpenAI-centered stacks: Teams already using OpenAI models can keep agent orchestration compact with the OpenAI Agents SDK. Its runtime manages turns, tools, guardrails, sessions, and handoffs through a small set of primitives.

Typed Python services: Pydantic AI is suited to applications where model output must satisfy declared Python types before entering an API, database, or downstream service. Structured outputs are validated with Pydantic, so schema errors surface before invalid data continues through the application.

TypeScript products: Mastra keeps agents, tools, memory, and structured workflows in TypeScript, which works well for Node.js and full-stack teams maintaining shared types across the agent and the wider product. Teams centered on .NET can also evaluate Microsoft Agent Framework.

Framework selection determines how an agent executes, but teams still need a consistent process for measuring whether the agent completed the task correctly. Braintrust has integrations for all five frameworks, capturing agent runs, model calls, tool activity, guardrails, and workflow steps in traces that teams can inspect and evaluate. Production traces can also be added to versioned datasets, keeping evaluation cases connected to failures and edge cases observed in real use.

Teams can run repeatable evaluations in CI/CD before release, compare results against established baselines, and apply online scoring after deployment. Pass/fail thresholds allow evaluation results to become release requirements, while production scoring continues checking quality as new requests reach the agent.

Start free with Braintrust to trace, evaluate, and gate agent releases.

FAQs: Best tools to build AI agents in 2026

Do I need to code to build an AI agent, or can I use a no-code builder?

A no-code builder can support agents that follow defined business processes and use standard integrations. Code becomes necessary when the agent needs custom authorization, proprietary tools, complex state handling, or deployment controls that a visual builder cannot expose. Base the decision on how much control the production application will need. A fast first prototype offers little evidence about production requirements.

What is the difference between LangGraph and LangChain?

LangChain provides higher-level components for creating agents, connecting models, and using tools. LangGraph is the lower-level orchestration runtime for controlling state, execution paths, persistence, and human intervention across long-running agents. LangChain agents run on LangGraph, so teams can begin with LangChain and work directly with LangGraph when they need finer control over execution.

Do I need a multi-agent system, or is one agent enough?

A multi-agent system is justified when separate parts of the task require isolated context, different permissions, specialist tools, or an independent review step. Adding agents without those requirements increases the number of prompts, handoffs, and failure paths the team must maintain. Traces from an initial single-agent implementation can reveal whether delegation would solve a specific performance or context problem.

How do I test an AI agent once it is built?

Create evaluation cases from important user tasks, known failures, and high-risk tool interactions. Score the final result alongside relevant execution details, such as tool selection, argument accuracy, and completion of required steps. Braintrust connects traces to datasets, experiments, and scorers, allowing teams to test changes before release and apply the same quality criteria to production requests.

Should I build an AI agent in Python or TypeScript?

Use the language that already supports the surrounding application, deployment environment, and engineering team. Python offers access to many established agent libraries, while TypeScript can keep frontend, backend, tool definitions, and shared application types in one codebase. LangGraph and the OpenAI Agents SDK support both languages, while Mastra supports only TypeScript.

Share

Trace everything