Skip to content

Commit b7e4699

Browse files
fix: match guardrail tools by display_name in addition to tool name
When matching tools for deterministic guardrails, also check the tool's metadata display_name field. This fixes cases where the guardrail match_names reference the display name rather than the internal tool name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 73a8614 commit b7e4699

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.9.18"
3+
version = "0.9.19"
44
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath_langchain/agent/guardrails/guardrails_factory.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ def _compute_field_sources_for_guardrail(
315315

316316
# Deterministic guardrails have one single tool
317317
if guardrail.selector.match_names and len(guardrail.selector.match_names) > 0:
318+
match_name = guardrail.selector.match_names[0]
318319
matching_tool = next(
319-
(t for t in tools if t.name == guardrail.selector.match_names[0]), None
320+
(t for t in tools if t.name == match_name or t.metadata.get("display_name") == match_name), None,
320321
)
321322

322323
if matching_tool:
@@ -339,7 +340,7 @@ def _compute_field_sources_for_guardrail(
339340
code=AgentStartupErrorCode.INVALID_GUARDRAIL_CONFIG,
340341
title="Invalid guardrail match_names",
341342
detail=f"Guardrail '{guardrail.name}' requires a valid match_names with at least one tool. "
342-
f"Tool '{tool_name}' not found in available tools. Please verify the tool name in your guardrail config."
343+
f"Tool '{tool_name}' not found in available tools. Please verify the tool name in your guardrail config."
343344
if tool_name
344345
else f"Guardrail '{guardrail.name}' has match_names empty or not specified. Please add at least one tool name to match_names.",
345346
category=UiPathErrorCategory.USER,
@@ -519,8 +520,8 @@ def build_guardrails_with_actions(
519520
code=AgentStartupErrorCode.INVALID_GUARDRAIL_CONFIG,
520521
title="Invalid guardrail scope",
521522
detail=f"Deterministic guardrail '{converted_guardrail.name}' can only be used with TOOL scope. "
522-
f"Found invalid scopes: {[scope.name for scope in non_tool_scopes]}. "
523-
f"Please configure this guardrail to use only TOOL scope.",
523+
f"Found invalid scopes: {[scope.name for scope in non_tool_scopes]}. "
524+
f"Please configure this guardrail to use only TOOL scope.",
524525
category=UiPathErrorCategory.USER,
525526
)
526527
else:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)