What is @entrypoint?
@entrypoint is the foundation of LangGraph's functional API — it transforms an ordinary Python function into a fully stateful, checkpointed, interruptible workflow. When you decorate a function with @entrypoint, LangGraph wraps it in a compiled graph that exposes the same .invoke(), .stream(), and .batch() interface as a StateGraph-compiled graph. The decorated function's return value becomes the graph's output; its parameter is the graph's input.
The key capability @entrypoint unlocks is persistence. By passing a checkpointer (e.g., MemorySaver()) either to the decorator or at invocation time via config={"configurable": {"thread_id": "x"}}, every invocation's state is checkpointed. If the function is interrupted (via interrupt() or a raised Interrupt exception), the checkpoint saves the execution state and the function can be resumed from that exact point rather than restarting. This is the mechanism for human-in-the-loop approval steps: pause, present state to a user, collect their response via update_state(), then resume.
@entrypoint composes naturally with @task-decorated functions. Functions marked with @task are cached within an @entrypoint invocation — identical inputs return the cached result rather than re-executing. This eliminates redundant LLM calls, database queries, or API requests when a workflow is partially replayed after an interrupt. The functional API is particularly useful for workflows with complex branching logic that is awkward to express as a graph with conditional edges — standard Python if/else statements, loops, and exception handling all work inside an @entrypoint function.
Use Cases
- • Multi-step agents
- • Conversational AI
- • Decision trees
- • Data pipelines
- • Orchestration
- • Interactive apps
Key Features
- ✓ State persistence
- ✓ Caching
- ✓ Checkpointing
- ✓ Interrupt capability
- ✓ Python syntax
- ✓ Auto-compilation
When NOT to Use
For simple chains—use LCEL pipes.
Notes
Pass checkpointer to the decorator, not just at invoke time
For permanent persistence across process restarts, pass checkpointer=SqliteSaver.from_conn_string("./state.db") to the @entrypoint decorator itself. Passing only at invoke time via config uses an in-memory checkpointer that evaporates when the process exits. For production HITL workflows, the checkpointer must survive restarts.
The function's return value is the graph output — return a serializable type
LangGraph serializes the return value into the checkpoint. Return plain Python types (str, dict, list) or Pydantic models. Returning non-serializable objects (open file handles, generator objects, DB connection objects) raises a serialization error when checkpointing is enabled.
@entrypoint wraps the function in a compiled graph — invoke it like a graph
After decoration, my_function is no longer a plain function — it is a CompiledGraph object. Call it with my_function.invoke(input, config=...) or my_function.stream(input, config=...). Calling my_function(input) directly bypasses the LangGraph runtime and loses all persistence, caching, and interrupt support.
Nest @task calls inside @entrypoint for automatic caching and parallel execution
@task functions return futures inside @entrypoint. Call .result() to await them synchronously, or collect multiple futures and call .result() on each after all are submitted to run them in parallel: fut1 = fetch_a(x); fut2 = fetch_b(y); a = fut1.result(); b = fut2.result() — LangGraph executes both tasks concurrently.
Import
from langgraph.func import entrypoint
How to Apply
@entrypoint
def my_graph(input_text):
return process(input_text)
What It Enables
- ✓ State persistence
- ✓ Task caching
- ✓ Checkpointing
- ✓ Interrupt/resume
Code Examples
Basic entrypoint
from langgraph.func import entrypoint
@entrypoint
def agent(input_text: str) -> str:
return call_llm(input_text)
Entrypoint with checkpointer and cached @task
from langgraph.func import entrypoint, task
from langgraph.checkpoint.memory import MemorySaver
@task
def fetch_data(url: str) -> dict:
return requests.get(url).json()
@entrypoint(checkpointer=MemorySaver())
def pipeline(url: str) -> str:
data = fetch_data(url).result() # Cached on replay
return summarize(data)
Human-in-the-loop with interrupt()
from langgraph.func import entrypoint
from langgraph.types import interrupt
from langgraph.checkpoint.memory import MemorySaver
@entrypoint(checkpointer=MemorySaver())
def review_workflow(draft: str) -> str:
human_decision = interrupt({"draft": draft})
if human_decision == "approved":
return publish(draft)
return revise(draft)
Integration Patterns
@task marks cached subtasks
graph.invoke()
Common Mistakes
❌ def graph(): # Missing decorator
✅ @entrypoint def graph(input): return result
Related LangChain References
Browse the full LangChain API reference index to explore more classes, methods, and decorators, or start with the LangChain introduction tutorial for end-to-end context on building with @entrypoint and the wider framework.
@entrypoint FAQ
What does @entrypoint do in LangChain?
Define entry point of stateful LangGraph workflow. @entrypoint is the foundation of LangGraph's functional API — it transforms an ordinary Python function into a fully stateful, checkpointed, interruptible workflow. When you decorate a function with @entrypoint, LangGraph wraps it in a compiled graph that exposes the same .invoke(), .stream(), and .batch() interface as a StateGraph-compiled graph. The decorated function's return value becomes the graph's output; its parameter is the graph's input. The key capability @entrypo…
Which package provides @entrypoint?
DevShelfHub documents @entrypoint from the langgraph.func package. Pin your installed LangChain version and match imports to the snippet on this page.
When should I use @entrypoint?
Use @entrypoint when your LangChain agents, workflows, or pipelines need the behavior described in this guide.
When should I avoid using @entrypoint?
For simple chains—use LCEL pipes.
How do I apply @entrypoint in Python?
Apply @entrypoint as a decorator above your function definition. Import it from from langgraph.func import entrypoint and annotate the function you want to wrap. See the code examples on this page for a complete working snippet.
Where can I explore more LangChain API reference pages?
Open the LangChain API reference index on DevShelfHub to browse classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.