Guarding LangGraph agents with NeMo Guardrails: what the integration does
If your team runs multi-agent LangGraph workflows that call models and tools, the supported way to put NeMo Guardrails between those agents and the model is the RunnableRails interface wrapped around graph nodes, with optional tool rails that validate tool calls and tool results. The integration needs the LangChain opt-in, set with NEMOGUARDRAILS_LLM_FRAMEWORK=langchain, plus the matching langchain-* packages for your model provider. Since NeMo Guardrails 0.22.0, a plain pip install nemoguardrails no longer brings in LangChain, so this dependency is a deliberate step your build must include. The LangGraph integration guide is the primary reference for the wrapping pattern, per-agent configuration and tool rails, and you should work from it rather than from examples copied from other projects.
The integration is a control layer, not a design for your agents. It does not decide which agent should hand off to which, how state is shared across the graph, or whether an agent should be allowed to take an action at all. Those choices remain in your LangGraph design. Rails also do not replace authorization inside the tools themselves: a tool that calls an internal API must still check the caller's identity and permissions, because a rail that misreads a tool call will fail open in ways the tool cannot catch. Treat each tool's own access checks as the authoritative control and the rails as an additional filter.
Plan a review step for the rail logic itself. Colang flows, Python actions and the config.yml settings for each agent are code, and they need the same review, version control and tests as the graph. Confirm with your own engineers which rails each agent actually loads, how a blocked tool call surfaces in the graph state, and what your team will do when a rail produces an unexpected refusal. Those answers determine whether the integration is ready for your workflows, and they are the questions to put to any implementation partner before scope is agreed.
What you need before guarding a LangGraph agent
Guarding a LangGraph agent depends on five components that have to line up before any rail runs: the workflow, the NeMo Guardrails version, the LangChain opt-in, the model endpoint for each agent, and the deployment target. Confirm each one in your own environment first, because a missing package or a wrong Python version fails at startup rather than during a review.
A LangGraph workflow to wrap
Start with the graph you intend to guard. Identify each node that calls a model, each node that executes a tool, and the state keys that pass between them, because those are the points where RunnableRails and tool rails attach. A graph with one model node and two tools needs a different plan than a supervisor pattern with several specialist agents. Write the node map down before you write any configuration.
LangGraph guideNeMo Guardrails 0.25.0 on supported Python
The current release is 0.25.0, and it requires Python 3.11, 3.12 or 3.13. Pin the version in your lock file so that a routine dependency update does not change rail behavior. If you are still on an older release, plan the upgrade as a separate change with its own test run, since configuration and API details may move between versions.
PyPI packageLangChain opt-in and matching packages
Since 0.22.0, a plain pip install nemoguardrails no longer brings LangChain. Teams upgrading older setups must set NEMOGUARDRAILS_LLM_FRAMEWORK=langchain and install the langchain-* packages that match their LangGraph version. Confirm exact package names and version pins against the LangGraph integration guide and your own lock files, since a mismatch surfaces as an import error at runtime.
A model endpoint for each agent
Each agent in the graph may call a different model, and each needs an endpoint, credentials and a rail configuration that points at it. List the provider, the engine name and the secret that holds the key for every agent. Shared or unauthenticated endpoints need their own review, because a guardrail configuration can only be as trustworthy as the model behind it.
A deployment target you control
The NeMo Guardrails microservice has been sunset, with no new releases after October 1, 2026, so do not build a new plan around it. Choose between embedding the library in your LangGraph service or running the guardrails server from a folder of configurations. Record where the secrets, logs and container images will live, because these choices determine who can review the setup later.
NGC container noticeA test set for blocked and allowed calls
Before enabling rails, assemble prompts and tool requests that should pass, and others that should be blocked, including tool arguments that point to restricted resources. Without this set, you cannot tell whether a rail blocks too much or too little. Keep the set in version control so that each upgrade of the framework or the models is rerun against the same cases.
How a guarded request moves through a LangGraph graph
The diagram starts at the user message entering a wrapped LangGraph node, where NeMo Guardrails runs input rails before the model endpoint is called. Tool calls the model requests pass through tool rails before the external tool executes, and tool results pass back through tool rails before the model sees them. Output rails then check the response before it returns to the graph. This is a simplified, illustrative flow, so confirm the exact hook points against the LangGraph integration guide for your version.
Simplified illustrative flow of one agent turn across the trust boundaries.
Setting up guarded LangGraph agents, step by step
This sequence takes a LangGraph multi-agent workflow from a bare environment to a graph where every agent node runs under its own guardrail configuration and every tool call and tool result passes through validation. Each step ends with a check you can run before moving on.
Pin the environment and enable the LangChain opt-in
Your platform engineer creates a clean Python environment on a supported interpreter. NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, so confirm the version first. Install nemoguardrails alongside the langchain-* and langgraph packages your graph imports, and pin every version in a lock file so the agents do not drift during testing. Since NeMo Guardrails 0.22.0, the base install no longer brings in LangChain, so the opt-in must be set explicitly by exporting NEMOGUARDRAILS_LLM_FRAMEWORK=langchain in the runtime. Done means a short script imports the LangGraph and NeMo Guardrails modules without errors and prints the framework setting it reads from the environment.
Write a config.yml and Colang files for each agent
Your AI engineers create one configuration folder per agent role, such as a planner, a research agent and a responder. Each folder holds a config.yml that names the main model and the rails that agent needs, plus Colang files that define the input, dialog and output behavior for that role. Keep the folders separate so a permissive research agent does not inherit the strict rules of a customer-facing one. Colang 1.0 is the default, and Colang 2.0 is also supported, so record which version each folder uses. Done means each folder loads on its own with the nemoguardrails CLI or Python API and reports its rails without warnings.
Load each configuration as a named rail set
Your engineers load every configuration folder with RailsConfig and build one guardrails object per agent. Keep a mapping from agent name to configuration so the wiring in the next step is explicit and reviewable. If a config cannot be loaded, the graph should fail at startup rather than run with no rails. Ask the vendor or check the documentation for the current loading interface in your pinned version, because the Python API has changed across releases. Done means a startup check lists each agent with its rail set, and a deliberately broken folder causes a startup error.
Wrap each graph node with RunnableRails
Your developers replace each LLM-calling node in the LangGraph workflow with a RunnableRails wrapper that points to that agent's configuration. The node keeps its existing state contract, so the rest of the graph does not change. Review each node to confirm it calls the wrapped runnable and not the raw model, since a single unwrapped call bypasses the rails for that step. Done means a trace or log for one run shows the input rails firing on each wrapped node, and a grep of the graph code finds no direct model calls outside the wrappers.
Add tool rails for tool calls and tool results
Your developers define the tool rails for each agent that calls tools. Input-side tool rails check the arguments the model proposes before the tool runs, and output-side tool rails check what the tool returns before the model or the next node reads it. Write the checks as Colang flows or Python actions, and keep the rules narrow, such as allowed tool names, argument patterns and maximum result handling. Confirm with your NeMo Guardrails version which tool rail hooks it provides. Done means a test tool that returns a planted instruction is blocked or sanitized before the next node receives it.
Test blocked inputs and validated tool results
Your QA or security engineers run the graph against a fixed set of test inputs. The set includes benign requests, a clear policy violation, a prompt injection string and a tool call with out-of-policy arguments. For each case, confirm the blocked input never reaches the model by checking model call logs or a counting stub. Confirm each tool result is validated before the next node reads it by inspecting state between nodes. Save the outputs as evidence. Done means every blocked case shows zero model calls after the rail fires, and every tool result passes through its output check first.
Run the full graph and record the results
Your team runs the complete multi-agent workflow end to end on the pinned environment, using the same test set and at least one run with each agent configuration in use. Record the rail decisions, model calls and tool results for each run, and compare them with the expected outcomes from the previous step. Any difference becomes a fix followed by a rerun of the full set. Ask your partner or your engineers to confirm that the lock file, configuration folders and test results are stored together under version control so a later upgrade can be tested against the same cases. Done means a clean run of the full test set against the locked versions, with results archived.
Giving each agent its own rail configuration
A single configuration loaded for every node gives you one place to define input rails, output rails and tool rails. Every agent in the graph runs the same policy, so a change to a topic rule or a content check takes effect across the whole workflow at once. The trade-off is that a rule written with a planner in mind can block a responder in ways nobody intended, and the graph has no per-agent boundary to contain that failure.
- What it isolates: very little. A fault or an overly broad rule in one agent's flow appears in every agent that shares the configuration.
- Maintenance cost: the lowest of the three options, with one set of Colang flows, custom actions and test cases to review.
- Tool permissions: one tool rail set applies to all agents, so a researcher that should only read can still reach write-capable tools unless the tools enforce their own access control.
- Review burden: security reviewers examine a single configuration, which simplifies evidence collection for an assessment.
Before you adopt this option, confirm with your own build whether configurations are loaded once per process or once per node, because that determines how a configuration change reaches running workers.
Giving each agent role its own configuration, such as a planner, a researcher and a responder, lets each agent carry only the rails that fit its job. The LangGraph guide documents wrapping individual graph nodes with their own rail configuration, which is the pattern this option relies on. Isolation improves because a policy change for the researcher does not alter the responder's behavior, though the teams that own each configuration must coordinate on any shared base rules.
- What it isolates: policy and tool scope per role, so a failure or a rule change stays within one agent.
- Maintenance cost: higher, because each role needs its own folder, flows, actions and tests. Shared rules are either duplicated or moved into a common base that every role imports.
- Tool permissions: each role's tool rails list only the tools that role may call. For example (illustrative), a researcher configuration might permit search and retrieval tools, while a responder configuration permits only message composition.
- Drift risk: as roles multiply, configurations can diverge in wording and coverage, so a periodic comparison of the rails across roles is worth scheduling.
Before you rely on this option, verify in your own environment how each role's configuration loads and caches, and confirm that a change to one role does not reload or affect the others.
In this option, the supervisor agent carries the full set of input, output and tool rails because it receives user requests and decides which worker runs next. Worker agents carry lighter configurations, usually limited to the checks that matter for the work they perform. This concentrates controls at the entry point and the routing decision, which is where most user-controlled text enters the graph. The risk is that workers see content produced by tools and other agents, and that content may carry instructions that a lighter configuration does not catch.
- What it isolates: the user-facing boundary and routing logic. Worker failures are contained, but the supervisor is the single point where checks must be complete.
- Maintenance cost: moderate. Two tiers of configuration need a documented list of which checks each worker omits and the reason for each omission.
- Tool permissions: the supervisor controls which worker runs, while each worker still calls its own tools. Keep tool result validation on workers that read external or user-supplied content.
- Injection exposure: a tool result read by a worker can try to steer later steps, so test whether injected text in a worker's output can change the supervisor's routing decision.
Before you choose this option, write down each omitted check and the review that approved omitting it, then test the supervisor against injected instructions that arrive through worker outputs.
Validating tool calls and tool results in LangGraph workflows
In a LangGraph multi-agent workflow, tool rails are the layer that checks what moves in and out of tools, and they matter more in a graph than in a single agent because one agent's output becomes the next agent's input. A tool call can carry arguments the model invented, such as an account identifier it never received from the user or a file path outside the expected directory. A tool result can carry injected instructions, for example text inside a retrieved document telling the next agent to ignore its policy. Either problem can travel silently through several nodes before anyone notices. The NeMo Guardrails LangGraph integration supports optional tool rails for this purpose, so the team should decide early whether each agent needs them and where they sit in the graph.
There are two checkpoints to design around. The first runs before a tool executes, where the guardrails inspect the proposed call and its arguments against an allowed-tools list and argument rules. The second runs after execution and before the model sees the result, where the guardrails inspect returned content for instructions or data that should not reach the next agent. For each agent, the team must decide which tools are allowed, which argument values are validated and against what (schema, value ranges, allowlists or a custom action), and what happens on a blocked call: return a refusal message to the model, route to a human reviewer, or stop the graph. Confirm in the current documentation exactly which tool rail names and configuration keys the release you deploy supports, since the rail configuration is version-specific.
Treat tool rails as one control, not the whole authorization model. The integration validates messages, but it does not replace the tools' own authorization and input handling. Each tool should still enforce its permissions against the calling identity, validate its inputs on the server side, and apply least privilege to the credentials it holds, because a rail that passes an argument does not prove the caller may act on that record. Ask your team to test the failure paths directly: a call to a disallowed tool, an argument outside the expected range, and a tool result containing an instruction. Confirm that each produces the decision you designed, and that the blocked event is logged with enough context to review later.
Mapping agents, nodes, configurations and tools to rails
This table maps each part of a LangGraph multi-agent design to its NeMo Guardrails counterpart, with what each mapping controls, who should own it, and the evidence to keep. Use it as a checklist when you design the rails, then confirm field-level names against the documentation for the version you pin, since the LangGraph integration and its configuration keys can change between releases.
| Design element | What the mapping controls | Owner | Evidence to keep |
|---|---|---|---|
| Graph node | A node that calls a model is wrapped with RunnableRails so input and output rails run around that call. Unwrapped nodes bypass the rails entirely. | Platform engineering with the agent developer | Node inventory listing each wrapped and unwrapped node, reviewed at each graph change |
| Agent role | Each agent role maps to its own rail configuration directory, so policies can differ between a research agent and a payments agent. | Security architect for policy, agent owner for role scope | Versioned config directory per role and a diff log of rail changes |
| Tool | Each tool gets a tool rail that validates calls before execution and results before the model reads them, plus a permission that limits which roles may call it. | Security engineering for permissions, tool owner for behavior | Tool-to-role permission matrix and test cases for blocked and allowed calls |
| Model endpoint | Engine settings such as the engine name, model name and endpoint decide which model the rails and the agent talk to. Safety models may use a different engine from the main model. | Platform engineering | Config files pinned to a version and a record of which endpoints each role can reach |
| State key (messages) | The rails inspect the messages passed into the wrapped node, so the state keys that carry user text, tool output and retrieved content determine what is checked. | Agent developer, confirmed by security | Written list of state keys read by rails and tests showing each key is inspected |
| Opt-in and packages | The LangChain opt-in environment variable and matching langchain packages must be present in the runtime image, or the integration will not load. | Platform engineering | Container build manifest and a startup check that confirms the framework setting |
| Version pin | The NeMo Guardrails and LangChain versions decide which wrapper signatures, configuration fields and migration steps apply. | Platform engineering | Lock file, upgrade notes and release review for each pinned version |
Security settings and hardening for guarded agents
A guarded LangGraph agent is only as safe as the settings around it. The cards below cover the configuration, permission, logging and release decisions that sit around the rails, and they should be reviewed together rather than one at a time. None of them is a substitute for testing the rails themselves, and the rails do not stop all prompt injection on their own.
Keep endpoint keys out of config
Model and safety endpoint keys belong in environment variables or your secrets manager, not in config.yml, Colang files or custom actions that get committed to version control. Each agent's rail configuration often names its own model and safety endpoints, so the same key can end up copied into several folders. Check that no configuration folder contains a literal key, and that the keys the container receives are scoped to the endpoints that agent actually calls.
Least-privilege tools per agent
Give each LangGraph node only the tools its role needs, and declare the tool rails for that node's configuration so a tool outside its list is refused. A research agent that reads documents should not hold a tool that sends email. Review the tool list for each agent as a separate permission set, because the graph as a whole can reach any tool that any node holds.
Restrict write-capable tools
Limit tools that create, update or delete records to specific agents, and require a human approval step or a narrower validation action before those calls run. Tool rails validate a call against rules you write, so a write tool should have stricter rules than a read tool. Ask your team to confirm which nodes can reach each write tool and to test that a read-only agent cannot invoke one through prompt manipulation.
Log decisions without sensitive content
Record which rail blocked or allowed each call, the agent and node involved, and the tool name, but avoid storing full prompts, retrieved documents or tool outputs unless a documented need exists. Set a retention period for these logs and restrict who can read them. Confirm with your security and privacy teams which fields may leave the application, and test that a blocked request still produces a useful audit entry.
Pin library versions
Pin the nemoguardrails version, the matching langchain-* packages and the LangGraph version in your lock file, and promote upgrades through a test environment. The current release is 0.25.0, which requires Python 3.11, 3.12 or 3.13, and it deprecates the LLMRails class in favor of Guardrails. Read the upgrade notes before moving a pinned version, and rerun your rail tests after each change.
Review rail configurations as code
Store config.yml, Colang files and custom actions in Git and require peer review, tests and an approval step before a change reaches production. Colang changes can alter which messages reach a model, so a small edit can weaken a rail without any visible error. Converted configurations also need manual review, so treat any migration as a full code change with its own review record.
Common failures when guarding LangGraph agents
This table lists the failure points teams most often hit when adding NeMo Guardrails to LangGraph agents, with the cause of each and the fix to apply. Read it before the first integration test, and again when a rail appears to do nothing or a graph stops mid-run.
| Failure | Cause | Fix |
|---|---|---|
| Integration does not load | The NEMOGUARDRAILS_LLM_FRAMEWORK=langchain variable is not set in the process or container that runs the graph, so the LangChain path is never enabled. | Set NEMOGUARDRAILS_LLM_FRAMEWORK=langchain in the same environment as the graph, then restart the process and confirm the variable is present inside the container. |
| Import or runtime errors with LangChain or LangGraph | The langchain-* packages were installed at versions that do not match the installed LangChain or LangGraph core packages. | Pin the langchain-* packages to versions that work with your LangChain and LangGraph versions, and check the NeMo Guardrails LangGraph guide for the packages it expects. |
| LangChain missing after a plain install | Since 0.22.0, pip install nemoguardrails no longer installs LangChain, so a fresh environment has no LangChain for the graph to use. | Install LangChain, LangGraph and the matching langchain-* packages explicitly alongside nemoguardrails, and record them in your lock file. |
| Install fails or the library will not import on 0.25.0 | NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, and the agent runtime or base image runs an older or newer interpreter. | Confirm the interpreter version in the build image and in local development before installing, and move the runtime to a supported version. |
| One agent applies another agent's rails | All nodes load a single shared rail configuration, or the wrapper for one agent points at the config folder used by another. | Give each agent its own configuration folder and wrap each graph node with RunnableRails using that node's config. Test each agent with a input that another agent's rails would block. |
| Tool rails never fire | The tool result does not arrive in the message shape the tool rail expects, so the check passes without inspecting the content. | Log the exact message objects the tool node returns, match the structure the tool rail reads, and add a test that feeds a known-bad tool result and confirms it is blocked. |
| Graph state breaks after a block | A blocked message is returned as a refusal in a shape the graph's state reducer or downstream node does not handle, so the run stops or loops. | Define the refusal message format in the graph state schema, route blocked outputs to a handler node, and test a blocked run through every conditional edge. |
Questions teams ask before guarding LangGraph agents
How much effort does guarding a LangGraph agent with NeMo Guardrails take?
Effort depends mostly on the shape of the graph, not on the rail library itself. The main drivers are the number of agents, each of which may need its own rail configuration, the number of tools whose calls and results need validation, any custom actions your rails call, which safety models you run and how much test coverage you need. Each added agent adds a configuration to design and test, and each tool adds a validation decision. Ask any partner for a written scope that lists agents, tools, actions, models and test cases individually, since that list is what a fair estimate is built from.
Can our in-house team guard LangGraph agents without outside help?
Yes, if your team already runs Python services and LangGraph workflows and can own the rail logic over time. The NeMo Guardrails LangGraph guide covers wrapping nodes with RunnableRails, per-agent configurations and tool rails, so the work is learnable. Outside help usually adds the most value on the parts that are easy to get wrong: setting the LangChain opt-in correctly in every container, designing rails that do not block legitimate tool use, and building a test set that exposes bypasses. Many teams split the work, building the first configuration in-house and bringing in a partner for review and adversarial testing.
What do we need to provide before the integration work starts?
Three things make the work start cleanly. First, a running LangGraph workflow that you can run in a non-production environment, including the nodes, agents and tools in use. Second, a test set of prompts and tool scenarios, covering normal requests, edge cases and attempts to misuse tools, with the expected outcome for each. Third, a named owner who can approve rail changes, since every change to a configuration affects what an agent may do. Without the owner, rail decisions stall and tests drift from actual policy.
How long does a guarded LangGraph build take?
Duration depends on scope, so no fixed figure applies to every build. A workflow with one agent and a few read-only tools is a smaller job than a multi-agent graph with write-capable tools, custom actions and a safety model served from your own infrastructure. Timing also depends on how quickly your owner can review rail decisions and how many test rounds the findings require. Ask for a timeline tied to the written scope, with milestones for configuration design, tool rail validation, testing and handover, so you can see which dependency is driving the schedule.
Is the LangChain opt-in a permanent setting?
No. The LangChain integration is opt-in and is enabled with the environment variable NEMOGUARDRAILS_LLM_FRAMEWORK=langchain, together with the matching langchain-* packages. Since NeMo Guardrails 0.22.0, a plain install of the library no longer brings in LangChain, so the setting belongs in the deployment configuration of each service that uses LangGraph. Treat it as part of the runtime definition: set it in every container image or deployment manifest that runs guarded nodes, and confirm the packages match your LangChain version during each upgrade.
How do NeMo Guardrails upgrades affect Colang and our configurations?
Upgrades can change Colang and configuration files, so plan each one as a change with its own test run. Colang 1.0 is the default, and Colang 2.0 is also supported. NVIDIA documents a migration path from Colang 1.0 to 2.x using the nemoguardrails convert tool, and states that converted configurations still need manual review. Before upgrading, pin your current version, run your test set against the new release, review converted flows, and check that tool rails still block and allow the same scenarios. Confirm the current release notes and the migration guide for your target version before scheduling the change.
Does the NeMo Guardrails microservice retirement affect this integration?
The integration described here runs the open-source library inside your LangGraph services, so it does not depend on the NeMo Guardrails microservice. NVIDIA has said the microservice was sunset as of October 1, 2026, and that existing NeMo Microservices users should contact their NVIDIA account team. Confirm which deployment model you plan to use and check the current NVIDIA guidance for any container or licensing question before you commit. The library is licensed under Apache 2.0, and your licensing review should cover the packages you install with it.
How DeployOpen scopes and delivers guarded LangGraph agents
DeployOpen plans, builds, tests, documents and supports NeMo Guardrails around LangGraph agents inside infrastructure you control. Each engagement starts with a written scope that names the graph nodes, agents, tools and rail configurations involved before any build work begins.
How we scope
- Map each LangGraph node and agent that needs a guardrail configuration, and record which ones share rails and which need their own.
- List every tool the agents call and every tool result that returns to a model, so tool rails cover the agreed paths.
- Confirm the LangChain opt-in, the langchain-* packages and the Python versions your runtime supports before the build starts.
How we build
- Wrap the agreed graph nodes with RunnableRails and keep each agent's configuration in its own folder under version control.
- Add tool rails for tool calls and tool results, and keep custom actions separate from the model calls they guard.
- Run the agents against the chosen model endpoints and safety models in your environment, with configuration changes tracked in Git.
How we hand over
- Deliver test results for each agent's rails, including blocked and allowed tool calls, with the steps needed to reproduce them.
- Document the configuration layout, the opt-in settings, the package pins and the runbook for changing a rail safely.
- Walk your engineering and security teams through the configuration, the test suite and the open items agreed in the scope.
How we support
- Review NeMo Guardrails release notes and the LangChain packages for changes that affect your configurations before you upgrade.
- Retest the agreed agent paths after each upgrade, and record the results alongside the configuration history.
- Ongoing support, upgrades and continuous testing are available as retainers, scoped in writing like the original engagement.

