Skip to content

Commit 52ae534

Browse files
valentinabojanValentina Bojan
andauthored
feat: add support for guardrails [AL-232] (#30)
Co-authored-by: Valentina Bojan <valentina.bojan@uipath.com>
1 parent 2f9a642 commit 52ae534

6 files changed

Lines changed: 180 additions & 1027 deletions

File tree

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
{
2+
"id": "ca9e1b22-e201-4e7c-859d-2436075c833c",
3+
"version": "1.0.0",
4+
"name": "Agent",
5+
"metadata": {
6+
"storageVersion": "31.0.0",
7+
"isConversational": false
8+
},
9+
"messages": [
10+
{
11+
"role": "system",
12+
"content": "You are an agentic assistant.",
13+
"contentTokens": [
14+
{
15+
"type": "simpleText",
16+
"rawString": "You are an agentic assistant."
17+
}
18+
]
19+
},
20+
{
21+
"role": "user",
22+
"content": "What is the current date, Agent?",
23+
"contentTokens": [
24+
{
25+
"type": "simpleText",
26+
"rawString": "What is the current date, Agent?"
27+
}
28+
]
29+
}
30+
],
31+
"inputSchema": {
32+
"type": "object",
33+
"properties": {}
34+
},
35+
"outputSchema": {
36+
"type": "object",
37+
"properties": {
38+
"content": {
39+
"type": "string",
40+
"description": "Output content"
41+
}
42+
}
43+
},
44+
"settings": {
45+
"model": "gpt-4.1-2025-04-14",
46+
"maxTokens": 16384,
47+
"temperature": 0,
48+
"engine": "basic-v2",
49+
"maxIterations": 25
50+
},
51+
"resources": [],
52+
"features": [],
53+
"guardrails": [
54+
{
55+
"name": "PII log guardrail",
56+
"description": "This validator is designed to detect personally identifiable information using Azure Cognitive Services",
57+
"action": {
58+
"$actionType": "log",
59+
"severityLevel": "Warning"
60+
},
61+
"enabledForEvals": true,
62+
"id": "5b994b25-3714-48fa-804f-4173b2645603",
63+
"selector": {
64+
"scopes": [
65+
"Agent",
66+
"Llm"
67+
]
68+
},
69+
"$guardrailType": "builtInValidator",
70+
"validatorType": "pii_detection",
71+
"validatorParameters": [
72+
{
73+
"$parameterType": "enum-list",
74+
"id": "entities",
75+
"value": [
76+
"Email",
77+
"Address",
78+
"PhoneNumber",
79+
"Person"
80+
]
81+
},
82+
{
83+
"$parameterType": "map-enum",
84+
"id": "entityThresholds",
85+
"value": {
86+
"Email": 0.5,
87+
"Address": 0.7,
88+
"PhoneNumber": 0.5,
89+
"Person": 0.5
90+
}
91+
}
92+
]
93+
},
94+
{
95+
"name": "Prompt injection log guardrail",
96+
"description": "This validator is designed to detect personally identifiable information using Azure Cognitive Services",
97+
"action": {
98+
"$actionType": "log",
99+
"severityLevel": "Warning"
100+
},
101+
"enabledForEvals": true,
102+
"id": "5b994b25-3714-48fa-804f-4173b2645603",
103+
"selector": {
104+
"scopes": [
105+
"Llm"
106+
]
107+
},
108+
"$guardrailType": "builtInValidator",
109+
"validatorType": "prompt_injection",
110+
"validatorParameters": [
111+
{
112+
"$parameterType": "number",
113+
"id": "threshold",
114+
"value": 0.5
115+
}
116+
]
117+
},
118+
{
119+
"name": "PII block guardrail",
120+
"description": "This validator is designed to detect personally identifiable information using Azure Cognitive Services",
121+
"action": {
122+
"$actionType": "block",
123+
"reason": "test"
124+
},
125+
"enabledForEvals": true,
126+
"id": "5b994b25-3714-48fa-804f-4173b2645603",
127+
"selector": {
128+
"scopes": [
129+
"Agent",
130+
"Llm"
131+
]
132+
},
133+
"$guardrailType": "builtInValidator",
134+
"validatorType": "pii_detection",
135+
"validatorParameters": [
136+
{
137+
"$parameterType": "enum-list",
138+
"id": "entities",
139+
"value": [
140+
"Email",
141+
"Address",
142+
"PhoneNumber"
143+
]
144+
},
145+
{
146+
"$parameterType": "map-enum",
147+
"id": "entityThresholds",
148+
"value": {
149+
"Email": 0.5,
150+
"Address": 0.7,
151+
"PhoneNumber": 0.5
152+
}
153+
}
154+
]
155+
}
156+
]
157+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "2.0",
3+
"resources": []
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"runtime": {
3+
"internalArguments": {
4+
"resourceOverwrites": {}
5+
}
6+
}
7+
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
88
"uipath>=2.2.21",
9-
"uipath-langchain>=0.1.18",
9+
"uipath-langchain>=0.1.20",
1010
"uipath-runtime>=0.2.2",
1111
"langgraph>=1.0.0",
1212
"azure-monitor-opentelemetry>=1.7.0",

src/uipath_agents/agent_graph_builder/graph.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
from typing import Any
44

5-
from uipath.agent.models.agent import LowCodeAgentDefinition
5+
from uipath.agent.models.agent import (
6+
LowCodeAgentDefinition,
7+
)
8+
from uipath_langchain.agent.guardrails import build_guardrails_with_actions
69
from uipath_langchain.agent.react import (
710
AgentGraphConfig,
811
create_agent,
@@ -46,6 +49,8 @@ async def build_agent_graph(
4649
input_model = resolve_input_model(agent_definition.input_schema)
4750
output_model = resolve_output_model(agent_definition.output_schema)
4851

52+
guardrails = build_guardrails_with_actions(agent_definition.guardrails)
53+
4954
# Create agent config with feature flags
5055
agent_config = AgentGraphConfig(
5156
recursion_limit=AGENT_LOOP_RECURSION_LIMIT,
@@ -58,4 +63,5 @@ async def build_agent_graph(
5863
input_schema=input_model,
5964
output_schema=output_model,
6065
config=agent_config,
66+
guardrails=guardrails,
6167
)

0 commit comments

Comments
 (0)