LangGraph in Practice: Wrapping an Agent in a Workflow and Keeping Audit Outside the Model
Ajitesh Shukla shared a LangGraph architecture for a P2P agent: the outer layer is a deterministic workflow, the inner layer is a growable agent core, and rule validation and independent review sit outside the model. For developers and general readers, this case explains when to use a workflow and when to leave room for an agent.
Harrison Chase reshared Ajitesh Shukla's tweet, discussing one question: LangGraph workflow, or deep agent? Ajitesh's answer is: use a workflow on the outside, an agent on the inside, and let the inner layer keep growing.
The context is their work on a procure-to-pay (P2P) agent on @LangChain. The P2P process has explicit review requirements, and not every step can be left to the model to improvise. They cite Anthropic's “Building effective agents”: use a workflow when the task is clearly defined, and add agency when flexibility is needed; LangGraph can put deterministic steps and agent steps in the same graph, making a complete agent an ordinary node in the graph.
Their approach can be broken down into four layers.
1/ Deterministic shell
Load context → agent core → exit validation → write back. This part is ordinary code and runs the same way every time. For P2P operations, there is only one auditable path.
2/ An agent core behind one interface
AgentCore.run(context) -> Resolution. Today it may just be a create_agent loop, with known steps and a small context. As cases become more complex—for example, multiple invoices, disputes, needing to ask another team—create_deep_agent can be plugged in with the same tools and skills. The interface stays the same, while the internals can change.
3/ Guarantees in code, not in the prompt
Prompt rules are probabilistic. Rule checks and independent review run in the shell, outside the model, so no matter how the core plans, it cannot bypass these checks.
4/ Make steps into skills, not graph nodes
When a new scenario arrives, add a new skill; there is no need to redesign the entire graph. That way the graph does not spiral out of control as business scenarios multiply.
The reverse pattern also exists: some teams put the agent on the outside and treat a locked-down workflow as a tool for high-risk actions such as refunds. Which layer goes on the outside depends on risk. For Ajitesh's team, every case must go through the same audit, so the deterministic part goes on the outside.
Their rule of thumb is straightforward: if you can draw a flowchart, it is a workflow. Put the agent where you cannot draw a flowchart, and put guarantees where the agent cannot reach them.
For AI practitioners, the value of this case lies in layering: auditability on the outside, flexibility on the inside. For general readers, it also clarifies a boundary for putting agents into production: the model can be responsible for judgment, but key constraints are best left to code.
Original tweet: https://x.com/hwchase17/status/2122119023446130879
发布时间: 2026-11-16 09:27