Skip to content
Phase 3: Production PatternsStep 8 of 14Intermediate2 weeks

Agent Frameworks

Leverage production-ready tooling to build sophisticated agents faster.

LangChainLangGraphCrewAIState machinesGraph-based workflows

Getting Started

Agent frameworks provide pre-built abstractions for common patterns you would otherwise implement from scratch: tool routing, memory management, state machines, and multi-step orchestration. The three dominant frameworks in the Python ecosystem are LangChain, LangGraph, and CrewAI, each solving different problems.

Before reaching for a framework, you should have already built a basic agent manually. That experience helps you understand what the framework is abstracting and when those abstractions help versus hinder your work.

Install the core libraries to follow along:

pip install langchain langchain-openai langgraph crewai

Key Concepts

LangChain provides the foundational primitives: chains for sequential LLM calls, tool interfaces, output parsers, and retrieval integrations. It works best as a library of components you compose rather than a rigid framework.

LangGraph extends LangChain with a graph-based execution model. You define your agent as a directed graph where nodes are processing steps and edges define control flow. This makes complex workflows explicit and debuggable:

from langgraph.graph import StateGraph, END
from typing import TypedDict

class AgentState(TypedDict):
    query: str
    results: list[str]
    answer: str

graph = StateGraph(AgentState)
graph.add_node("search", search_node)
graph.add_node("synthesize", synthesize_node)
graph.add_edge("search", "synthesize")
graph.add_edge("synthesize", END)

app = graph.compile()
result = app.invoke({"query": "What is RAG?"})

CrewAI takes a role-based approach where you define agents with specific roles, goals, and backstories, then assign them tasks. It handles delegation and collaboration automatically.

When to go custom: If your agent has simple linear logic, a single tool, or you need to minimize dependencies, skip the frameworks. A well-structured Python class with direct API calls is often clearer and faster.

Hands-On Practice

Start by rebuilding your existing manual agent using LangGraph. Define each step of your agent's logic as a node, add conditional edges for branching decisions, and compare the debugging experience. Pay attention to how the graph structure makes the agent's decision flow visible and how state management becomes declarative rather than imperative.

Exercises

Build a Multi-Step Workflow with LangGraph

Create a LangGraph workflow that takes a user question, searches the web, synthesizes results, and generates a cited summary. The graph should have at least 3 nodes with conditional edges.

Knowledge Check

When should you choose a custom agent implementation over using a framework like LangChain?

Milestone Project

Multi-step agent workflow using LangGraph with branching logic and state persistence