[KongchangAI]
· 2 min read· 1,155 words

LangGraph for Beginners: Agent Flow Control and Enterprise Development in Practice

LangGraph for Beginners: Agent Flow Control and Enterprise Development in Practice

LangGraph is a low-level orchestration framework that solves the problem of insufficient Agent control caused by context bloat in fixed flows.

Based on a Bilibili tutorial, this article outlines LangGraph's positioning, core capabilities, and its hierarchical relationship with LangChain and Deep Agent. It notes that LangChain Agents rely on autonomous LLM decision-making, which leads to verbose prompts and context bloat when handling multi-step fixed flows, easily causing tool call errors or missed steps. LangGraph fixes the orchestration flow, delegating determinism to the framework while keeping each step flexible. Its core capabilities include checkpoints, human intervention, conditional branching, parallel execution, fault-tolerant retries, and subgraphs. Hierarchically, LangGraph is the low-level orchestration runtime, LangChain is built on it, and Deep Agent further encapsulates it with file system and sandbox capabilities. Higher encapsulation means simpler usage but lower flexibility—choose according to the scenario.

Agent Limitations: When Flows Get Complicated

Agents in LangChain rely on LLM reasoning to decide autonomously whether to call tools, which tools to call, and to return results after multiple rounds of interaction based on the user's question. This pattern is flexible, but problems become obvious when facing multi-step fixed flows.

Suppose you need to complete five steps: crawl a fixed webpage, summarize the content with an LLM, generate a Markdown document from a template, compare it with yesterday's MD file, and send an email. Accomplishing this with an Agent is not impossible, but the prompt becomes extremely verbose, and as the steps progress, the context keeps accumulating, gradually drowning out the importance of the early prompts. The tutorial points out that this can cause the Agent to forget to call tools in subsequent execution, call the wrong tools, or even miss critical steps.

Flow step illustration

Context bloat refers to the number of tokens accumulated by an LLM in a single session exceeding the effective processing window, causing early key information to be diluted or lost. In multi-round Agent tool calls, each round appends historical messages and tool return results to the context, making the context length grow linearly. The LLM's attention mechanism becomes less sensitive to distant information in long contexts, and early instructions may be drowned out by subsequent content, triggering tool call errors or missed steps. Common mitigation strategies include context compression, segmented summarization, and external memory, but in fixed-flow scenarios these methods still struggle to guarantee determinism, which is why an orchestration framework like LangGraph is needed to constrain the flow structurally.

LangGraph's Approach: Fixed Orchestration

The core idea of LangGraph is to fix the flow: execute the first step separately, then move to the second step upon completion, and proceed in sequence, rather than letting the LLM decide each step autonomously based on context. In this way, the determinism of the flow is guaranteed by the framework, while whether each individual step uses an LLM, calls tools, or executes business logic remains freely decidable.

In other words, LangGraph doesn't care what model or tools you use—it focuses on doing one thing: orchestration. It is a low-level orchestration framework, close to the underlying execution engine, capable of precisely controlling the direction of each step.

Steps can be freely combined

Core Capabilities at a Glance

  • Checkpoints: Support saving execution state for recovery and debugging.
  • Human intervention: Allow inserting human review at sensitive steps.
  • Conditional branching: Dynamically select subsequent paths based on runtime results.
  • Parallel execution: Multiple branches can run simultaneously.
  • Fault-tolerant retries: Automatically retry when a step fails.
  • Subgraphs: Support nested structures of main graphs and dynamic subgraphs.

These capabilities give LangGraph precise control when handling complex flows.

Orchestration in AI application development refers to defining the execution order, branching, and state passing of multiple processing steps through code or configuration, rather than relying on autonomous LLM decision-making. Orchestration frameworks typically provide mechanisms such as state management, conditional jumps, parallel execution, and error handling, making flow behavior predictable and testable. As a low-level orchestration framework, LangGraph abstracts each step as a node, connects nodes via edges, and maintains a global state object; developers can explicitly define control flow while retaining the freedom to use LLMs or tools within each node. This design separates "flow determinism" from "step flexibility" and is a key pattern for bringing enterprise-grade agents into production.

Technical Hierarchy: LangGraph, LangChain, and Deep Agent

The tutorial uses a hierarchical architecture diagram to explain the relationship among the three. LangGraph sits at the bottom as the orchestration runtime; LangChain is built on top of LangGraph, providing the ability to assemble models, tools, and prompts so developers can quickly build Agents; Deep Agent further encapsulates on top of the Agent framework.

Hierarchy comparison

LangChain's Agent lets the LLM fully decide what to execute autonomously, suitable for non-flow scenarios that require flexible combinations of models and tools. LangGraph offers more precise control over fixed flows, suitable for precise control of complex flows. The higher the level of encapsulation, the simpler the usage, but the lower the flexibility—this is the trade-off emphasized in the tutorial.

Deep Agent adds file system operations and sandbox backend capabilities on top of the LangChain Agent. A sandbox backend means file execution is isolated from the host environment and runs inside the sandbox. In addition, Deep Agent's Skill is essentially a high-level encapsulation based on LangChain's dynamic prompts, capable of describing step flows and ready to use once configured.

Sandbox isolation illustration

Sandbox backend is an isolated execution environment used to run untrusted code or file operations, preventing impact on the host system. In Deep Agent, the sandbox backend confines operations such as file read/write and code execution within an isolated container, separated from the host file system, thereby improving security. Sandboxes typically provide restricted resource access and network policies, and can be combined with checkpoints for state recovery. For Agent scenarios that need to handle user-uploaded files or execute generated code, sandbox isolation is a basic requirement for production deployment and an important capability that distinguishes Deep Agent from ordinary LangChain Agents.

How to Choose the Right Scenario

  • Deep Agent: Suitable for fast-delivery, quick-turnaround scenarios.
  • LangChain Agent: Suitable for custom Agents, combining models and tools, and handling non-flow tasks.
  • LangGraph: Suitable for complex flows that require precise control.

The tutorial also mentions the LangSmith tool, which can be used to trace, evaluate, and monitor the execution of Agents and Graphs, and also supports deploying Agents as APIs for web use.

Conclusion

LangGraph's positioning is a low-level orchestration engine that solves the problem of insufficient Agent control in fixed flows. Understanding its hierarchical relationship with LangChain and Deep Agent helps you choose the right tool for the scenario in actual development. For agent development that requires enterprise-grade flow control, LangGraph is a skill worth mastering.

One-line Summary

LangGraph is a low-level orchestration framework that solves the problem of insufficient control caused by context bloat when Agents handle fixed flows.

Paragraph Summary

Based on a Bilibili tutorial, this article outlines LangGraph's positioning, core capabilities, and its hierarchical relationship with LangChain and Deep Agent. The article points out that LangChain Agents rely on autonomous LLM decision-making, and when facing multi-step fixed flows, prompts become verbose and context bloats, easily leading to tool call errors or missed steps. LangGraph fixes the orchestration flow, delegating determinism to the framework while still allowing free combination of models and tools within each step. Its core capabilities include checkpoints, human intervention, conditional branching, parallel execution, fault-tolerant retries, and subgraphs. In terms of hierarchy, LangGraph is the low-level orchestration runtime, LangChain is built on top of it, and Deep Agent further encapsulates it and adds file system and sandbox capabilities. The higher the level of encapsulation, the simpler the usage but the lower the flexibility—choose according to the scenario.

#LangGraph#LangChain#Deep Agent#Agent orchestration#flow control#enterprise AI development
Share:

Related articles