Skip to content

What is LangChain? When to Use LangGraph

Published Updated

LangChain is an open-source framework for building applications with large language models (LLMs) in Python and JavaScript. Use it when you want standard components for retrieval or a simple tool-using agent. Choose LangGraph when you need to control which step runs next or save a workflow’s progress so it can resume later.

What LangChain is

LangChain connects a model to the information and tools an application needs. Its model interface gives developers a common way to call supported providers. Provider-specific features can still require different settings. Prompts hold the instructions and provide places to fill in information from the current request.

Retrievers fetch relevant passages or records, which your application can send to the model with a question. That is the basis of retrieval-augmented generation. A chain runs steps in a sequence your code defines, such as retrieving a policy and passing it to the model for a draft answer. Tools are functions exposed to the model. An agent can decide which tool to request and when it has enough information to answer.

LangSmith is a separate service that captures traces of model requests and tool calls so developers can see where a run went wrong. It also runs evaluations against saved examples so teams can compare changes to prompts, models or code.

What LangGraph Adds

LangGraph is an open-source library for running stateful, multi-step agents and workflows as graphs. A node is a step you write, such as looking up the status of a request. An edge connects steps and can choose a path based on the result. A checkpointer stores the workflow’s state under a thread ID so the run can continue from a saved point.

An interrupt pauses the graph until someone supplies a decision. A retry policy can run a failed node again after a temporary error. For example, an internal service request can wait for a manager’s approval and then resume under the same thread ID. If a subsequent read-only lookup times out, the graph can retry it. A resumed node can run its opening code again, so make writes safe to repeat or put them after the approval step in a separate node.

LangChain vs LangGraph

Use LangChain for retrieval, fixed chains and agents that need a standard loop for calling tools. Use LangGraph directly when your workflow has several branches, needs to survive a long wait or passes work between agents. The choice is about how much of the execution you need to define.

What you’re deciding LangChain LangGraph
Who controls the next step? Your code sequences a chain, or the standard agent loop lets the model request a tool. You define the graph’s nodes and routing. You can use a model’s decision as an input to the routing.
How much state do you need? Use the built-in agent interface and configure persistence if the agent needs it. Define what the workflow carries forward, when it pauses and how it recovers.
What can you reuse? Reuse standard model and retrieval interfaces. Expose tools through the same agent interface. Use LangChain components inside individual steps or call the provider directly.

LangChain’s current agent API runs on LangGraph. A LangChain agent can therefore use persistence and human approval without your team defining every node. Start with the built-in agent if it expresses the workflow you need. Work directly with LangGraph when the application needs explicit control over branches, approvals or handoffs between agents.

In a hypothetical policy assistant, a fixed sequence retrieves relevant documents, passes them to a model and returns an answer with references. LangChain’s retrieval and model interfaces cover those steps.

In a hypothetical onboarding workflow, a check can send a case back for missing documents or pause for approval before another agent prepares the account. LangGraph can record each decision and resume the same case when the missing item arrives. For a fuller guide to building an AI agent, start by deciding which actions the model can choose.

When LangChain is the Wrong Tool

Call the provider’s software development kit (SDK) directly when your app needs one prompt or one predictable tool call. Your own code can validate the result and handle the error. A direct call is also worth measuring when you have a tight response-time budget. Compare end-to-end timings using the same model and prompt so you can distinguish framework overhead from model or network delays.

LangChain adds interfaces between your code and the provider. Debugging a tool call can mean following the request through your code, the framework and a provider integration before you reach the raw model response. The framework and its integrations ship updates separately. Pin them together and read the release notes before changing any of them.

Other options include CrewAI and Pydantic AI. Teams using Semantic Kernel can also consider its successor, Microsoft Agent Framework. The AI agent frameworks comparison covers how those choices differ.

Running LangChain Applications in Production

Run the application with a named engineering owner and a business owner for the workflow. Set up deployment, secrets and monitoring before real requests arrive. Use a separate environment for testing with its own credentials and load production secrets from a secrets manager.

Where the Application, Model and Traces Run

You can run the application and its checkpoint database in an Australian cloud region. Choose the model deployment separately. Microsoft lists GPT-4.1 mini for Azure OpenAI Standard/Regional deployment in Australia East. Amazon Bedrock lists a Claude Haiku model with an Australia inference profile that can route between Sydney and Melbourne.

Select a regional deployment or Australia profile explicitly if prompts must stay in Australia. A model listed under a global deployment in an Australian region can still process requests overseas.

Traces are a separate data flow. LangSmith Cloud has a GCP APAC region in Sydney for trace and application data. Self-hosted LangSmith is an Enterprise add-on if you need to run it in your own infrastructure. The model endpoint, checkpoint database and tracing service each need their own location and access controls.

What to Review After Launch

The engineering owner reviews failed runs, latency and spend by workflow. The business owner reviews sampled answers, incorrect actions and cases referred to staff. Use AI observability to spot which step caused a slow or expensive request. Give the team a cost alert and a way to disable a faulty tool without taking the whole application offline.

Commit a dependency lockfile and record the deployed model version. Test upgrades in a separate environment with a fixed set of real examples that have appropriate data controls. For a graph, check that a paused run can resume after deployment and that a retry leaves a single record. Keep the last working release available if answers or tool behaviour degrade.

When Traces Contain Personal Information

If the Privacy Act 1988 applies to your organisation, assess whether sending prompts or tool outputs to a tracing service is a permitted use or disclosure. The Office of the Australian Information Commissioner (OAIC) distinguishes use within your effective control from disclosure outside it. Australian Privacy Principle (APP) 6 governs whether the use or disclosure is permitted. For an overseas disclosure, APP 8 generally requires reasonable steps to ensure the recipient handles the information in line with the applicable principles. OAIC guidance on commercial AI products

Keep raw prompts out of traces by default and record request IDs or timings where they meet the debugging need. If you need payloads, mask personal information before export and set who can see traces and when they expire. Before you enable tracing in production, send a test request containing dummy personal information and check that it stays out of the exported trace.