Advanced

Agent Frameworks with Claude

LangGraph, AutoGen, and CrewAI are popular agent frameworks that handle the orchestration logic — message routing, state management, agent-to-agent communication — while you provide the LLM. This page shows how to configure Claude as the backbone model in each framework.

LangGraph: Graph-Based Workflows with Claude

LangGraph is LangChain's graph-based workflow framework — nodes are processing steps, edges define flow. Claude is the LLM node in the graph:

from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent

# Use Claude as the LLM
model = ChatAnthropic(model="claude-sonnet-4-6")

# Create an agent with tools
from langchain_core.tools import tool

@tool
def search(query: str) -> str:
    """Search the web for information."""
    # Your search implementation
    return f"Results for: {query}"

agent = create_react_agent(model, tools=[search])

# Run the agent
result = agent.invoke({
    "messages": [("user", "What's the latest on LLM benchmarks?")]
})

LangGraph's strengths for Claude-based agents: built-in state management with TypedState, human-in-the-loop support via interrupt/resume, streaming output, and built-in retry logic. The graph approach makes complex multi-step workflows easier to reason about and debug than raw loop code.

AutoGen: Multi-Agent Conversation with Claude

Microsoft's AutoGen frames agents as participants in a conversation. Agents send messages to each other; the framework routes them. To use Claude in AutoGen v0.4+:

from autogen_ext.models.anthropic import AnthropicChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat

# Create Claude client
claude_client = AnthropicChatCompletionClient(
    model="claude-sonnet-4-6"
)

# Create an agent backed by Claude
assistant = AssistantAgent(
    name="claude_assistant",
    model_client=claude_client,
    system_message="You are a helpful research assistant."
)

# Create a team of agents
team = RoundRobinGroupChat([assistant], max_turns=5)

# Run a task
import asyncio
result = asyncio.run(
    team.run(task="Summarise the key differences between RAG and fine-tuning.")
)

AutoGen is well-suited for multi-agent conversation patterns where you want agents to critique each other's outputs, debate, or collaborate on writing.

CrewAI: Role-Based Agent Crews

CrewAI organises agents into "crews" with defined roles, goals, and backstories. To use Claude in CrewAI:

from crewai import Agent, Task, Crew
from langchain_anthropic import ChatAnthropic

# Claude as the LLM
claude = ChatAnthropic(model="claude-sonnet-4-6")

# Define agents with roles
researcher = Agent(
    role="Research Analyst",
    goal="Find comprehensive information on the given topic",
    backstory="You are an expert researcher with deep analytical skills.",
    llm=claude,
    verbose=True
)

writer = Agent(
    role="Technical Writer",
    goal="Transform research into clear, engaging content",
    backstory="You specialise in making complex technical topics accessible.",
    llm=claude
)

# Define tasks
research_task = Task(
    description="Research the current state of vector databases",
    agent=researcher
)

writing_task = Task(
    description="Write a 500-word summary based on the research",
    agent=writer
)

# Create and run the crew
crew = Crew(agents=[researcher, writer], tasks=[research_task, writing_task])
result = crew.kickoff()

When to Use a Framework vs Build Your Own

Use a framework when

  • You need complex state management across many steps
  • You want built-in human-in-the-loop support
  • You need multi-agent collaboration patterns out of the box
  • Your team knows the framework and wants to move fast
  • You need observability tooling (LangSmith, etc.)

Build your own when

  • Your agent loop is simple (under 50 lines of loop logic)
  • You want full control over every API call
  • Framework abstractions add confusion rather than clarity
  • You need to minimise dependencies for a production microservice
  • Latency is critical and framework overhead matters

Checklist: Do You Understand This?

  • LangGraph: graph-based with TypedState — best for complex sequential workflows with branching and human-in-the-loop
  • AutoGen: conversation-based multi-agent — best for agent-to-agent collaboration, critique, and debate patterns
  • CrewAI: role-based crews — best for structured workflows where each agent has a clear, specialised job
  • All three: use ChatAnthropic (LangChain-compatible) or the Anthropic SDK directly to set Claude as the LLM
  • Simple agents: build your own loop — frameworks add overhead not justified for straightforward cases

Page built: 01 Jun 2026