Skip to content

Commit 0f6e711

Browse files
committed
chore: extra validation
1 parent 1d108d2 commit 0f6e711

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

src/uipath_langchain/agent/tools/client_side_tool.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,26 @@ def validate_and_apply_tool_filter(
4747
agent_tools: The agent's client-side tools.
4848
Dict of {tool_name: ClientSideToolInfo}.
4949
"""
50-
declared = {
51-
(t["name"] if isinstance(t, dict) else t): t
52-
if isinstance(t, dict)
53-
else {"name": t}
54-
for t in declared_tools
55-
}
50+
declared: dict[str, dict[str, Any]] = {}
51+
for i, t in enumerate(declared_tools):
52+
if isinstance(t, dict):
53+
if "name" not in t:
54+
raise ValueError(
55+
f"Client-side tool declaration at index {i} is missing required 'name' field."
56+
)
57+
name = t["name"]
58+
elif isinstance(t, str):
59+
name = t
60+
t = {"name": t}
61+
else:
62+
raise ValueError(
63+
f"Client-side tool declaration at index {i} must be a dict or string, got {type(t).__name__}."
64+
)
65+
if name in declared:
66+
raise ValueError(
67+
f"Duplicate client-side tool declaration: '{name}'."
68+
)
69+
declared[name] = t
5670

5771
required = set(agent_tools.keys())
5872
missing = required - set(declared.keys())

0 commit comments

Comments
 (0)