Skip to content

Commit aa4c517

Browse files
fix: match guardrail tools by display_name in addition to tool name (#748)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 73a8614 commit aa4c517

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,18 @@ 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+
(
321+
t
322+
for t in tools
323+
if t.name == match_name
324+
or (
325+
isinstance(t.metadata, dict)
326+
and t.metadata.get("display_name") == match_name
327+
)
328+
),
329+
None,
320330
)
321331

322332
if matching_tool:

tests/agent/guardrails/test_guardrails_factory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ def test_convert_with_nonexistent_tool_raises_error(self) -> None:
11791179

11801180
mock_tool = Mock(spec=BaseTool)
11811181
mock_tool.name = "different_tool"
1182+
mock_tool.metadata = None
11821183

11831184
agent_guardrail = AgentCustomGuardrail.model_validate(
11841185
{

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)