feat(guardrails): add decorator framework to uipath-platform [AL-288] by apetraru-uipath · Pull Request #1537 · UiPath/uipath-python

@apetraru-uipath @claude

Move @guardrail decorator, validators, actions, and adapter registry
from uipath-langchain into uipath-platform as a framework-agnostic
subpackage. Includes PIIValidator, PromptInjectionValidator,
CustomValidator, BlockAction, LogAction, and GuardrailTargetAdapter
Protocol. Bump version to 0.1.18.

Redesign @guardrail as a pure-function decorator: remove GuardrailScope
from the validator/decorator layer (not required by the API), replace
detect_scope() with recognize() in the adapter Protocol, add GuardrailExclude
marker for Annotated parameters, and add serialization helpers
(_collect_input, _collect_output, _reconstruct_output). The decorator
now works on any callable — plain functions, async functions, and factory
functions whose return values are recognized by registered adapters.

Remove unused _evaluate_rules function and its tests (was dead code).
Rewrite test_guardrails_decorators.py with 76 tests covering all paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>