22
33import copy
44import re
5- from typing import Any , cast
5+ from typing import Any
66
7- from langchain .tools import BaseTool
8- from langchain_core .messages import ToolCall
97from langchain_core .tools import StructuredTool
108from uipath .agent .models .agent import (
119 AgentIntegrationToolParameter ,
2624 raise_for_enriched ,
2725)
2826from uipath_langchain .agent .react .jsonschema_pydantic_converter import create_model
29- from uipath_langchain .agent .react .types import AgentGraphState
30- from uipath_langchain .agent .tools .static_args import (
31- ArgumentPropertiesMixin ,
32- handle_static_args ,
33- )
34- from uipath_langchain .agent .tools .tool_node import (
35- ToolWrapperReturnType ,
36- )
3727
38- from .schema_editing import strip_matching_enums
28+ from .schema_editing import strip_enum
3929from .structured_tool_with_argument_properties import (
4030 StructuredToolWithArgumentProperties ,
4131)
@@ -149,15 +139,14 @@ def _is_param_name_to_jsonpath(param_name: str) -> str:
149139 return "$" + "" .join (parts )
150140
151141
152- def strip_template_enums_from_schema (
142+ def strip_enums_from_schema (
153143 schema : dict [str , Any ],
154144 parameters : list [AgentIntegrationToolParameter ],
155145) -> dict [str , Any ]:
156- """Remove {{template}} enum values only from argument-variant parameter fields .
146+ """Remove enum constraints from fields in the schema that were configured with static args .
157147
158- For each parameter with fieldVariant 'argument', navigates the schema to the
159- corresponding field (supporting nested objects, arrays, and $ref resolution)
160- and strips enum values matching the {{...}} pattern.
148+ We strip them so that the tool's args_schema does not enforce them at
149+ validation time; we add our own enum constraints only visible to the LLM.
161150
162151 The function deep-copies the schema so the original is never mutated.
163152
@@ -166,17 +155,14 @@ def strip_template_enums_from_schema(
166155 parameters: List of integration tool parameters from resource.properties.
167156
168157 Returns:
169- A cleaned copy of the schema with template enum values removed
170- only from argument-variant fields.
158+ A cleaned copy of the schema with enum constraints removed
159+ from configured fields.
171160 """
172161 schema = copy .deepcopy (schema )
173162
174163 for param in parameters :
175- if param .field_variant != "argument" :
176- continue
177-
178164 segments = _param_name_to_segments (param .name )
179- strip_matching_enums (schema , segments , _TEMPLATE_PATTERN )
165+ strip_enum (schema , segments )
180166
181167 return schema
182168
@@ -309,7 +295,7 @@ def create_integration_tool(
309295
310296 activity_metadata = convert_to_activity_metadata (resource )
311297
312- cleaned_input_schema = strip_template_enums_from_schema (
298+ cleaned_input_schema = strip_enums_from_schema (
313299 resource .input_schema , resource .properties .parameters
314300 )
315301 input_model = create_model (cleaned_input_schema )
@@ -351,16 +337,6 @@ async def integration_tool_fn(**kwargs: Any):
351337
352338 return result
353339
354- async def integration_tool_wrapper (
355- tool : BaseTool ,
356- call : ToolCall ,
357- state : AgentGraphState ,
358- ) -> ToolWrapperReturnType :
359- call ["args" ] = handle_static_args (
360- cast (ArgumentPropertiesMixin , tool ), state , call ["args" ]
361- )
362- return await tool .ainvoke (call )
363-
364340 tool = StructuredToolWithArgumentProperties (
365341 name = tool_name ,
366342 description = resource .description ,
@@ -375,6 +351,5 @@ async def integration_tool_wrapper(
375351 },
376352 argument_properties = argument_properties ,
377353 )
378- tool .set_tool_wrappers (awrapper = integration_tool_wrapper )
379354
380355 return tool
0 commit comments