Agent Frameworks in Python — Core Concepts
Agent frameworks provide the scaffolding for building AI systems that can reason, use tools, and execute multi-step plans. In Python, this ecosystem has matured from simple ReAct loops to sophisticated multi-agent orchestration platforms.
What makes an agent
An agent is an LLM-powered system with three capabilities beyond basic chat:
- Tool use — the ability to call external functions (APIs, databases, search engines).
- Planning — breaking a task into steps and deciding which tools to use.
- Memory — retaining information across steps and conversations.
The framework coordinates these capabilities into a coherent execution loop.
The reasoning loop
Most agents follow the ReAct (Reasoning + Acting) pattern:
- Think — the model reasons about what to do next.
- Act — it calls a tool with specific parameters.
- Observe — it receives the tool result.
- Repeat — until the task is complete or a limit is reached.
This loop is the fundamental building block. Frameworks differ in how they implement and extend it.
Major frameworks compared
LangGraph — part of the LangChain ecosystem. Models agents as state machines with explicit nodes and edges. Best for complex workflows where you need fine-grained control over the execution graph. Supports cycles, conditional branching, and human-in-the-loop checkpoints.
CrewAI — focused on multi-agent collaboration. Define agents with roles (researcher, writer, editor) and tasks. Agents can delegate to each other. Good for workflows where different perspectives or skills are needed.
AutoGen (Microsoft) — designed for multi-agent conversation. Agents communicate via messages and can run code. Strong support for human-agent collaboration and group chat patterns.
Smolagents (Hugging Face) — lightweight framework where agents write and execute Python code directly instead of using structured tool calls. Minimal abstraction, close to the metal.
OpenAI Assistants API — managed agent runtime. Handles tool execution, file search, and code execution server-side. Simplest to set up but least control.
Choosing a framework
| Need | Best fit |
|---|---|
| Simple tool-calling agent | OpenAI Assistants or plain code |
| Complex state machine | LangGraph |
| Multi-agent collaboration | CrewAI or AutoGen |
| Minimal dependencies | Smolagents or custom |
| Enterprise with observability | LangGraph + LangSmith |
Memory patterns
Short-term memory — the conversation history within a single task. All frameworks handle this.
Long-term memory — information persisted across conversations. Options include vector stores (semantic recall), key-value stores (exact recall), and summary memories (compressed context).
Working memory — a scratchpad for the current task. Frameworks like LangGraph model this explicitly as state that flows through the graph.
Common misconception
Many people think using an agent framework automatically makes their AI application better. Agents add complexity, cost, and unpredictability. For tasks where a single LLM call or a simple prompt chain suffices, an agent framework is overkill. Start simple and add agent capabilities only when you need dynamic tool selection or multi-step reasoning.
The one thing to remember: Agent frameworks organize AI into think-act-observe loops with tools and memory — choose the framework that matches your complexity needs, and resist the urge to use agents when simpler approaches work.
See Also
- Python Embedding Pipelines An embedding pipeline turns words into numbers that capture meaning — like translating every sentence into coordinates on a giant map of ideas.
- Python Guardrails Ai Guardrails are safety bumpers for AI — they check what the model says before it reaches users, like a spellchecker but for facts, tone, and dangerous content.
- Python Llm Evaluation Harness An LLM evaluation harness is like a report card for AI — it runs tests and grades how well the model answers questions so you know if it is actually improving.
- Python Llm Function Calling Function calling lets an AI ask your Python code for help — like a chef who can read a recipe but needs someone else to actually open the fridge.
- Python Prompt Chaining Think of prompt chaining as a relay race where each runner hands a baton to the next — except the runners are AI prompts building on each other's work.