Skip to content

Commit 27d7988

Browse files
fix: add back resolve_static_args with deprecation warning (#734)
1 parent 3d0afd8 commit 27d7988

File tree

4 files changed

+148
-2
lines changed

4 files changed

+148
-2
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.11"
3+
version = "0.9.12"
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/tools/static_args.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from langchain_core.messages import ToolCall
99
from langchain_core.tools import BaseTool, StructuredTool
1010
from pydantic import BaseModel
11+
from typing_extensions import deprecated
1112
from uipath.agent.models.agent import (
1213
AgentToolArgumentArgumentProperties,
1314
AgentToolArgumentProperties,
@@ -132,6 +133,33 @@ def _apply_static_arguments_to_schema(
132133
return modified_tool
133134

134135

136+
@deprecated(
137+
"Use StaticArgsHandler to modify LLM tool calls directly."
138+
"Applying static args in the tool node conflicts with guardrails"
139+
)
140+
def resolve_static_args(
141+
tool: ArgumentPropertiesMixin,
142+
agent_input: dict[str, Any],
143+
) -> dict[str, Any]:
144+
"""Resolves static arguments for a given resource with a given input.
145+
146+
Args:
147+
tool: The tool with argument_properties.
148+
agent_input: The input arguments passed to the agent.
149+
150+
Returns:
151+
A dictionary of expanded arguments to be used in the tool call.
152+
"""
153+
154+
static_arguments = _resolve_argument_properties(
155+
tool.argument_properties, agent_input
156+
)
157+
return {
158+
json_path: static_argument.value
159+
for json_path, static_argument in static_arguments.items()
160+
}
161+
162+
135163
def apply_static_args(
136164
static_args: dict[str, Any],
137165
kwargs: dict[str, Any],

tests/agent/tools/test_static_args.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
)
1212

1313
from uipath_langchain.agent.tools.static_args import (
14+
ArgumentPropertiesMixin,
1415
StaticArgsHandler,
1516
apply_static_args,
17+
resolve_static_args,
1618
)
1719
from uipath_langchain.agent.tools.structured_tool_with_argument_properties import (
1820
StructuredToolWithArgumentProperties,
@@ -461,3 +463,119 @@ def test_apply_static_args_replace_entire_array(self):
461463
"enabled": True,
462464
}
463465
assert result == expected
466+
467+
468+
class TestResolveStaticArgs:
469+
"""Test cases for resolve_static_args function."""
470+
471+
def test_resolve_static_args_with_argument_properties(self):
472+
"""Test resolve_static_args with an object that has argument_properties."""
473+
474+
class ResourceWithProps(ArgumentPropertiesMixin):
475+
argument_properties = {
476+
"$['host']": AgentToolStaticArgumentProperties(
477+
is_sensitive=False, value="api.example.com"
478+
),
479+
}
480+
481+
result = resolve_static_args(ResourceWithProps(), {"unused": "input"})
482+
483+
assert result == {"$['host']": "api.example.com"}
484+
485+
def test_resolve_static_args_with_static_values_of_different_types(self):
486+
"""Test resolve_static_args resolves string, integer, and object static values."""
487+
488+
class ResourceWithProps(ArgumentPropertiesMixin):
489+
argument_properties = {
490+
"$['connection_id']": AgentToolStaticArgumentProperties(
491+
is_sensitive=False, value="12345"
492+
),
493+
"$['timeout']": AgentToolStaticArgumentProperties(
494+
is_sensitive=False, value=30
495+
),
496+
"$['config']": AgentToolStaticArgumentProperties(
497+
is_sensitive=False, value={"enabled": True, "retries": 3}
498+
),
499+
}
500+
501+
result = resolve_static_args(ResourceWithProps(), {"unused": "input"})
502+
503+
assert result == {
504+
"$['connection_id']": "12345",
505+
"$['timeout']": 30,
506+
"$['config']": {"enabled": True, "retries": 3},
507+
}
508+
509+
def test_resolve_static_args_with_argument_properties_extracts_from_agent_input(
510+
self,
511+
):
512+
"""Test resolve_static_args resolves AgentToolArgumentArgumentProperties from agent_input."""
513+
514+
class ResourceWithProps(ArgumentPropertiesMixin):
515+
argument_properties = {
516+
"$['user_id']": AgentToolArgumentArgumentProperties(
517+
is_sensitive=False, argument_path="userId"
518+
),
519+
"$['query']": AgentToolArgumentArgumentProperties(
520+
is_sensitive=False, argument_path="searchQuery"
521+
),
522+
}
523+
524+
agent_input = {
525+
"userId": "user123",
526+
"searchQuery": "test search",
527+
"unused_arg": "not_used",
528+
}
529+
530+
result = resolve_static_args(ResourceWithProps(), agent_input)
531+
532+
assert result == {
533+
"$['user_id']": "user123",
534+
"$['query']": "test search",
535+
}
536+
537+
def test_resolve_static_args_with_mixed_static_and_argument_properties(self):
538+
"""Test resolve_static_args with both static and argument properties."""
539+
540+
class ResourceWithProps(ArgumentPropertiesMixin):
541+
argument_properties = {
542+
"$['api_key']": AgentToolStaticArgumentProperties(
543+
is_sensitive=False, value="secret_key"
544+
),
545+
"$['user_id']": AgentToolArgumentArgumentProperties(
546+
is_sensitive=False, argument_path="userId"
547+
),
548+
"$['version']": AgentToolStaticArgumentProperties(
549+
is_sensitive=False, value="v1"
550+
),
551+
}
552+
553+
agent_input = {"userId": "user456"}
554+
555+
result = resolve_static_args(ResourceWithProps(), agent_input)
556+
557+
assert result == {
558+
"$['api_key']": "secret_key",
559+
"$['user_id']": "user456",
560+
"$['version']": "v1",
561+
}
562+
563+
def test_resolve_static_args_skips_missing_argument_values(self):
564+
"""Test that argument properties referencing missing agent_input keys are skipped."""
565+
566+
class ResourceWithProps(ArgumentPropertiesMixin):
567+
argument_properties = {
568+
"$['existing_param']": AgentToolArgumentArgumentProperties(
569+
is_sensitive=False, argument_path="existingArg"
570+
),
571+
"$['missing_param']": AgentToolArgumentArgumentProperties(
572+
is_sensitive=False, argument_path="missingArg"
573+
),
574+
}
575+
576+
agent_input = {"existingArg": "exists"}
577+
578+
result = resolve_static_args(ResourceWithProps(), agent_input)
579+
580+
assert result == {"$['existing_param']": "exists"}
581+
assert "$['missing_param']" not in result

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)