Agentic pipelines
Compare LangGraph, n8n, and Temporal for building agentic workflows, understand when each tool shines, and learn the deterministic-plan pattern that makes production agents reliable.
TL;DR
- "Call the LLM in a loop" is not a production architecture. You need retry logic, observability, state persistence, cost budgets, and audit trails baked into the infrastructure layer.
- Three tool categories cover the space: LangGraph (complex stateful Python-first agent logic with conditional edges), n8n (low-code business process automation with AI nodes), Temporal (durable execution that survives crashes, deploys, and multi-day runs).
- The deterministic plan pattern is a useful baseline for reliable production agents. The LLM generates a step-by-step plan once; deterministic code executes it. Fewer LLM calls during execution can reduce hallucination compounding.
- A DAG (directed acyclic graph) is easier to debug, retry, and reason about than a looping graph. Add cyclic branching only when you have proven you need it.
- Every agentic pipeline needs a baseline of input validation, step-level logging, bounded retries with backoff, cost budgets, per-step timeouts, and output validation. Tune the details to the risk and latency requirements.
30-second mental model
An agentic pipeline is orchestration around model and tool calls. The orchestration layer owns state, retries, timeouts, budgets, observability, and recovery; the LLM supplies bounded decisions inside that workflow. Use a DAG or deterministic plan when dependencies are known, and add loops only where iterative behavior is a tested requirement.
5-minute explanation
Separate planning from execution when possible. Let the model produce a typed, bounded plan; validate it against an allowlist and business rules; then let deterministic code execute each step with an idempotency key, timeout, retry policy, and checkpoint. For workflows that need conditional routing or pauses, represent those transitions explicitly in a graph or durable workflow engine.
The framework choice follows the failure model: application-level graphs are useful for branching agent logic, low-code nodes suit business automation, and durable workflow systems suit long-running work that must survive process failures. In all cases, external side effects still need idempotency and authorization.
The problem it solves
An agent can work in a terminal: it calls the LLM, uses a tool, calls the LLM again, and produces a result. That is a useful prototype.
You run it in production. At step 7 of 12, a transient network error kills the container. The $200 of compute is gone and you restart from step 1. With 50 concurrent runs per day, that isn't a bug you can ignore.
Without pipeline infrastructure, you have no resume capability, no cost tracking, no visibility into which steps fail most often, and no way to catch the runs that silently produce wrong output. That's the problem agentic pipeline frameworks solve.
What is it?
An agentic pipeline is the infrastructure layer that wraps AI steps with the production requirements that any serious software system needs: state management, error handling, observability, retries, and audit trails.
Three tools dominate this space. Each occupies a different position on the trade-off between LLM-native workflow complexity and operational complexity.
How it works
LangGraph: Python-first stateful graph
LangGraph models your workflow as a directed graph where each node is a Python function and edges define control flow. The key features are add_conditional_edges (route to different nodes based on runtime state) and a built-in checkpointer that serializes graph state to a database after each step. This checkpointer can help long-running workflows reload from a checkpoint after a crash instead of starting over.
Best for: complex stateful agent logic with multi-level conditional branching, human-in-the-loop interrupt gates, and multi-agent coordination. Public case studies from companies such as Klarna, LinkedIn, and Elastic illustrate this use; verify current framework fit and operational requirements for your own workload. Choose LangGraph when your workflow logic is conditional, Python-first, and complex enough to justify the learning curve.
from typing import TypedDict, Annotated
from langgraph.graph import StateGraph, END
from langgraph.graph.message import add_messages
class AgentState(TypedDict):
messages: Annotated[list, add_messages]
step_count: int
result: str | None
def call_llm(state: AgentState) -> AgentState:
response = llm.invoke(state["messages"])
return {"messages": [response], "step_count": state["step_count"] + 1}
def call_tool(state: AgentState) -> AgentState:
last_message = state["messages"][-1]
result = execute_tool(last_message.tool_calls[0])
return {"messages": [result]}
def should_continue(state: AgentState) -> str:
last_message = state["messages"][-1]
if last_message.tool_calls:
return "call_tool"
return END
graph = StateGraph(AgentState)
graph.add_node("call_llm", call_llm)
graph.add_node("call_tool", call_tool)
graph.set_entry_point("call_llm")
graph.add_conditional_edges("call_llm", should_continue)
graph.add_edge("call_tool", "call_llm")
app = graph.compile(checkpointer=memory_saver)
n8n: Low-code with AI nodes
n8n is a visual workflow automation platform with 400+ pre-built integrations and built-in AI nodes (call OpenAI, classify with Claude, extract with Gemini). The visual editor means non-engineers can author, maintain, and debug workflows without writing code. It's self-hostable and production-grade for workflows that fit its model.
Best for: business process automation where AI is one step in a larger integration workflow. Not suited for complex conditional agent logic or deeply recursive graphs. Choose n8n when the workflow is integration-focused, the logic is linear or lightly branched, and the team includes non-engineers who will maintain it long-term.
Temporal: Durable execution that survives crashes
Temporal is not AI-native. It's a durable execution engine where your workflow code is ordinary Python (or Go, Java, TypeScript). Temporal records workflow history and retries activities, but durable workflow execution does not make external side effects exactly-once by itself. If your workflow server crashes around step 15 of 20, Temporal can replay workflow history and retry the pending activity; activities that call APIs or mutate data should be idempotent.
Best for: multi-day workflows, durable execution, and coordination across multiple services. The setup cost is high (you need to run the Temporal service), and external effects still need idempotency and reconciliation. Choose Temporal when workflows must survive crashes, deploys, and days-long execution windows.
import asyncio
from datetime import timedelta
from temporalio import activity, workflow
from temporalio.common import RetryPolicy
@activity.defn
async def summarize_document(doc_url: str) -> str:
"""Non-deterministic activity: fetch and LLM-summarize a document."""
content = await fetch_url(doc_url)
return await llm_client.summarize(content)
@workflow.defn
class DocumentAnalysisWorkflow:
@workflow.run
async def run(self, doc_urls: list[str]) -> dict:
results = []
for url in doc_urls:
# Each activity auto-retries; state persists across crashes
summary = await workflow.execute_activity(
summarize_document,
url,
schedule_to_close_timeout=timedelta(minutes=5),
retry_policy=RetryPolicy(maximum_attempts=3),
)
results.append({"url": url, "summary": summary})
return {"summaries": results, "total": len(results)}
The sequence below shows how Temporal handles a mid-workflow crash without data loss or double-execution.
The deterministic plan pattern
The most reliable pattern for production agentic workflows: separate the LLM's planning role from execution entirely. The LLM generates a structured step list once. Code executes it deterministically, with no further LLM calls.
Continue Reading with Premium
Unlock this article and every other in-depth system design guide on the platform with SDEpedia Premium.
Related Articles
Learn how LangGraph models agent state as a typed graph, how conditional edges enable complex branching workflows, and how persistent checkpointing lets agents survive crashes and support human approval gates.
Learn why production agents fail when demos succeed, how to reduce blast radius through sandboxing and cost limits, and what reliability patterns make AI agents safe to deploy.
Learn when AI agents need human approval gates, how to implement pause-and-resume in LangGraph, and how to calibrate the approval threshold to balance safety with autonomy.