compile()
compile() turns a StateGraph definition into a runnable graph. Compilation performs structural checks and accepts runtime features such as a checkpointer or static breakpoints.1
Tiny example
Section titled “Tiny example”from langgraph.checkpoint.memory import InMemorySaver
graph = builder.compile(checkpointer=InMemorySaver())result = graph.invoke( {"order_id": "A-104", "status": "new"}, {"configurable": {"thread_id": "order-A-104"}},)- Build nodes and edges.
- Compile once.
- Invoke the compiled graph many times with different inputs.
Failure note
Section titled “Failure note”Compilation checks graph structure; it does not call every API or prove every route works. Test success, failure, loop termination, and resume paths separately.
Related
Section titled “Related”Footnotes
Section titled “Footnotes”-
LangChain, Graph API overview. ↩