How tool calling with LangChain tools works in NeMo Guardrails
A team that wants its model to call built-in, community or custom LangChain tools under guardrails needs to know how the pieces fit before writing any configuration. Tool calling is available from NeMo Guardrails 0.17.0, and the integration is built from two parts: the LangChain runnable wrapper, RunnableRails, and the tools integration that NVIDIA documents for NeMo Guardrails. It is not a separate connector. The LangChain integration is opt-in, so the environment variable NEMOGUARDRAILS_LLM_FRAMEWORK=langchain must be set before the application runs. Confirm that the deployed version is 0.17.0 or later and that the Python version meets the requirements of that release, since the current release line requires Python 3.11, 3.12 or 3.13.
When a model responds with tool calls, RunnableRails returns them to the calling application. NeMo Guardrails does not define its own tool-call schema. Instead, it converts each call into the shape of LangChain's ToolCall TypedDict, so existing LangChain code that reads tool calls can keep working. The tool rails sit in the execution path and check both the call and the tool result: the call is validated before the tool runs, and the result is validated before it returns to the model. Teams should decide which tools need a check on arguments, which results could carry sensitive or injected content, and whether a blocked call should stop the turn or return a refusal to the user.
Because the tool rails act on data that the model has not yet seen, their coverage depends on how the tools are registered and named. Built-in, community and custom tools each bring their own argument shapes and side effects, so each category needs a review of what the rail can actually inspect. Confirm with NVIDIA's NeMo Guardrails tools integration documentation which rail hooks apply to which tool types in your version, and test a blocked call and a blocked result in a staging environment before relying on the control in production.
Prerequisites for LangChain tool calling in NeMo Guardrails
Tool calling through RunnableRails depends on a specific NeMo Guardrails version, a supported Python runtime, the LangChain packages your tools import, and a model provider account. Each of these is a separate check, and they fail in different ways, so confirm them together before the build starts.
NeMo Guardrails 0.17.0 or later
Tool calling arrived in NeMo Guardrails 0.17.0, which supports built-in, community and custom LangChain tools. Pin this minimum or a later release in your requirements file. Earlier versions will not expose tool rails, so a team that inherited an older pin should plan the upgrade before writing tool rails. Check the version against the release notes for each upgrade you plan, since later releases change configuration and Python APIs.
Tools integration docsPython 3.11 to 3.13
The 0.25.0 release requires Python 3.11, 3.12 or 3.13, and it is the current release. If you pin an older NeMo Guardrails version, confirm its Python requirement separately before you build your base image. Mismatched interpreters are a common reason a container builds locally but fails in CI, so set the same minor version in every environment.
- Python for 0.25.0
- 3.11 to 3.13
LangChain packages for your tools
NeMo Guardrails enables LangChain only when you set NEMOGUARDRAILS_LLM_FRAMEWORK=langchain, and your built-in, community or custom tools import their own LangChain packages. List each package and its version in your lock file, including the community packages that provide your chosen tools. Tools that are not installed will fail at load time, not at the first request.
Model provider account and keys
RunnableRails calls the model that decides which tools to use, so you need an account with the provider and an API key scoped to that model. Confirm that the model supports tool calling in the LangChain integration you use, and that your account quota covers test traffic from rail evaluation. Store the key in your secrets manager and inject it at runtime rather than baking it into the image.
Network access from the guarded runtime
The process running RunnableRails must reach the model endpoint, and any internal API that a tool calls. Confirm egress rules, proxy settings and DNS for each host before testing, especially in private networks or air-gapped environments. A tool that cannot reach its API will return an error that looks like a model failure, so test connectivity from the same container and namespace that will run in production.
Secrets for tools that call internal APIs
Tools that call internal systems need credentials, such as service tokens or database users, that are separate from the model key. Give each tool the narrowest identity its job requires and load it from your secrets store. Ask the team that owns each internal API which scopes it issues, how it rotates them, and whether the tool's calls appear in its audit log.
Request flow for a tool call through guardrails
The flow starts with a user request entering the input rails in the guardrails runtime, which passes it to the model provider. The model proposes a tool call, which the tool rail checks before the LangChain tool runs against the tool's backend system. The tool result then passes through a rail before returning to the model, and output rails check the final answer before the user sees it. Trust boundaries are drawn around the application, the guardrails runtime, the model provider and the backend, so you can confirm where data leaves your control and which hand-offs need validation.
Tool call and result checks between the user, model, tool and backend.
What RunnableRails returns and what tool rails receive
NeMo Guardrails does not define its own tool-call schema. Instead, RunnableRails converts tool calls into LangChain's ToolCall TypedDict shape, so the response your application reads uses the same structure LangChain uses everywhere else. For application code, this means the parsing you already have for LangChain tool calls should carry over, but it still needs a test against a real response. Before you write parsing logic, confirm the exact fields your pinned LangChain version emits, such as the tool name, the arguments and the call identifier, and check them against the tools integration documentation linked from this page. Pin the LangChain version in your lockfile so a framework upgrade does not silently change the shape your code depends on.
Custom rail logic is where this matters most. A tool rail that allows or blocks a call has to read the tool name and its arguments from the same ToolCall structure, so a rail written against one field name will fail quietly if the field is absent or named differently. Plan a small set of fixture tests with representative calls for each tool your application exposes, including calls with missing or unexpected arguments, and run them whenever LangChain or NeMo Guardrails changes. Also decide how your rail behaves when it cannot read a field: failing closed, blocking the call and logging the reason, is usually the safer default for tools that write data or reach internal systems. Confirm the rail names and flows for tool input and tool output checks in the documentation rather than relying on examples from older versions.
Mapping tool call fields to the checks that act on them
This table maps each part of a LangChain tool call and its result to the rail that checks it, the decision that rail can make, and the owner who approves the allowed values. Read it as a checklist for each tool you expose to the model. Confirm the field names against the LangChain version you install before you write any rule, because the shape can change between releases.
| Field or check | Decision the rail can make | Owner who approves allowed values |
|---|---|---|
| Tool name (name) | Allow, block or route the call to a tool on the approved list | Application owner with security sign-off |
| Arguments (args) | Reject values outside schema limits, ranges or permitted paths before execution | Owner of the tool that receives the arguments |
| Call identifier (id) | Match each result to its originating call and reject mismatched or repeated IDs | Platform engineering team |
| Tool result | Block or redact sensitive data or instructions before the model reads the output | Data protection or security team |
| Built-in tools | Apply rails to a fixed set of names shipped with the library | Platform team, after confirming the library version |
| Community tools | Wrap calls with argument and result checks because the code comes from outside your organization | Security review board, before first use |
| Custom tools | Enforce argument and result checks in your own action code with full control of outcomes | Internal team that owns the tool and its data |
Setting up tool calling with LangChain tools in NeMo Guardrails
This sequence takes a LangChain application from a pinned NeMo Guardrails version to a working tool-calling chain, with a tool rail that validates calls and results and a logged check at each stage.
Pin NeMo Guardrails at 0.17.0 or later
The engineer responsible for the application sets the nemoguardrails package to version 0.17.0 or later in the project's dependency file and installs it into a Python environment running 3.11, 3.12 or 3.13, which are the versions the current 0.25.0 release supports. Tool calling is available from 0.17.0, so earlier pins will not support this pattern. Confirm the installed version by running pip show nemoguardrails and checking that the reported version is at or above 0.17.0. If you plan to move to the current release, check the upgrade notes first, since 0.25.0 deprecates the LLMRails class in favor of Guardrails.
Enable the LangChain framework opt-in
Set the environment variable NEMOGUARDRAILS_LLM_FRAMEWORK to langchain in the runtime where the application starts, such as the shell, the process manager or the container definition. The LangChain integration is opt-in, so without this variable RunnableRails and the LangChain tool path are not active. Confirm it is set by printing the variable in the same environment that runs the application and by confirming the LangChain packages your chain uses import cleanly in that environment. Record the setting in your deployment configuration so it survives container rebuilds.
Register built-in, community and custom tools
Define the tools the model may call as LangChain tools, using built-in tools, community tools from the LangChain ecosystem, or your own functions decorated as tools. Each tool needs a clear name, a description the model can read, and typed arguments, because NeMo Guardrails does not define its own tool-call schema and relies on LangChain's shapes. Limit the list to tools the application actually needs, and document who owns each one. Confirm registration by invoking each tool once directly with test arguments and checking that it returns the expected output before it is exposed to the model.
Wrap the chain with RunnableRails
Build the chain that binds the tools to the model, then wrap it with RunnableRails, passing the guardrails configuration folder that holds config.yml and any Colang files. The wrapped object is called like any other LangChain runnable, so existing invoke calls continue to work. Confirm the wrap by running one request with a prompt that does not need a tool and checking that a normal response returns. Note that the configuration folder must be readable from the process that loads it, which matters in containers.
Write the tool rail in the configuration
Add a rail that runs on tool calls and tool results in config.yml and, where needed, a Python action or Colang flow that decides whether a call is allowed. Name the tool and its arguments the rule checks, such as an allowlist of tool names, argument ranges, or a block on results that contain sensitive fields. Keep the decision logic in an action your security team can review and test. Confirm the rail is referenced in the configuration so it runs, since an unreferenced rail does nothing.
Confirm the configuration loads
Start the application or run a short script that loads the guardrails configuration and builds the wrapped chain, then check the startup output for errors about missing actions, unknown rail names or Colang parse problems. Fix each error before continuing, because a configuration that fails to load should stop the deployment, not fall back silently. Repeat the load after every change to config.yml or the Colang files. A clean load with no warnings about the tool rail is the check that closes this step.
Run a tool call and inspect its shape
Send a prompt that should trigger one of the registered tools and print the returned response. RunnableRails converts tool calls into LangChain's ToolCall TypedDict shape, so the output should contain the tool name, the arguments and an identifier for each call. Confirm this shape matches what your downstream code reads. Then send a prompt that should be blocked by the tool rail and confirm the call is refused and that the log entry records the tool name and the reason the rail gave. This pair of runs is the acceptance check for the sequence.
Built-in, community and custom tools need different controls
Built-in LangChain tools ship with the LangChain packages your application already depends on, so the team's main job is keeping that dependency current and predictable. The code is maintained upstream, but your organization still decides which version runs, which tools are exposed to the model, and what those tools can reach on your network.
- Version pinning: Pin the LangChain packages in your lock file and record the version used in each release, so a tool behavior change arrives through a planned upgrade rather than a routine rebuild.
- Tool exposure: Register only the built-in tools the use case needs. A tool that is loaded but not needed still gives the model a path to call it.
- Network reach: Confirm which hosts each tool contacts from your runtime, and restrict egress to those hosts at the network layer.
- Credentials: Give built-in tools only the scoped credentials they need, and keep them in your secrets store, not in configuration files.
- Rail checks: Validate the arguments the model proposes for each tool call, and validate returned results before they reach the model, using the tool rails in your configuration.
Before release, test each exposed tool with valid, malformed and out-of-scope arguments, and confirm the rail blocks the calls you intend to block.
Community tools come from third-party packages that your team did not write and may not maintain. They can carry transitive dependencies, unreviewed network calls and behavior that changes between releases. Treat them as third-party code entering your production path, with the review obligations that implies.
- Version pinning: Pin the exact package version and its dependencies, and review changelogs before each upgrade rather than accepting the latest release.
- Code review: Read the tool's source for outbound calls, file access, shell execution and logging of arguments, and record who approved it.
- Credentials: Do not pass your organization's broad credentials into a community tool. Issue a separate, narrowly scoped credential and rotate it on a schedule.
- Network reach: Run the tool in a context that can reach only the endpoints it needs, and watch for unexpected destinations during testing.
- Rail checks: Treat the tool's results as untrusted input. Use output-side tool rails to inspect returned content for instructions aimed at the model before the model reads it.
Before release, confirm the package source and version, run the tool against a test environment with monitored egress, and check that the rail catches injected instructions in returned content.
Custom tools are written by your organization and call your internal systems, so the controls are the ones your own engineering and security processes already apply, plus the rail design. Ownership is complete: your team sets the authorization model, the error handling and the logging. The risk is usually in what the tool is allowed to do, not in the framework that calls it.
- Authorization: Enforce the user's permissions inside the tool itself, not only in the prompt. The model should never be the component that decides whether a call is allowed.
- Code review: Apply the same review and testing standards as other internal services, with particular attention to write operations and parameter handling.
- Credentials: Use service identities with least privilege, and avoid giving a custom tool access to systems beyond the operation it performs.
- Network reach: Limit the tool to the internal APIs it calls, and document each dependency so network policy stays aligned with the code.
- Rail checks: Validate tool arguments against the expected schema and business limits, and check results for data that the current user should not see.
Before release, write tests for denied and permitted calls per user role, and confirm that a blocked call produces a log entry your security team can review.
Securing tool calling with LangChain tools in production
Tool calls turn a model's output into actions against your systems, so each control below limits what a call can reach, what it can send and what the model gets back. Together they define the boundary a tool rail enforces and the evidence you keep about it.
Least-privilege credentials per tool
Give each LangChain tool its own service account or API token with only the scopes that tool needs. A shared administrative key behind several tools means one injected prompt can reach every system those tools touch. Check that a read-only search tool cannot call a write endpoint, by testing the credential directly against the upstream API rather than trusting the tool wrapper to restrict it.
Allow lists for tool names
Permit only the tool names your use case requires and reject any call that names a tool outside that list, including tools that exist in the same process. Tools imported from community packages often bring extra functions along, so review what each one exposes. Verify the list by sending a call for an unlisted tool and confirming the rail blocks it before the tool runs.
Allow lists for argument values
Constrain arguments as well as names. Define permitted values, ranges, path prefixes or record identifiers for each argument, and reject anything outside them, such as a file path that escapes an approved directory or a query without a required tenant filter. Test with adversarial arguments that a model could produce after reading injected content.
Validation of tool results
Inspect what a tool returns before it is added to the model context. Tool output can carry instructions from a web page, a ticket or a document, so apply output checks for injection patterns, oversized responses and fields that must never reach the model, such as personal data outside the user's entitlement. Confirm in testing that a blocked result never appears in the next model prompt.
Secrets kept out of tool configuration
Keep API keys and connection strings in a secrets manager or environment injection at runtime, not in config.yml, Colang files or Python tool definitions that get committed to source control. Confirm that log output, tracing and error messages do not echo credential values or full request headers. Scan your configuration folder and container image for hard-coded values as part of the release check.
Logging of blocked and allowed calls
Record each tool call with the tool name, a sanitized argument summary, the rail decision, the reason code and the time, and record each returned result's decision as well. Keep raw arguments and results out of general logs when they contain personal data, and set retention to match your policy. Verify the log by running one allowed and one blocked call and confirming both appear with the decision recorded.
Testing tool rails before the model sees results
Test the tool rails through the same chain that serves production traffic, so a passing result describes the deployed path. Build the harness around the production RunnableRails wrapper, the same config.yml, Colang files, LangChain tool bindings and the NEMOGUARDRAILS_LLM_FRAMEWORK=langchain setting. Cover four cases. The first is an allowed call to a tool on your approved list. The second is a call naming a tool that is not registered. The third is an argument outside the range the tool accepts. The fourth is a tool result containing instructions aimed at the model, such as text telling it to ignore earlier rules. The sample inputs for these cases are illustrative only. Your tools and policies set the expected outcome for each one, and that outcome should be written down before the first run.
For each case, record the tool call exactly as the chain returns it. NeMo Guardrails does not define its own tool-call schema, so RunnableRails converts calls into LangChain's ToolCall TypedDict shape. Capture the fields of that shape, including name and args, together with the rail decision and the final message the model received. Store each case as a fixture with its expected outcome. Pin the nemoguardrails and LangChain package versions in the test environment and log them with every run. Tool calling has been available since NeMo Guardrails 0.17.0, so a baseline run on your current version becomes the reference. After any LangChain or NeMo Guardrails upgrade, including a move to 0.25.0 or later, rerun the full set and diff the records against the baseline. Treat every changed field as a finding to review before the upgrade goes live.
Give the security reviewer a package they can check against the source, not a live demo. It should include the test matrix with expected and observed outcomes for each case, the commit hash of the rail configuration, the version pins, the raw ToolCall records and the final model input for each case, and the date and name of the person who ran the tests. The key evidence is that poisoned tool results never reached the model in their original form and that disallowed tool names produced no execution. Point the reviewer to the NeMo Guardrails tools integration documentation so they can compare expected behavior with the source. Confirm the evidence format your reviewer accepts, and agree the pass criteria before the first run so the results cannot be adjusted afterward.
Common failures when tool calls go through NeMo Guardrails
This table lists the failures teams most often hit when LangChain tool calls pass through NeMo Guardrails, with the likely cause, the check to run and the fix for each. Work through the rows in order, since the opt-in and version checks rule out the most common causes before you debug the tool or the rail logic.
| Failure | Likely cause | Check to run | Fix |
|---|---|---|---|
| Tool calls are not routed through the rails | The LangChain opt-in was not set, so the integration is not active in the process that runs the guardrails | Confirm NEMOGUARDRAILS_LLM_FRAMEWORK=langchain is set in the same environment as the application or server container | Set the NEMOGUARDRAILS_LLM_FRAMEWORK variable to langchain in the runtime environment and restart the process |
| Tool calling is missing or unsupported | NeMo Guardrails is older than 0.17.0, the first release with tool calling support | Run pip show nemoguardrails and compare the installed version with 0.17.0 | Upgrade to a current release, then review the upgrade notes for configuration changes before redeploying |
| Install or import fails on Python | The interpreter is outside the range 0.25.0 supports (Python 3.11, 3.12 or 3.13) | Run python --version in the environment that builds and runs the application | Create the virtual environment or container image with a supported Python version and reinstall |
| Tool runs, then the answer is blocked or empty | A tool rail rejected the tool result, and the application expected the raw result to continue | Review the rail log for the blocked tool result and confirm which rail fired on the execution path | Handle the blocked outcome in the calling code, or adjust the rail so the result is transformed rather than dropped |
| Tool call fails at execution | Tool arguments do not match the shape the tool or rail expects, such as a missing field or a different type | Compare the arguments in the ToolCall object with the tool's input schema and with the rail's expected fields | Align the tool schema and rail logic, and validate arguments before execution with a clear error message |
| Tool fails with an authentication error | The tool's backend needs a credential that is missing from the container or process environment | Check that the key the tool reads is set in the runtime environment, not only in a local shell | Add the credential through your secret store and inject it at runtime, then verify with a test call to the backend |
What tool calling with LangChain tools costs and requires
What makes tool calling with LangChain tools cost more or less?
The main drivers are the number of tools, how much custom tool code you own, the depth of security review, how much test coverage you need, and how many model providers sit behind the application. Each tool adds its own schema, permissions, input validation and result checks, so a small set of built-in tools is far less work than many custom tools that call internal APIs. Every additional model provider adds a configuration path to verify, because tool call behavior can differ between providers. Ask any partner to price these five items separately in a written scope so you can see which ones you can reduce.
Does the number of tools change how long the work takes?
Yes, the count of tools and their complexity are usually the largest factors in duration, along with the environment they run in. Built-in and community LangChain tools need configuration and rail design, while custom tools need code review, permission design and tests for both tool calls and tool results. Duration also depends on how quickly your teams can give access to test systems, approve rail behavior and review findings. Ask for a timeline tied to a named tool inventory and to the environments you control, not to a generic estimate.
What does our team need to supply before tool calling work starts?
Plan to supply four inputs before any build work begins:
- A tool inventory listing each LangChain tool, whether it is built-in, community or custom, and what systems it reaches
- API credentials for each tool's backend, issued to test environments with least-privilege scopes
- Named approval owners who decide which tool calls and results are allowed, blocked or need review
- Test data and sample conversations that reflect real workflows, including known misuse cases
Missing any of these typically moves work into waiting time rather than engineering time, so confirm owners and access early.
Who owns the decisions about which tool calls are allowed?
Your organization owns those decisions, and a partner implements them. Business owners should decide which actions a tool may take, under what conditions, and which results may reach the model. Security and compliance teams should review permission boundaries and logging. Engineers then encode those decisions in rail configuration and tests. If approval owners are unavailable, the build stalls at the point where rules must be chosen, so name a decision-maker for each tool category before the engagement is scoped.
Can an internal team implement tool calling with NeMo Guardrails alone?
An internal team with Python and LangChain experience can build a working prototype, and the library is open source under the Apache 2.0 license with a release of NeMo Guardrails 0.17.0 or later providing tool calling support. The harder part for most teams is the review work: writing tests for blocked and allowed calls, validating tool results, documenting permissions and producing evidence for security reviewers. Teams that lack capacity for that review, or that run many custom tools against internal APIs, often bring in a partner for the security review and test coverage while keeping implementation in-house. Decide which part you can staff before you choose the model.
Which runtime requirements must we confirm before starting?
Confirm the Python version and the NeMo Guardrails version you plan to use. NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, and it is published on PyPI under the Apache-2.0 license. LangChain integration is opt-in and is enabled with the NEMOGUARDRAILS_LLM_FRAMEWORK=langchain environment variable, so include that in your deployment configuration. Also confirm that the NeMo Guardrails microservice is not your target, since NVIDIA has sunset it, and check the NeMo Guardrails release notes for version-specific changes to tool handling before you pin a version.
Which compliance and security evidence should we expect the work to produce?
Ask for documented tool permissions, rail configuration in version control, test results for blocked and allowed tool calls, logs that show what the model received, and a record of who approved each rule. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports, attestations or certifications; independent auditors and certification bodies do that work. Confirm with your assessor which artifacts they expect before scoping, because the evidence list drives test coverage and documentation effort.
How DeployOpen scopes and delivers this integration
DeployOpen plans, implements, tests, documents and supports self-hosted open-source platforms inside the client's own infrastructure, and this integration follows the same arc. We agree the scope in writing before work starts, then build and verify tool rails against the tools your agents actually call.
How we scope
- Inventory which built-in, community and custom LangChain tools your agents call and which need validation rails
- Confirm the NeMo Guardrails version and Python runtime, including whether your team needs the 0.17.0 tool calling baseline
- Define which tool calls and tool results are validated before the model sees them, and which are only logged
- Agree deliverables, timelines and exclusions in writing, with ongoing support available as a retainer
How we build
- Set up the LangChain opt-in with NEMOGUARDRAILS_LLM_FRAMEWORK=langchain in your containers or environments
- Wrap the chain with RunnableRails and map tool call output to the LangChain ToolCall shape your code expects
- Write tool rails for call arguments and tool results, with custom actions isolated from model-facing prompts
- Test each rail against allowed and blocked tool calls, including malformed arguments and unexpected tool results
How we hand over
- Document the rail configuration, Colang and Python action files, and the tool inventory they cover
- Provide runbooks for adding a new tool, changing a rail, and reviewing a blocked tool call
- Deliver a test suite and retest results that your engineers can rerun after each change
- Walk your platform and security teams through the configuration so they can review it independently
How we support
- Plan upgrades across NeMo Guardrails releases, including configuration and Python API changes to review
- Track dependency and Python version changes that affect the LangChain integration and the tool rails
- Offer retainers for ongoing upgrades, continuous testing of tool rails and updates when new tools are added
- Retest tool rails after any change to tool permissions, model providers or the guardrails server

