Why teams build a custom NeMo Guardrails rail
Building an internal guardrail as a reusable NeMo Guardrails rail starts with a library licensed under Apache 2.0, and the current release is 0.25.0. Several assistants often need the same organization-specific check, such as a policy lookup or a data classification test. When each team copies that check into its own config.yml and Python actions, the copies drift. One team fixes a bug, another changes a threshold, and no one can say which version runs where. Before packaging anything, confirm that the check already works as a plain Python action in one configuration. The work described here centers on packaging and reuse, and it does not involve training or building new detection models. The check logic stays the same. What changes is how it is shipped, named and enabled.
A one-off custom action is a Python function that one configuration calls from its flows. A reusable rail wraps that action with the flows that invoke it and a manifest that declares what the rail needs, so another configuration can enable it by name instead of copying files. The distinction matters most for ownership. A reusable rail needs a named owner, a version number, documented inputs and outputs, and tests that run whenever the rail changes. Decide early how the rail reports its decision. Every consuming flow should read allow, block or transform results the same way. The sibling section on RailOutcome covers that contract in detail, so settle it before other teams depend on the rail.
Package a rail when at least two configurations need the same check, when the check depends on internal data or services that should be configured in one place, or when a security reviewer needs to see one controlled version of the logic. Leave a check that only one assistant uses as a one-off action. Before you start, ask the owners of the internal lookup or classification service what access the rail needs, who approves changes to the policy data, and how results must be logged. Confirm that your target Python version is supported, since NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13 according to its GitHub repository.
How the action, flows, manifest and config.yml fit together
The path starts in a team's config.yml, which lists the rail by name. The platform team's manifest maps that name to flows and a Python action, and Colang flows call the action when a request reaches the rail. Application teams own the config entry and the thresholds it passes in, while the platform team owns the manifest, the action code and its tests. Check that every name resolves to exactly one manifest entry before a configuration ships.
Application teams enable a named rail, while the platform team owns its manifest and code.
What a packaged rail contains
A reusable rail is a set of files that must travel together. Each part below has a specific job, and a missing part usually fails quietly: the rail either does not load, loads under the wrong name, or runs without anyone noticing it stopped checking anything.
Python action and parameters
The action holds the organization-specific check itself, such as a call to an internal classifier or a policy lookup. Its parameters are where thresholds, endpoints and tenant identifiers belong, so the same code can be configured per team. If the action is missing or its signature drifts from what the flows pass in, the flow fails at runtime instead of at load time, so check the signature in your tests.
NeMo Guardrails docsColang flows that consume the result
The flows decide what happens when the action reports a problem: block the message, replace it with a fixed response, or pass it on. They are the only part that turns a check into a behavior users see. If the flows are absent, the action still runs and produces a result that nothing acts on, which is the most common silent failure in a custom rail.
Manifest with name and version
The manifest declares the rail's name, version and the files that belong to it. Teams enable the rail by that name, so the name is effectively a public interface. Without a manifest, each team copies files by hand, and two teams can end up running different versions of the same check under one label. Confirm the version format your release process will use before the first publish.
Config fragment teams include
The config fragment is the snippet a team adds to its config.yml to turn the rail on, along with any parameter values it needs. It is the only part most application teams will touch. If the fragment assumes a model or action name the team has not defined, the configuration will load with the rail silently absent, so ask the platform owner to provide a minimal working example.
Tests for the check and the flow
Tests should cover two things: the action returns the expected decision on known inputs, and the flow reacts correctly to each decision. Testing only the Python function misses broken Colang wiring. Keep a fixed set of allowed and disallowed examples in the repository so a change to a prompt, model or version can be compared against the same baseline.
Documentation for the owning team
The documentation names the team that owns the rail, the decisions it makes, the parameters, the known false positives and the upgrade path. Without it, the rail outlives the people who built it, and no one outside the original team can tell whether a block is a defect or intended behavior. Review it at every version change, since it is the document auditors and new consumers will read first.
Steps to package an internal check as a rail
This sequence turns an organization's own check into a named NeMo Guardrails rail that any approved configuration can enable. Each step ends with a check you can run, so a failure is caught before the rail reaches a shared package or a production server.
Confirm the Python version and install target
The platform engineer who owns the build environment confirms that the runtime is Python 3.11, 3.12 or 3.13, since NeMo Guardrails 0.25.0 requires one of these versions. Install the library from PyPI into an isolated virtual environment pinned to the release you plan to target, and record that version in the package metadata. The step is done when the interpreter reports a supported version and
pip show nemoguardrailsreturns the expected release. If the version is outside that range, stop here and resolve the runtime before writing any code.Write and unit-test the action outside the server
A developer writes the organization-specific check as a plain Python action with clear inputs and a defined return value, such as a classification or a decision on the content. Tests run the function directly with representative allowed and disallowed samples, including edge cases and empty input, without starting a guardrails server or calling a model. Keep external calls behind parameters so tests can substitute a stub. The step is done when the test suite passes locally and the action can be imported and called from a plain Python session without errors.
Define the Colang flows that call the action
The developer who knows the conversation design writes Colang flows that decide when the rail runs and what happens with its result. Input, output or execution rail placement is decided here, along with the message the user sees when the check blocks content. Flow names should reflect the check so other teams can recognize them. Confirm the Colang version with the team's configuration standard, because Colang 1.0 is the default and 2.0 is also supported. The step is done when the flows parse without errors and a dry run shows the flow reaching the action call.
Write the manifest for the rail
The rail owner writes a manifest file that names the rail, identifies the action and flows it includes, lists required parameters, and states the minimum NeMo Guardrails version and Python range. The manifest is what lets a team enable the rail by name without reading its source. Keep parameter names aligned with the action signature so configuration errors surface early. The step is done when a reviewer who did not write the rail can read the manifest and list every file and parameter it depends on.
Add the configuration fragment
A configuration owner adds a fragment to the
config.ymlfile that references the rail by its manifest name and supplies the parameters for the target environment. Keep environment-specific values, such as endpoints or thresholds, outside the shared fragment and pass them in through the configuration folder. The step is done when NeMo Guardrails loads the configuration without warnings about unknown rails or missing parameters, and the rail appears in the loaded configuration output.Run the rail against a local server or the Python API
The developer runs the configuration either through the Python API or by starting a guardrails server that loads the configuration folder and exposes its HTTP API. Send a fixed set of allowed and disallowed test messages and compare each response with the expected decision. Review the logs to confirm the action was invoked and returned the expected outcome. The step is done when every test message produces the expected allow, block or transform result. If the server is used, the Dockerfile supplied with the project can build an image for the same configuration.
Publish the rail to a shared package or repository
The platform team publishes the action, flows, manifest and tests to a shared package index or internal Git repository, with a version number and a changelog entry. Require the test suite to pass in the publishing pipeline and record the NeMo Guardrails version it was verified against. Confirm with your security and governance team who may approve changes to a shared rail, because other teams will inherit its decisions. The step is done when another team can install the pinned version, enable the rail by name, and pass the same test messages in its own environment.
Choosing how the rail is delivered and loaded
A shared Python package is the most controlled option. The rail's action, flows and manifest live in one versioned project that each service installs as a dependency and loads within its own guardrails configuration. It suits teams that already ship Python services and want the check to behave the same way in each of them.
- Fits when: several Python services in one stack need the same check and each service already has a release process.
- Who maintains it: the platform or security team owns the package, and each application team controls when it updates its pinned version.
- Upgrades: a version bump is explicit and reviewable, but services adopt it on their own schedules, so versions can drift apart.
- Rollback: pin the previous version in each service. Rollback means a dependency change and a redeploy of every consumer.
- Dependency weight: the package brings NeMo Guardrails and its dependencies into every consumer, and each service must run one of the supported Python versions, 3.11, 3.12 or 3.13.
Confirm in the 0.25.0 documentation how a package registers its rail so that teams can enable it by name, and whether that discovery works from an installed package.
The guardrails server loads configurations from a folder, so the rail files can be mounted into that configuration directory and enabled by name from config.yml. This model puts one copy of the rail under central control, which suits organizations where the platform team runs the server and application teams only choose which rails to enable.
- Fits when: the team runs the guardrails server container and wants one change to reach every configuration that references the rail.
- Who maintains it: the platform team owns the mounted folder, and configuration owners enable rails without editing the code.
- Upgrades: replacing the mounted files changes every configuration that loads them, which is fast but affects all consumers at once. Mounting a staged folder per environment limits that blast radius.
- Rollback: keep the folder in version control so the previous state is one checkout away, then reload the server.
- Failure scope: a malformed file can break every configuration that loads the folder, so validate the files in the pipeline before they are mounted.
Confirm the manifest file name, the expected folder layout, and whether the server reloads on file change or needs a restart, using the 0.25.0 documentation.
Running the rail on the actions server moves its Python action out of the guardrails process. The action can then hold its own credentials and network access, which keeps those away from the guardrails host. This fits checks that call internal systems, such as a classification service or a data loss prevention API, where the security team wants that access isolated.
- Fits when: the check needs credentials or network reach that the guardrails host should not hold.
- Who maintains it: security or platform engineering runs the actions server, and the action code has one owner with its own tests.
- Upgrades: the action can change without redeploying the guardrails server, but the flow and action contract must still match across versions.
- Rollback: redeploy the previous action revision, then confirm that flows calling it still match the earlier parameters and return values.
- Operating cost: the actions server is one more service to size, monitor, secure and keep available. Decide in advance whether a failed call blocks the request or lets it pass.
Confirm how the 0.25.0 release starts and registers an actions server, and check the setup against the NeMo Guardrails documentation rather than the retired microservice.
How teams enable a rail by name across configurations
A team enables a reusable rail by listing its flow name under the matching key in its own config.yml, such as rails.input.flows, and making the rail's action and Colang files available to that configuration folder. The rail's code stays the same in every configuration, so the per-team differences belong in the configuration. Thresholds, allowed categories, endpoint URLs and other parameters should arrive through the configuration, either as values the action reads from config.py or as arguments the flow passes through. A customer-facing assistant and an internal assistant can then run the same check with different strictness without two copies of the rail. Confirm how your chosen version passes parameters to actions before you write the first flow, because that decides where secrets and per-team values live.
The rail type decides where the check runs, and the position in the configuration decides when it runs relative to other rails. Input rails inspect the user message before any model call, output rails inspect the generated response, execution rails wrap custom actions and tool calls, and dialog rails steer the conversation flow. A check that screens personal data in a prompt belongs in the input list, while a check that confirms a response does not expose internal identifiers belongs in the output list. Put the wrong type on a check and it either runs too late to protect the model call or runs on content it cannot evaluate. Write down the type and the expected order in the rail's README so every team that enables it places it the same way.
The manifest should record the rail's version, the NeMo Guardrails version it was tested against and the Python versions it supports. NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, and teams should pin the library version in their deployment rather than accept whatever installs next. Pinning the rail version in the manifest lets a team keep an older rail while a new one is tested in staging, and a changed rail version should trigger the same regression tests as a library upgrade. Because the manifest is a convention your team defines, not a file NeMo Guardrails reads, make it part of the review process for each configuration. Check the NeMo Guardrails releases page before each pin change.
Security risks in shared guardrail code
A reusable rail runs inside every assistant that enables it, so one weak action, secret or default can reach many teams at once. The cards below cover the risks that matter most when an internal check is packaged as a shared rail, with a mitigation and a check for each.
Shared code reaches internal systems
A custom action runs Python with whatever network routes, service accounts and file access its host process has. Because the rail is shared, any assistant that enables it inherits that reach, not only the team that wrote it. Run the action under a dedicated service identity with read access only to what the check needs, and confirm which internal hosts it can reach from the runtime where the actions execute. Review the action's imports and outbound calls in code review before each release.
NeMo Guardrails docsSecrets passed through parameters
Credentials for a scanning API or internal classifier often end up in the rail's config.yml or in a parameter that is logged with the flow. Keep secrets in environment variables or your secrets manager, and let the action read them at runtime. Confirm that the rail's manifest and example configurations contain no keys, and that the server logs do not echo action parameters.
Check fails open
If the backend a rail calls is unreachable, a rail that returns allow by default lets unchecked content through without any visible error. Decide per rail whether a failed call should block, route to human review or allow, and write that decision into the action's error path. Test the behavior by pointing the action at an unreachable address and confirming that the outcome matches the policy you documented.
Logging of blocked user content
Debug logging that records the full user message from blocked requests creates a store of sensitive prompts, personal data and possibly attack payloads. Log the rail name, outcome and a request identifier by default, and capture content only under a controlled debug setting with a stated retention period. Ask your logging team where NeMo Guardrails output goes and who can read it before the rail goes live.
One change reaches every assistant
Because a shared rail is enabled by name across configurations, a bad edit to its flow or action changes behavior for every assistant at once. Version the rail in Git, tag releases, and pin each configuration to a specific version rather than a moving branch. Roll out a new version to one assistant first and compare its block and allow results with the previous version before wider enablement.
Untested edge cases
Shared rails usually get tested on the examples that prompted them, which leaves empty inputs, very long messages, non-English text, and inputs that try to alter the flow untested. Write unit tests for the action with these cases and with adversarial examples, and run them in continuous integration on every change. Record which cases each release has passed so reviewers can see the coverage without reading the test code.
Questions teams ask before building a reusable rail
How much more effort is a reusable rail than a one-off custom action?
A reusable rail usually takes noticeably more effort than a one-off action, because the action is only the first piece. A one-off action is a Python function called from one configuration. A reusable rail adds a stable action interface, flows that call it, a manifest that declares its name and parameters, defaults that work across configurations, and tests that prove it behaves the same wherever it is enabled. Ask any partner to split the estimate into these parts so you can see which ones your team already covers.
What drives the effort of building a reusable rail?
Four factors drive most of the effort:
- How clearly the check is defined, since vague policy turns into rework in code and flows.
- How many configurations will enable the rail, and how different their settings are.
- Whether the check calls internal systems, which adds credentials, network paths and failure handling.
- How much evidence the rail must produce, such as logged decisions and retest records.
Each one raises cost when it is unresolved at the start, so settle them in writing before the build.
What skills does an internal team need to build a reusable rail?
The team needs working Python for the action and its tests, working Colang for the flows that call the action, and someone who owns the configuration files and the platform the rail runs on. The Colang skill matters more than many teams expect, because the flows decide how a block or transform reaches the user. Confirm that the people who will maintain the rail after release, not only the people who build it, have these skills.
Can an internal team build and maintain a reusable rail alone?
An internal team can build a reusable rail alone if it has the Python, Colang and platform skills described above and enough capacity to test and document it. Many teams find the harder part is ongoing ownership: someone must review the rail after each NeMo Guardrails release and after each change to the internal system it calls. Decide before the build who owns that work. DeployOpen can take the build as a fixed-scope engagement, or provide ongoing support and upgrades on a retainer, and you can also keep it fully in-house.
How long does it take to build a reusable rail?
No timeline is supplied for this work, so confirm the duration with your own team or with any partner against a written scope. The main drivers are the same as the effort drivers: how well the policy is defined, how many configurations depend on the rail, how many internal systems it touches, and how much testing and documentation your review process requires. A rail with a narrow check and one configuration moves much faster than one that must serve several teams with different settings.
How should we version and upgrade a reusable rail across the LLMRails deprecation?
Pin the NeMo Guardrails version your rail was tested against, and record it in the manifest. NeMo Guardrails 0.25.0 deprecates the LLMRails class in favor of Guardrails, with removal planned no earlier than 0.27.0, and NVIDIA publishes a 0.25 migration guide. Plan to move any code that instantiates LLMRails to the new class during a scheduled upgrade, rerun the rail's tests on each version, and version the rail itself so teams can see which combinations were verified. Also check the Colang migration guide if your configurations use Colang 1.0, since NVIDIA says converted configurations still need manual review.
What does DeployOpen's fixed-scope engagement cover for a reusable rail?
DeployOpen agrees the scope, deliverables and timeline for a reusable rail in writing before work starts. A typical written scope lists the check to be packaged, the action, flows, manifest and tests to be delivered, the configurations that will enable the rail, the deployment target and the handover to your team. DeployOpen plans, implements, documents and supports self-hosted open-source platforms in your own infrastructure, and offers ongoing support, upgrades and continuous testing as retainers. A quote follows from the written scope, and DeployOpen does not publish a price list.
Limits to confirm in your environment
A reusable rail depends on several release-specific behaviors that change between NeMo Guardrails versions and deployment paths. Each card names one behavior to confirm with the documentation or a test environment before your teams depend on the rail.
Manifest and registration behavior
Confirm that the manifest format and the way a rail is registered and enabled by name work the same way in the release you choose. Load a test configuration that references the rail by name, then check that the flow and action are picked up without manual edits. Treat any difference between the documentation and observed behavior as a blocker until it is understood.
- Current release
- 0.25.0
Colang 1.0 versus 2.x flows
Colang 1.0 is the default, and Colang 2.0 is also supported, so a flow written for one may not behave the same under the other. Confirm which version your configuration declares and test the rail under that version. If you need to move between them, the convert tool output still needs manual review.
Colang 2 migration guideRail outcome handling
Check how your version returns allow, block and transform outcomes from a custom action and how the calling flow reads them. Outcome handling is the part of the rail most likely to differ between releases. Write one test case per outcome and confirm that a transform rewrites content in the path you expect.
Guardrails server and image
Confirm that the configuration folder your rail ships in loads the same way through the guardrails server and the Docker image you build, not only through the Python API. Differences in file paths, installed packages or Python version can break a rail that works locally. Pin the image tag and test the rail against it.
- Supported Python
- 3.11 to 3.13
Opt-in LangChain integration
LangChain integration is opt-in and is enabled with an environment variable. If your rail depends on LangChain classes, confirm that the variable is set in every environment where the rail runs, including the server container. Without it, a rail that calls LangChain components can fail in ways that look like model errors.
NeMo Helix relevance
The NeMo Platform repository now points to NeMo Helix, which runs NeMo Guardrails as an inference gateway plugin. Decide whether your deployment path uses the library, the server, or a control plane, and confirm whether your rail works in that path. Ask NVIDIA or your account team how the sunset of the microservice affects existing deployments.
NeMo Helix repositoryTesting and running a shared rail in production
Treat the shared rail as a product with its own test suite, release process and named owner before any team enables it. The first layer is unit tests for the Python action: call the function directly with sample inputs, cover the parameters injected from config.py, and assert on the returned outcome, including the allow, block and transform paths. These tests run without a model and without a running server, so they can gate every change in continuous integration. The second layer is flow tests. Keep a file of sample conversations that cover the cases the rail must catch, the cases it must let through, and the edge cases your policy owners have agreed on. Run each through the configuration that enables the rail by name and check that the bot responds as specified. Confirm the expected result with your policy owner, not only with the engineer who wrote the action.
Regression runs matter most when something outside the rail changes. Rerun the full unit and flow suites whenever the rail code changes, whenever a configuration that enables it changes, and whenever you move to a different NeMo Guardrails release. 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, so pin the version in your lockfile and read the 0.25 migration guide before upgrading. Keep a record of which library version passed which suite. For production, watch the rail's blocked and transformed outcomes as a metric, not only as log lines. A sudden rise or fall in blocks usually signals a change in traffic, a prompt change or a regression, and each event should be traceable to the rail name and the configuration that produced it.
Assign a single accountable owner for the rail after handover, typically a platform or security engineering team, with a named policy owner who decides what the check should block. Write down who may approve changes, who may enable the rail in a new configuration, and who responds when outcomes shift. Require every change to go through a pull request that includes the test results, a note on any change to outcomes, and a sign-off from the policy owner. Ask your delivery partner, or confirm internally, how long vendor support and handover documentation will cover the rail and what the process is for retiring it.
How DeployOpen scopes and delivers a reusable rail
DeployOpen approaches building an internal guardrail as a reusable NeMo Guardrails rail as a fixed-scope engagement. We agree in writing what the rail checks, how teams enable it by name, and how it is tested and handed over before build work starts, so your security and platform teams know what they are receiving.
How we scope
- Agree in writing which organization-specific check the rail performs and which decisions it returns
- Define the manifest fields, flow names and configuration keys teams will use to enable the rail
- Confirm the target NeMo Guardrails version and Python 3.11, 3.12 or 3.13 runtime in your environment
- Record which models, safety services and internal systems the rail calls, and who owns each
How we build
- Implement the custom action and rail flows in a package layout your teams can version and install
- Wire the rail into sample configurations so it is enabled by name without copying code
- Test the rail with unit tests and with representative allow, block and transform cases
- Document each configuration option, failure behavior and dependency in the package
How we hand over
- Deliver the package, source repository, test suite and a written guide for platform and application teams
- Walk your engineers through enabling the rail, reading its decisions and adding a new configuration
- Provide a checklist for upgrading the rail when NeMo Guardrails releases change configuration or action interfaces
- Record the evidence your compliance team can review, such as test results and decision logs
How we support
- Support updates to the rail after handover under a retainer, where ongoing support is agreed in writing
- Retest the rail after NeMo Guardrails upgrades, including version changes to Colang and Python APIs
- Confirm with your team which support channel, response expectations and access model apply before the engagement starts
- Scope follow-on work such as a security test of the rail as a separate written engagement

