[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3
SEQ. 4
SEQ. 5
SEQ. 6
SEQ. 7

LangGraph Functional API

👥 Multi-Agent Systems15 min100 BASE XP

A Pythonic Alternative to Graph Construction

LangGraph v1.2+ introduced the Functional API, a radically simpler way to build agents using Python decorators instead of explicit graph construction. While the Graph API (StateGraph, nodes, edges) remains the gold standard for complex workflows, the Functional API lets you build production-grade agents with plain Python functions decorated with @entrypoint and @task.

Core Decorators

DecoratorPurposeAnalogy
@entrypointDefines the top-level agent function that receives user input and orchestrates tasksThe main() of your agent
@taskDefines an individual unit of work (LLM call, tool execution, data processing)A single node in a graph

Functional API Example

from langgraph.func import entrypoint, task

@task
async def research(topic: str) -> str:
    """Search the web and compile research notes."""
    results = await web_search(topic)
    return summarize(results)

@task
async def write_draft(notes: str) -> str:
    """Write a blog post draft from research notes."""
    return await llm.generate(f"Write a blog post based on: {notes}")

@task
async def review(draft: str) -> dict:
    """Score the draft and provide feedback."""
    return await llm.generate_json(f"Score 1-10 and give feedback: {draft}")

@entrypoint
async def blog_writer(topic: str) -> str:
    notes = await research(topic)
    draft = await write_draft(notes)
    result = await review(draft)
    while result["score"] < 8:
        draft = await write_draft(notes + f"\nFeedback: {result['feedback']}")
        result = await review(draft)
    return draft

Functional API vs Graph API

DimensionFunctional APIGraph API (StateGraph)
SyntaxPlain Python with decoratorsExplicit graph builder (addNode, addEdge)
Learning CurveLow — feels like writing normal async codeMedium — requires understanding graph concepts
Persistence✅ Automatic via @task checkpoints✅ Manual checkpointing at nodes
Human-in-Loop✅ Via interrupt() inside any task✅ Via interrupt nodes
ParallelismNative Python asyncio.gather()Fan-out/fan-in edges
Best ForLinear and moderately complex workflowsComplex multi-agent orchestration with branching
💡 Key Insight: Each @task call is automatically checkpointed. If your agent crashes mid-execution, it resumes from the last completed task — you get persistence and fault tolerance for free, without writing any graph wiring code.
SYNAPSE VERIFICATION
QUERY 1 // 3
What is the purpose of the @entrypoint decorator in LangGraph's Functional API?
It defines a tool for the agent
It marks the top-level function that receives user input and orchestrates tasks
It configures the LLM model
It sets up authentication
Watch: 139x Rust Speedup
LangGraph Functional API | Multi-Agent Systems — AI Agents Academy