feat: add UiPathByoGuardrailMiddleware (BYOG) [AL-512] - #1013
Merged
Conversation
This was referenced Jul 29, 2026
Merged
apetraru-uipath
commented
Jul 29, 2026
apetraru-uipath
commented
Jul 29, 2026
apetraru-uipath
commented
Jul 29, 2026
apetraru-uipath
commented
Jul 29, 2026
There was a problem hiding this comment.
Pull request overview
Adds “Bring Your Own Guardrail (BYOG)” support to uipath-langchain guardrails via a new middleware (UiPathByoGuardrailMiddleware) that references an admin-defined BYOG configuration (validator name + optional connection id) and evaluates it through the existing built-in middleware wiring.
Changes:
- Introduces
UiPathByoGuardrailMiddlewareand exports it from the guardrails public API. - Refactors built-in guardrail middlewares to use a shared
BUILT_IN_VALIDATOR_GUARDRAIL_TYPEconstant (typedLiteral) forguardrail_type. - Adds a full sample project and documentation section for BYOG, plus a dedicated unit test suite for the new middleware.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/uipath_langchain/guardrails/middlewares/byo.py |
New BYOG middleware building a BuiltInValidatorGuardrail with validator_type="byo" and BYO reference fields. |
tests/guardrails/middlewares/test_byo.py |
Unit tests covering construction, validation, hook wiring, and evaluation forwarding for BYOG middleware. |
src/uipath_langchain/guardrails/middlewares/_base.py |
Adds BUILT_IN_VALIDATOR_GUARDRAIL_TYPE constant typed as Literal["builtInValidator"]. |
src/uipath_langchain/guardrails/middlewares/{harmful_content,pii_detection,llm_as_judge,intellectual_property,prompt_injection,user_prompt_attacks}.py |
Switches guardrail_type from a raw string literal to the shared constant. |
src/uipath_langchain/guardrails/middlewares/__init__.py |
Exports UiPathByoGuardrailMiddleware. |
src/uipath_langchain/guardrails/__init__.py |
Re-exports UiPathByoGuardrailMiddleware from the top-level guardrails package. |
docs/guardrails.md |
Adds BYOG section + updates the middleware table and samples list. |
samples/README.md |
Links the new BYOG sample. |
samples/joke-agent-bring-your-own-guardrail/* |
New runnable sample project demonstrating BYOG middleware usage + bindings. |
apetraru-uipath
force-pushed
the
feat/byog-middleware
branch
from
July 29, 2026 11:25
ad0be88 to
021ec6d
Compare
apetraru-uipath
added a commit
that referenced
this pull request
Jul 29, 2026
…parameters Bring the decorator-flavor sample and docs in line with the middleware PR (#1013): - Replace tenant-specific values with placeholders following the bring-your-own-model convention: validator name `my-harmful-content-guardrail`, connection `my-byog-guardrail-connection`, and the public `uipath-azure-contentsafety-guardrails` connector key in bindings.json. - Document `ByoValidator(parameters=...)`: a "Tuning the validator" section in the sample README plus a commented-out Azure Content Safety `harmful_content` example in graph.py, stressing that parameter ids and types are defined by the guardrail connector rather than by this SDK. - Drop the EnableByoGuardrails feature-flag prerequisite from user-facing docs (internal knowledge) and genericize vendor-specific wording. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
apetraru-uipath
added a commit
that referenced
this pull request
Jul 29, 2026
Decorator-flavor Bring Your Own Guardrail support, pairing with the ByoValidator shipped in uipath (UiPath/uipath-python#1833): - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim via a guarded getattr, so the package keeps importing (ByoValidator is None) on uipath releases that predate it. TODO in-code: switch to a direct import once the dependency floor includes it. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open). This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, feature flag off) visible. - Tests: adapter error-logging tests (always run) + ByoValidator-through- @guardrail tests (tool / plain function / validator reuse) that skip automatically until the installed uipath ships ByoValidator; verified passing locally against the uipath-python ByoValidator branch. - Docs: BYOG section under the decorator pattern in docs/guardrails.md, using placeholder validator/connection values and documenting the connector-defined `parameters` passthrough. - Sample: samples/joke-agent-byog-decorator starter (agent-factory AGENT scope + tool TOOL scope, bindings.json connection binding), with a commented-out Azure Content Safety `parameters` example. Bump to 0.14.18 (0.14.17 was taken by #1012 and is published on PyPI). Independent of the middleware-flavor PR (#1013); branched from main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath
added a commit
that referenced
this pull request
Jul 29, 2026
Decorator-flavor Bring Your Own Guardrail support, pairing with the ByoValidator shipped in uipath (UiPath/uipath-python#1833): - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim via a guarded getattr, so the package keeps importing (ByoValidator is None) on uipath releases that predate it. TODO in-code: switch to a direct import once the dependency floor includes it. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open). This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, feature flag off) visible. - Tests: adapter error-logging tests (always run) + ByoValidator-through- @guardrail tests (tool / plain function / validator reuse) that skip automatically until the installed uipath ships ByoValidator; verified passing locally against the uipath-python ByoValidator branch. - Docs: BYOG section under the decorator pattern in docs/guardrails.md, using placeholder validator/connection values and documenting the connector-defined `parameters` passthrough. - Sample: samples/joke-agent-byog-decorator starter (agent-factory AGENT scope + tool TOOL scope, bindings.json connection binding), with a commented-out Azure Content Safety `parameters` example. - Discovery: docs and sample point at `uip agent guardrails byo-configurations` (UiPath/cli#3298) rather than the raw agents_/api/designer/byog-guardrails endpoint, and note that the command needs an org-admin user session. Bump to 0.14.18 (0.14.17 was taken by #1012 and is published on PyPI). Independent of the middleware-flavor PR (#1013); branched from main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath
force-pushed
the
feat/byog-middleware
branch
from
July 30, 2026 09:01
021ec6d to
78ee08c
Compare
apetraru-uipath
added a commit
that referenced
this pull request
Jul 30, 2026
Decorator-flavor Bring Your Own Guardrail support, pairing with the ByoValidator shipped in uipath (UiPath/uipath-python#1833): - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim via a guarded getattr, so the package keeps importing (ByoValidator is None) on uipath releases that predate it. TODO in-code: switch to a direct import once the dependency floor includes it. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open). This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible. - Tests: adapter error-logging tests (always run) + ByoValidator-through- @guardrail tests (tool / plain function / validator reuse) that skip automatically until the installed uipath ships ByoValidator; verified passing locally against the uipath-python ByoValidator branch. - Docs: BYOG section under the decorator pattern in docs/guardrails.md, using placeholder validator/connection values and documenting the connector-defined `parameters` passthrough. - Sample: samples/joke-agent-byog-decorator starter (agent-factory AGENT scope + tool TOOL scope, bindings.json connection binding), with a commented-out Azure Content Safety `parameters` example. - Discovery: docs and sample point at `uip agent guardrails list` for the validator name, connection id and the connector-defined `Parameters` schema, rather than the raw agents_/api/designer/byog-guardrails endpoint. - Scopes/stages: BYOG validators are not scope- or stage-restricted, so the developer chooses; here the scope is inferred from each decorated target. Bump to 0.14.18 (0.14.17 was taken by #1012 and is published on PyPI). Independent of the middleware-flavor PR (#1013); branched from main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
valentinabojan
approved these changes
Jul 30, 2026
apetraru-uipath
added a commit
that referenced
this pull request
Jul 30, 2026
Decorator-flavor Bring Your Own Guardrail support, pairing with the ByoValidator shipped in uipath (UiPath/uipath-python#1833): - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim via a guarded getattr, so the package keeps importing (ByoValidator is None) on uipath releases that predate it. TODO in-code: switch to a direct import once the dependency floor includes it. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open). This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible. - Tests: adapter error-logging tests (always run) + ByoValidator-through- @guardrail tests (tool / plain function / validator reuse) that skip automatically until the installed uipath ships ByoValidator; verified passing locally against the uipath-python ByoValidator branch. - Docs: BYOG section under the decorator pattern in docs/guardrails.md, using placeholder validator/connection values and documenting the connector-defined `parameters` passthrough. - Sample: samples/joke-agent-byog-decorator starter (agent-factory AGENT scope + tool TOOL scope, bindings.json connection binding), with a commented-out Azure Content Safety `parameters` example. - Discovery: docs and sample point at `uip agent guardrails list` for the validator name, connection id and the connector-defined `Parameters` schema, rather than the raw agents_/api/designer/byog-guardrails endpoint. - Scopes/stages: BYOG validators are not scope- or stage-restricted, so the developer chooses; here the scope is inferred from each decorated target. Bump to 0.14.19: 0.14.17 was taken by #1012 and is published on PyPI, and 0.14.18 belongs to the middleware flavor (#1013), which lands first. Independent of the middleware-flavor PR (#1013); branched from main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add Bring Your Own Guardrail (BYOG) support so coded agents can run customer-managed validators (a cloud content-safety subscription, a vendor validation service, or a custom Integration Service connector) configured under Admin -> AI Trust Layer -> Guardrails Configurations. - UiPathByoGuardrailMiddleware references the admin configuration by validator name + IS connection id and builds a builtInValidator guardrail with validator_type="byo" (byoValidatorName/byoConnectionId), reusing the shared BuiltInGuardrailMiddlewareMixin hook wiring unchanged. - validator_parameters is an optional passthrough of raw ValidatorParameter values. Scopes and stages are developer-supplied: BYOG validators are not scope- or stage-restricted, so all three scopes and both stages are available exactly as for the built-in validators. - Extract BUILT_IN_VALIDATOR_GUARDRAIL_TYPE (Literal-typed, in middlewares/_base.py) and use it across all built-in middlewares in place of the repeated "builtInValidator" string. - Docs: "Bring Your Own Guardrail (BYOG)" section in docs/guardrails.md plus a "Tuning a BYOG validator" subsection for validator_parameters. - Sample: samples/joke-agent-bring-your-own-guardrail, guarding AGENT (PRE+POST) and TOOL (PRE) scopes, with bindings.json declaring the IS connection for per-environment rebinding. All identifiers are placeholders, following the bring-your-own-model convention; the Azure Content Safety parameter example ships commented out to keep the sample vendor-neutral. - Discovery: docs and sample point at `uip agent guardrails list` for the validator name, connection id and the connector-defined `Parameters` schema, rather than the raw agents_/api/designer/byog-guardrails endpoint. - Bump version to 0.14.18 and sync uv.lock (0.14.17 was taken by #1012 and is published on PyPI). Verified live on alpha against a real BYOG harmful-content configuration: benign input passes, harmful input blocks at before_agent with the vendor verdict, and per-category severity thresholds are honoured (omitted blocks any non-zero severity, 4 lets severity-2 through while blocking 4, 6 lets both through). The decorator flavor ships separately (uipath-python ByoValidator + #1014, which follows at 0.14.19). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath
force-pushed
the
feat/byog-middleware
branch
from
July 30, 2026 11:30
78ee08c to
bd05772
Compare
|
apetraru-uipath
added a commit
that referenced
this pull request
Jul 30, 2026
Decorator-flavor Bring Your Own Guardrail support, the counterpart to the UiPathByoGuardrailMiddleware shipped in #1013. - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim. `uipath-platform` is floored at >=0.2.14, the release that ships ByoValidator (UiPath/uipath-python#1833), so this is a plain import rather than a guarded getattr. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open). This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible. - Tests: adapter error-logging tests plus ByoValidator-through-@guardrail tests (tool / plain function / validator reuse), all running against the published uipath-platform - no conditional skips. - Docs: BYOG section under the decorator pattern in docs/guardrails.md. The admin prerequisite, discovery command and parameter-schema lookup are cross-referenced to the middleware section instead of repeated; only the decorator-specific notes are spelled out. - Sample: samples/joke-agent-byog-decorator (agent-factory AGENT scope + tool TOOL scope, bindings.json connection binding), with a commented-out Azure Content Safety `parameters` example. Cross-links the middleware sample as the sibling starter. - Replace the leftover tenant-specific validator name and connection GUID with the placeholder values used elsewhere, in this PR's tests and in tests/guardrails/middlewares/test_byo.py from #1013. - Bump to 0.14.19 (main is at 0.14.18, published on PyPI). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath
added a commit
that referenced
this pull request
Jul 30, 2026
Decorator-flavor Bring Your Own Guardrail support, the counterpart to the UiPathByoGuardrailMiddleware shipped in #1013. - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim. `uipath-platform` is floored at >=0.2.14, the release that ships ByoValidator (UiPath/uipath-python#1833), so this is a plain import rather than a guarded getattr. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open), via a shared _EVALUATION_FAILED_MSG constant rather than repeating the format string at each of the four call sites. This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible. - Tests: adapter error-logging tests plus ByoValidator-through-@guardrail tests (tool / plain function / validator reuse), all running against the published uipath-platform - no conditional skips. - Docs: BYOG section under the decorator pattern in docs/guardrails.md. The admin prerequisite, discovery command and parameter-schema lookup are cross-referenced to the middleware section instead of repeated; only the decorator-specific notes are spelled out. - Sample: samples/joke-agent-byog-decorator (agent-factory AGENT scope + tool TOOL scope, bindings.json connection binding), with a commented-out Azure Content Safety `parameters` example. Cross-links the middleware sample as the sibling starter. - Replace the leftover tenant-specific validator name and connection GUID with the placeholder values used elsewhere, in this PR's tests and in tests/guardrails/middlewares/test_byo.py from #1013. - Bump to 0.14.19 (main is at 0.14.18, published on PyPI). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath
added a commit
that referenced
this pull request
Jul 30, 2026
Decorator-flavor Bring Your Own Guardrail support, the counterpart to the UiPathByoGuardrailMiddleware shipped in #1013. - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim. `uipath-platform` is floored at >=0.2.14, the release that ships ByoValidator (UiPath/uipath-python#1833), so this is a plain import rather than a guarded getattr. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open), via a shared _EVALUATION_FAILED_MSG constant. This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible. - Tests: adapter error-logging tests plus ByoValidator-through-@guardrail tests (tool / plain function / validator reuse), all running against the published uipath-platform - no conditional skips. - Sample: merge both flavors into samples/joke-agent-bring-your-own-guardrail as ONE agent guarded twice from the same BYOG configuration -- the middleware logs on AGENT scope (PRE_AND_POST, LogAction) while the decorator blocks on LLM scope (PRE, BlockAction on a create_llm factory), so a harmful topic is first logged and then blocked before the model is invoked. The separate joke-agent-byog-decorator sample is removed. - Docs: BYOG section under the decorator pattern in docs/guardrails.md, cross-referencing the middleware section for the shared prerequisite and discovery steps. Discovery now uses `uip agent guardrails list --byo`, whose entries carry ByoValidatorName / ByoConnectionId / ByoConnectorKey and the connector-defined Parameters schema. - Replace the leftover tenant-specific validator name and connection GUID with the placeholder values used elsewhere, in this PR's tests and in tests/guardrails/middlewares/test_byo.py from #1013. - Bump to 0.14.19 (main is at 0.14.18, published on PyPI). Verified live on alpha against a real BYOG harmful-content configuration: benign topic evaluates on both flavors (agent PRE, LLM PRE per model call, agent POST) and returns a joke; harmful topic is logged by the agent-scope guardrail, then blocked by the LLM-scope guardrail before chat/completions, with the vendor verdict "Harmful content detected: Violence (severity 4)". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath
added a commit
that referenced
this pull request
Jul 30, 2026
Decorator-flavor Bring Your Own Guardrail support, the counterpart to the UiPathByoGuardrailMiddleware shipped in #1013. - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim. `uipath-platform` is floored at >=0.2.14, the release that ships ByoValidator (UiPath/uipath-python#1833), so this is a plain import rather than a guarded getattr. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open), via a shared _EVALUATION_FAILED_MSG constant. This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible. - Tests: adapter error-logging tests plus ByoValidator-through-@guardrail tests (tool / plain function / validator reuse), all running against the published uipath-platform - no conditional skips. - Parity suite: new scenario 12 (test_byog_agent_block) runs for BOTH flavors and asserts they deliver the same byo wire contract to the service (validator_type="byo", byoValidatorName, byoConnectionId) and block identically on a failing verdict; both parity mock agents gain an "Agent BYOG Detection" guardrail (AGENT scope, PRE, BlockAction). - Sample: merge both flavors into samples/joke-agent-bring-your-own-guardrail as ONE agent guarded twice from the same BYOG configuration -- the middleware logs on AGENT scope (PRE_AND_POST, LogAction) while the decorator blocks on LLM scope (PRE, BlockAction on a create_llm factory), so a harmful topic is first logged and then blocked before the model is invoked. The separate joke-agent-byog-decorator sample is removed. - Docs: BYOG section under the decorator pattern in docs/guardrails.md, cross-referencing the middleware section for the shared prerequisite and discovery steps. Discovery now uses `uip agent guardrails list --byo`, whose entries carry ByoValidatorName / ByoConnectionId / ByoConnectorKey and the connector-defined Parameters schema. - Replace the leftover tenant-specific validator name and connection GUID with the placeholder values used elsewhere, in this PR's tests and in tests/guardrails/middlewares/test_byo.py from #1013. - Bump to 0.14.20 (0.14.19 was taken by #1008 and is published on PyPI). Verified live on alpha against a real BYOG harmful-content configuration: benign topic evaluates on both flavors (agent PRE, LLM PRE per model call, agent POST) and returns a joke; harmful topic is logged by the agent-scope guardrail, then blocked by the LLM-scope guardrail before chat/completions, with the vendor verdict "Harmful content detected: Violence (severity 4)". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apetraru-uipath
added a commit
that referenced
this pull request
Jul 31, 2026
Decorator-flavor Bring Your Own Guardrail support, the counterpart to the UiPathByoGuardrailMiddleware shipped in #1013. - Re-export ByoValidator from uipath_langchain.guardrails and the .guardrails.decorators shim. `uipath-platform` is floored at >=0.2.14, the release that ships ByoValidator (UiPath/uipath-python#1833), so this is a plain import rather than a guarded getattr. - Adapter hardening: the LLM/agent wrappers previously swallowed evaluator exceptions silently; they now log a WARNING with the guardrail name and traceback (still fail-open), via a shared _EVALUATION_FAILED_MSG constant. This makes BYOG misconfiguration (PROVIDER_ERROR, removed/disabled config, BYOG not enabled) visible. - Tests: adapter error-logging tests plus ByoValidator-through-@guardrail tests (tool / plain function / validator reuse), all running against the published uipath-platform - no conditional skips. - Parity suite: new scenario 12 (test_byog_agent_block) runs for BOTH flavors and asserts they deliver the same byo wire contract to the service (validator_type="byo", byoValidatorName, byoConnectionId) and block identically on a failing verdict; both parity mock agents gain an "Agent BYOG Detection" guardrail (AGENT scope, PRE, BlockAction). - Sample: merge both flavors into samples/joke-agent-bring-your-own-guardrail as ONE agent guarded twice from the same BYOG configuration -- the middleware logs on AGENT scope (PRE_AND_POST, LogAction) while the decorator blocks on LLM scope (PRE, BlockAction on a create_llm factory), so a harmful topic is first logged and then blocked before the model is invoked. The separate joke-agent-byog-decorator sample is removed. - No solution binding for the BYOG connection (review feedback): the connection is resolved server-side from the BYOG configuration, so the sample ships no bindings.json and the docs no longer point ByoConnectorKey at a connection binding. - Docs: BYOG section under the decorator pattern in docs/guardrails.md, cross-referencing the middleware section for the shared prerequisite and discovery steps. Discovery uses `uip agent guardrails list --byo`, whose entries carry ByoValidatorName / ByoConnectionId and the connector-defined Parameters schema. - Replace the leftover tenant-specific validator name and connection GUID with the placeholder values used elsewhere, in this PR's tests and in tests/guardrails/middlewares/test_byo.py from #1013. - Bump to 0.14.20 (0.14.19 was taken by #1008 and is published on PyPI). Verified live on alpha against a real BYOG harmful-content configuration: benign topic evaluates on both flavors (agent PRE, LLM PRE per model call, agent POST) and returns a joke; harmful topic is logged by the agent-scope guardrail, then blocked by the LLM-scope guardrail before chat/completions, with the vendor verdict "Harmful content detected: Violence (severity 4)". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What changed?
Adds Bring Your Own Guardrail (BYOG) support for coded agents — middleware flavor.
New middleware
UiPathByoGuardrailMiddleware(src/uipath_langchain/guardrails/middlewares/byo.py): runs a customer-managed validator (a cloud content-safety subscription, a vendor validation service, or a custom Integration Service connector) configured under Admin → AI Trust Layer → Guardrails Configurations. References the configuration byvalidator_name(byoValidatorName) + recommendedconnection_id, and builds abuiltInValidatorguardrail withvalidator_type="byo"— reusing the sharedBuiltInGuardrailMiddlewareMixinhook wiring unchanged (scopes × stage, toolmatch_names,asyncio.to_threadoffload, exception routing). No changes to the mixin itself.validator_parametersis an optional passthrough of rawValidatorParametervalues, because BYO parameter schemas are defined by the connector. Scopes and stages are developer-supplied: BYOG validators are not scope- or stage-restricted, so all three scopes and both stages are available exactly as for the built-in validators.uipath_langchain.guardrailsand.middlewares.Small refactor across existing middlewares (review feedback)
BUILT_IN_VALIDATOR_GUARDRAIL_TYPEinmiddlewares/_base.pyand used it in all 7 built-in middlewares in place of the repeated"builtInValidator"literal. It is typedLiteral["builtInValidator"]becauseGuardrailType.BUILT_IN_VALIDATOR.valueis typedstrand does not satisfy the model'sLiteralfield under mypy.Docs & sample
docs/guardrails.md: new "Bring Your Own Guardrail (BYOG)" section (admin prerequisite, config lookup, error semantics) plus a "Tuning a BYOG validator" subsection coveringvalidator_parameters.samples/joke-agent-bring-your-own-guardrail/— joke agent guarded on AGENT (PRE+POST) and TOOL (PRE) scopes,bindings.jsondeclaring the IS connection for per-environment rebinding, and a README covering setup, tuning and expected outcomes. All identifiers are placeholders (my-harmful-content-guardrail,my-byog-guardrail-connection, publicuipath-azure-contentsafety-guardrailsconnector key), following thebring-your-own-modelsample convention; the Azure Content Safety parameter example ships commented out so the sample stays vendor-neutral.Review feedback addressed (@valentinabojan)
uip agent guardrails listreplaces the rawGET agents_/api/designer/byog-guardrails?includeConnectionDetails=trueeverywhere (docs, sample README, samplegraph.py). BYOG configurations are listed alongside the built-in validators, which the docs now call out so the duplicate validator type is not confusing.validator_parametersguidance now points at the entry'sParametersarray and names the fields you read from it (Id,Type,Required,DefaultValue,Options,KeySource,Min,Max,Step) instead of "your configuration's validator definition". This also replaced a guess: the previous text said omitting the argument uses "whatever the connector applies by default, which may be its strictest setting" — the definition reports a concreteDefaultValue, so the docs now say that.PROVIDER_ERROR. That was wrong. Removed fromdocs/guardrails.md, the sample README, and theUiPathByoGuardrailMiddlewaredocstring, and replaced with the correct behaviour — the developer chooses. Thelistoutput confirms it: the BYO-backedharmful_contententry returnsAllowedScopes: [Agent, Llm, Tool]withPreExecution+PostExecutionon all three.Release
uv.locksynced. (0.14.17 was taken by fix(agent): align ixp extraction tool with the job attachment strategy #1012 and is published on PyPI; feat: support ByoValidator (BYOG) on the decorator path [AL-512] #1014 follows at 0.14.19.)The decorator flavor is independent and ships separately:
ByoValidatorin UiPath/uipath-python#1833 and its LangChain wiring in #1014.How has this been tested?
tests/guardrails/middlewares/test_byo.py— 26 new unit tests: guardrail construction (byosentinel,byoValidatorName/byoConnectionIdalias serialization, parameter passthrough, defaults), constructor validation errors, hook wiring parity (scopes × stage →before_*/after_*/wrap_tool_call), and the evaluation path (BYO fields reachevaluate_guardrail;BlockActionraises onVALIDATION_FAILED). Wire-payload coverage already exists inuipath-python'stest_guardrails_service.py, so it is not duplicated here.Full suite green;
ruff check,ruff format --check,mypyclean;uv lock --checkclean. Everypythonfence in the BYOG docs section is compile-checked and its imports verified to resolve (the middleware constructs from the documented snippet).Live E2E on alpha (
AdminStudioTest) against a real BYOG harmful-content configuration backed by a customer Azure Content Safety connector withfallbackOnUiPath=false, viauipath runon the new sample. Threeguardrails/validatecalls per run, matching the sample's two registrations (agent PRE, tool PRE, agent POST):BYOG_Harmful_Content_before_agent, before the LLM is called, with the vendor verdict "Harmful content detected: Violence (severity 4)" ✅validator_parametersverified across three threshold settings on the same prompts, confirming the connector honours the values rather than merely accepting them:46Are there any breaking changes?
Purely additive: one new exported middleware class, one new internal constant, plus docs/sample. The
BUILT_IN_VALIDATOR_GUARDRAIL_TYPErefactor is behaviour-preserving (same string value, now typed). Server-side, BYOG evaluation availability is controlled by the tenant's AI Trust Layer configuration.🤖 Generated with Claude Code