Skip to main content

Agent Graph

An agent graph is a representation of an agentic LLM application as a directed graph of nodes (work units, often LLM calls or tools) connected by edges (transitions, often conditional on state). It is used by frameworks like LangGraph as the primary mental model. An agent graph differs from a linear chain by supporting branching, loops, and explicit state passed between nodes. The graph structure makes routing decisions and termination conditions visible in code rather than implicit in a chain of prompt instructions, which helps with debugging, testing, and reasoning about long-running flows.

Example

A research agent graph might have nodes for "plan," "retrieve," "synthesize," and "finalize," with conditional edges from "synthesize" back to "retrieve" if the model judges its evidence insufficient. Each node reads from and writes to a shared state object that all subsequent nodes can inspect, and the graph runs until either "finalize" emits a result or a step ceiling is reached.

Put this into practice

Build polished, copy-ready prompts in under 60 seconds with SurePrompts.

Try SurePrompts