Skip to content

What is an AI agent framework?

Mikhail Bodnarchuk

Definition

An AI agent framework is a software library for building agents on top of language models. It supplies the parts every agent needs: model clients, a loop that runs tool calls until the task is done, tool schemas, state and memory, human approval steps and tracing. Examples include the OpenAI Agents SDK, Google ADK and Microsoft Agent Framework.

What does an AI agent framework give you?

Every agent needs the same plumbing: a way to call models, a loop that keeps going until the task is done, tools the model can call, state between turns, and a record of what happened. A framework ships that plumbing as a library, so your code describes the agent instead of rebuilding the machinery around it.

The building blocks, with the names four frameworks use in their own docs:

Building blockWhat it doesExamples from the docs
Model clientsOne interface to many model providersMicrosoft Agent Framework lists Microsoft Foundry, Anthropic, Azure OpenAI, OpenAI and Ollama; Google ADK has adapters for other models and local ones
Agent loopCalls the model, runs the tools it asks for, repeats until doneOpenAI Agents SDK: "a built-in loop that continues until the task is complete"
ToolsTurns your functions and MCP servers into tools the model can callOpenAI function tools with automatic schemas; MCP clients in Microsoft Agent Framework
Multi-agent patternsDelegation between agents, or explicit execution pathsOpenAI handoffs and agents as tools; graph-based workflows in Microsoft Agent Framework and in ADK 2.0
State and memoryKeeps context within a run and across sessionsOpenAI sessions; LangGraph persistence and memory
Human approvalPauses a run until a person decidesHuman in the loop in OpenAI Agents SDK and in LangGraph
GuardrailsValidates inputs and outputsOpenAI guardrails run in parallel with the agent and fail fast
TracingRecords every model call, tool call and handoffBuilt-in tracing in OpenAI Agents SDK; telemetry in Microsoft Agent Framework

Sources: OpenAI Agents SDK, Microsoft Agent Framework, Google ADK and the LangGraph overview.

Framework, harness or orchestration runtime: where is the line?

The lines are moving. Our agent harness entry explains LangChain's split: a framework gives you parts, a harness gives you a working agent with defaults. Frameworks have started to ship harnesses too. Microsoft Agent Framework now includes a "Harness Agent" with planning and todo tracking, context compaction, file access and memory, and tool approval for long, multi-step tasks.

On the other side sits durable execution: checkpoints, resumable runs and pauses that survive a restart. LangGraph calls itself "a low-level orchestration framework and runtime for long-running, stateful agents" and says it does not prescribe prompts or agent architecture. AI orchestration covers that layer.

In practice, ask what you want the library to own:

You want to ownPick
The loop, tool dispatch and state, with only model calls from a libraryA provider API or SDK, no framework
The agent's logic, with the loop, tools and tracing handledAn agent framework
Explicit control over every state and step, with durable pausesAn orchestration runtime such as LangGraph
Almost nothing: a ready agent for files, code and long tasksAn agent harness

Do you need an agent framework at all?

Two of the framework vendors answer this in their own docs. OpenAI says to use its Responses API directly when "you want to own the loop, tool dispatch, and state handling yourself" or when the workflow is short-lived and mainly returns the model's response. Microsoft is blunter: "If you can write a function to handle the task, do that instead of using an AI agent."

Microsoft's docs also separate agents from workflows. Use an agent when the task is open-ended or conversational and needs autonomous tool use and planning. Use a workflow when the process has well-defined steps, when you need explicit control over execution order, or when several agents or functions must coordinate.

Example: what a framework does with one Python function

The script below gives a refund function to the OpenAI Agents SDK and lets it build the tool. No model is called: we play the model's part by sending the tool two sets of arguments, one valid and one out of range.

# One thing an agent framework does for you: turn a function into a tool schema
# and check the model's arguments before your code runs. No model call, no API key.
# Run with OPENAI_AGENTS_DONT_LOG_TOOL_DATA=0 so the SDK keeps the validation details.
import asyncio, json
from typing import Annotated
from pydantic import Field
from agents import function_tool, set_tracing_disabled
from agents.tool_context import ToolContext

set_tracing_disabled(True)  # offline demo: nothing to export
refunds = []

@function_tool(failure_error_function=None)  # raise errors instead of sending a generic message to the model
def issue_refund(order_id: str, amount_eur: Annotated[int, Field(ge=1, le=500)]) -> str:
    """Refund part of an order.

    Args:
        order_id: The order to refund, for example A-42.
        amount_eur: Refund in whole euros.
    """
    refunds.append((order_id, amount_eur))
    return f"refunded {amount_eur} EUR on {order_id}"

print("tool:", issue_refund.name, "|", issue_refund.description)
print("schema:", json.dumps(issue_refund.params_json_schema["properties"]["amount_eur"]))

async def model_proposes(args):  # what happens when a model asks for this call
    ctx = ToolContext(context=None, tool_name=issue_refund.name, tool_call_id="call_1", tool_arguments=args)
    try:
        return await issue_refund.on_invoke_tool(ctx, args)
    except Exception as e:
        if e.__cause__ is None:  # details are redacted unless the env var is set
            return f"{type(e).__name__}: {e}"
        err = e.__cause__.errors()[0]  # the pydantic validation error behind it
        return f"{type(e).__name__}, {err['loc'][0]}: {err['msg']}"

print("ok call  ->", asyncio.run(model_proposes('{"order_id": "A-42", "amount_eur": 120}')))
print("bad call ->", asyncio.run(model_proposes('{"order_id": "A-42", "amount_eur": 5000}')))
print("refunds executed:", refunds)

We ran it with openai-agents 0.25.0 on Python 3.11, as OPENAI_AGENTS_DONT_LOG_TOOL_DATA=0 python refund_tool.py. Output:

tool: issue_refund | Refund part of an order.
schema: {"description": "Refund in whole euros.", "maximum": 500, "minimum": 1, "title": "Amount Eur", "type": "integer"}
ok call  -> refunded 120 EUR on A-42
bad call -> ModelBehaviorError, amount_eur: Input should be less than or equal to 500
refunds executed: [('A-42', 120)]

Three things happened that you would otherwise write by hand. The docstring became the tool and argument descriptions. The Field(ge=1, le=500) limit became minimum and maximum in the JSON schema the model sees. And the 5,000 euro call was rejected before the function body ran, so only one refund was executed. We changed two defaults. The SDK's tools docs say that without failure_error_function, a default error function tells the model an error occurred, instead of raising an exception in your code. And without the environment variable, the same script prints ModelBehaviorError: Invalid JSON input for tool issue_refund, with no validation details.

A schema limit is a first line, not a permission system. The refund ceiling for a given user still belongs in your own code.

How do you choose an AI agent framework?

Work through these questions in order. Each answer removes options.

  1. Language. ADK lists Python, TypeScript, Go, Java and Kotlin. Microsoft Agent Framework covers .NET and Python, with Go in public preview. The OpenAI Agents SDK docs we read are for Python.
  2. Model providers. Check which providers have first-party clients and how a second provider is added. A framework tied to one vendor's API makes model changes a migration.
  3. Control flow. Do you want the model to plan freely, or a graph you can read? LangGraph's advice: use it "when you need explicit control over state and control flow".
  4. State and pauses. Can a run wait hours for an approval and resume after a restart? Which storage backs it in production?
  5. Tracing. Where do traces go, and can they reach the observability tools you already run?
  6. Lineage and stability. Microsoft Agent Framework is the direct successor of Semantic Kernel and AutoGen, built by the same teams, with migration guides from both. Read the release notes and preview labels before you depend on an API.

Then build the same small agent in your two finalists, with one real tool and one approval step, and compare how much code each needed and how easy each failure was to debug. For the steps around that, see our guide on how to build AI agents.

We build AI agents with Model Context Protocol, the Claude Agent SDK, the OpenAI Agents SDK, LangGraph and LlamaIndex: single agents or multi-step workflows with state, retries, timeouts and clear stopping rules.

Sources

  1. OpenAI Agents SDK, OpenAI (openai-agents-python docs), 2026-09-25
  2. Tools, OpenAI (openai-agents-python docs), 2026-10-17
  3. Microsoft Agent Framework, Microsoft Learn, 2026-10-28
  4. Build production agents, not prototypes., Google, Agent Development Kit (ADK) docs, 2026-10-15
  5. LangGraph overview, LangChain docs, 2026-11-16

Frequently asked questions

Is LangChain an AI agent framework?

Yes. LangChain's own docs call it the agent framework in its stack, with abstractions and integrations for models, tools and agent loops, while LangGraph is the orchestration runtime underneath and Deep Agents is the harness on top.

Which AI agent framework is best?

There is no single answer. The right one depends on your language, your model providers and how much control flow you want to write yourself, so build the same small agent in two candidates and compare.

Can I switch agent frameworks later?

Yes, if your tools and business logic live in plain functions or MCP servers and the framework code stays thin. Prompts, tool definitions and evals then move with little change; the loop and state handling get rewritten.

Is an AI agent framework the same as an agent builder?

No. A framework is a code library for developers. No-code agent builders, such as LangSmith Fleet in LangChain's stack, let people assemble agents from templates and integrations without writing the loop.

Mikhail BodnarchukMikhail BodnarchukFounder of Codeception and CodeceptJSBoth are open-source testing frameworks: Codeception for PHP, CodeceptJS for JavaScript.LinkedInGitHub

Building with AI agents? Talk to an engineer.