Skip to content

Conversation

@giuliastf
Copy link
Collaborator

@giuliastf giuliastf commented Oct 15, 2025

Add Guardrails Models

Summary

Implements a comprehensive guardrails system for UiPath agents with configurable validation rules and actions.

Changes

Guardrails Models (src/uipath/models/guardrails.py)

Core Components

  • Field Selectors: AllFieldsSelector, SpecificFieldsSelector with discriminated unions
  • Validation Rules:
    • WordRule - Text validation with operators (contains, equals, startsWith, etc.)
    • NumberRule - Numeric validation with comparison operators
    • BooleanRule - Boolean field validation
    • UniversalRule - Always-apply rules for input/output/both
  • Actions:
    • BlockAction - Stop execution with reason
    • FilterAction - Remove specific fields
    • LogAction - Log events with severity levels
    • EscalateAction - Human-in-the-loop workflows
  • Guardrail Types:
    • CustomGuardrail - User-defined rules and logic
    • BuiltInValidatorGuardrail - Pre-built validators with parameters

Agent Integration (src/uipath/agent/models/agent.py)

  • Added guardrails: Optional[List[Guardrail]] to BaseAgentDefinition

Testing and Example Usage (tests/agent/models/test_agent.py)

  • JSON parsing validation for complex guardrail configurations : test_agent_config_loads_guardrails

Development Package

  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath==2.1.100.dev1006982043",

  # Any version from PR
  "uipath>=2.1.100.dev1006980000,<2.1.100.dev1006990000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath = { index = "testpypi" }

@giuliastf giuliastf self-assigned this Oct 15, 2025
@github-actions github-actions bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository labels Oct 15, 2025
@giuliastf giuliastf force-pushed the feat/guardrail_model branch from 471b3be to fb067ab Compare October 15, 2025 09:32
@giuliastf giuliastf changed the title feat(guardrail_model): add agent.json classes feat(guardrail_model): support guardrail policy configuration for agents Oct 15, 2025
@giuliastf giuliastf marked this pull request as ready for review October 15, 2025 09:37
@giuliastf giuliastf added the build:dev Create a dev build from the pr label Oct 17, 2025
@giuliastf giuliastf force-pushed the feat/guardrail_model branch from c490043 to 012112b Compare October 17, 2025 08:24
@giuliastf giuliastf force-pushed the feat/guardrail_model branch from 012112b to c7ad16c Compare October 17, 2025 10:27
return isinstance(value, str) and value in [sl.value for sl in SeverityLevel]


# Guardrail Models

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what are these guardrail models used?

@giuliastf giuliastf force-pushed the feat/guardrail_model branch 3 times, most recently from ada1860 to fca863d Compare October 21, 2025 23:00
@giuliastf giuliastf requested review from valentinabojan and removed request for cristipufu and radu-mocanu October 21, 2025 23:01
@giuliastf giuliastf force-pushed the feat/guardrail_model branch 3 times, most recently from 8bca11a to 7689142 Compare October 22, 2025 07:27
@giuliastf giuliastf force-pushed the feat/guardrail_model branch 4 times, most recently from 1486263 to 6acb916 Compare October 22, 2025 15:02
@giuliastf giuliastf force-pushed the feat/guardrail_model branch from 6acb916 to cc0657c Compare October 22, 2025 15:06
@giuliastf giuliastf merged commit 802d12a into main Oct 22, 2025
60 checks passed
@giuliastf giuliastf deleted the feat/guardrail_model branch October 22, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build:dev Create a dev build from the pr test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants