Skip to content
Blog

Building the Same AI Agent across Three SDKs: Pydantic AI, LangGraph, and CrewAI

Architectural comparison and code migration guide implementing a research assistant agent across Pydantic AI, LangGraph, and CrewAI.

Published on • October 24, 2026

AI Assistant

Selecting an AI agent framework is one of the most consequential decisions when starting a new Generative AI project. The python agent ecosystem features three dominant frameworks: Pydantic AI (type-safe, lightweight, Pythonic), LangGraph (graph-based, stateful, low-level control), and CrewAI (role-playing, multi-agent task delegation).

In this architectural comparison, we implement the exact same Research Assistant Agent across all three SDKs to evaluate developer experience, state management, and type safety.

The Core Task Spec: Research Assistant Agent

Our agent must accept a research query, search a knowledge base (simulated tool call), summarize findings, and return a validated Pydantic model (ResearchSummary).

from pydantic import BaseModel

class ResearchSummary(BaseModel):
    topic: str
    key_findings: list[str]
    confidence_score: float

1. Pydantic AI Implementation

Pydantic AI emphasizes type safety, Pythonic syntax, and direct integration with Pydantic validation:

from pydantic_ai import Agent

pydantic_agent = Agent(
    'google-gla:gemini-1.5-pro',
    result_type=ResearchSummary,
    system_prompt="You are an expert research analyst. Summarize findings clearly."
)

@pydantic_agent.tool_plain
def search_knowledge_base(query: str) -> str:
    return f"Results for {query}: Gemini 3 delivers multimodal context window extensions."

# Execution
result = pydantic_agent.run_sync("Research Gemini 3 capabilities.")
summary: ResearchSummary = result.data

2. LangGraph Implementation

LangGraph approaches agents as explicit state graphs (StateGraph), offering fine-grained control over execution nodes, edges, and state persistence:

from typing import TypedDict
from langgraph.graph import StateGraph, END
from langchain_core.messages import HumanMessage

class AgentState(TypedDict):
    query: str
    findings: str
    result: ResearchSummary | None

def research_node(state: AgentState) -> AgentState:
    # Perform search tool execution
    findings = f"Results for {state['query']}: Gemini 3 multimodal capabilities."
    return {"findings": findings}

def summarize_node(state: AgentState) -> AgentState:
    # Synthesize research summary
    summary = ResearchSummary(
        topic=state['query'],
        key_findings=[state['findings']],
        confidence_score=0.92
    )
    return {"result": summary}

# Construct Graph
workflow = StateGraph(AgentState)
workflow.add_node("research", research_node)
workflow.add_node("summarize", summarize_node)
workflow.set_entry_point("research")
workflow.add_edge("research", "summarize")
workflow.add_edge("summarize", END)

app = workflow.compile()
output = app.invoke({"query": "Research Gemini 3 capabilities."})

3. CrewAI Implementation

CrewAI abstracts workflows into role-playing autonomous team members (Agent, Task, Crew):

from crewai import Agent as CrewAgent, Task, Crew

researcher = CrewAgent(
    role='Senior Research Analyst',
    goal='Uncover cutting-edge AI breakthroughs',
    backstory='Expert tech analyst with decades of experience.'
)

research_task = Task(
    description='Research Gemini 3 capabilities and summarize key findings.',
    expected_output='Structured ResearchSummary model',
    output_pydantic=ResearchSummary,
    agent=researcher
)

crew = Crew(agents=[researcher], tasks=[research_task])
crew_result = crew.kickoff()

Framework Feature Comparison Matrix

FeaturePydantic AILangGraphCrewAI
Primary FocusType safety, Pythonic simplicityExplicit state graph cyclesMulti-agent role delegation
Learning CurveLow (Standard Python/Pydantic)High (Graph theory concepts)Medium (Task/Role abstraction)
State ControlSimple session contextsComplete DAG/Cyclic state controlManaged Crew state flow
Best ForEmbedded agentic API endpointsComplex, branching workflowsHuman-like team simulations

Conclusion

Choose Pydantic AI for clean API integration and type safety, LangGraph for complex state graphs and cyclic loops, and CrewAI for rapid multi-agent team prototyping.

References & Further Reading