Skip to content

Commit b9284b9

Browse files
feat: add task recipient
1 parent 3a3c11a commit b9284b9

5 files changed

Lines changed: 27 additions & 17 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Python SDK that enables developers to build and deploy LangGraph
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath>=2.5.22,<2.6.0",
8+
"uipath>=2.5.23,<2.6.0",
99
"uipath-runtime>=0.5.1,<0.6.0",
1010
"langgraph>=1.0.0, <2.0.0",
1111
"langchain-core>=1.2.5, <2.0.0",

src/uipath_langchain/agent/guardrails/actions/escalate_action.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from langgraph.types import Command, interrupt
1010
from uipath._utils import UiPathUrl
1111
from uipath.agent.models.agent import AgentEscalationRecipient
12-
from uipath.platform.action_center.tasks import TaskRecipient
1312
from uipath.platform.common import CreateEscalation, UiPathConfig
1413
from uipath.platform.guardrails import (
1514
BaseGuardrail,
@@ -79,7 +78,7 @@ async def _node(
7978
state: AgentGuardrailsGraphState,
8079
) -> Dict[str, Any] | Command[Any]:
8180
# Resolve recipient value (handles both StandardRecipient and AssetRecipient)
82-
assignee = await resolve_recipient_value(self.recipient)
81+
task_recipient = await resolve_recipient_value(self.recipient)
8382

8483
# Validate message count based on execution stage
8584
_validate_message_count(state, execution_stage)
@@ -141,7 +140,7 @@ async def _node(
141140
app_folder_path=self.app_folder_path,
142141
title="Agents Guardrail Task",
143142
data=data,
144-
recipient=self.recipient,
143+
recipient=task_recipient,
145144
)
146145
)
147146

src/uipath_langchain/agent/guardrails/guardrails_factory.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
UniversalRule,
3333
WordRule,
3434
)
35-
36-
from uipath.platform.action_center.tasks import TaskRecipient
3735
from uipath.platform.guardrails import BaseGuardrail, GuardrailScope
3836

3937
from uipath_langchain.agent.guardrails.actions import (

src/uipath_langchain/agent/tools/escalation_tool.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
from uipath.agent.models.agent import (
1010
AgentEscalationChannel,
1111
AgentEscalationRecipient,
12+
AgentEscalationRecipientType,
1213
AgentEscalationResourceConfig,
1314
AssetRecipient,
1415
StandardRecipient,
1516
)
1617
from uipath.eval.mocks import mockable
1718
from uipath.platform import UiPath
19+
from uipath.platform.action_center.tasks import TaskRecipient, TaskRecipientType
1820
from uipath.platform.common import CreateEscalation
1921
from uipath.runtime.errors import UiPathErrorCode
2022

@@ -32,13 +34,24 @@ class EscalationAction(str, Enum):
3234
END = "end"
3335

3436

35-
async def resolve_recipient_value(recipient: AgentEscalationRecipient) -> str | None:
37+
async def resolve_recipient_value(
38+
recipient: AgentEscalationRecipient,
39+
) -> TaskRecipient | None:
3640
"""Resolve recipient value based on recipient type."""
3741
if isinstance(recipient, AssetRecipient):
38-
return await resolve_asset(recipient.asset_name, recipient.folder_path)
42+
value = await resolve_asset(recipient.asset_name, recipient.folder_path)
43+
type = None
44+
if recipient.type == AgentEscalationRecipientType.ASSET_USER_EMAIL:
45+
type = TaskRecipientType.EMAIL
46+
elif recipient.type == AgentEscalationRecipientType.ASSET_GROUP_NAME:
47+
type = TaskRecipientType.GROUP_NAME
48+
return TaskRecipient(value=value, type=type)
3949

4050
if isinstance(recipient, StandardRecipient):
41-
return recipient.value
51+
type = TaskRecipientType(recipient.type)
52+
if recipient.type == AgentEscalationRecipientType.USER_EMAIL:
53+
type = TaskRecipientType.EMAIL
54+
return TaskRecipient(value=recipient.value, type=type)
4255

4356
return None
4457

@@ -86,21 +99,21 @@ async def create_escalation_tool(
8699
async def escalation_tool_fn(**kwargs: Any) -> dict[str, Any]:
87100
task_title = channel.task_title or "Escalation Task"
88101

89-
assignee: str | None = (
102+
recipient: TaskRecipient | None = (
90103
await resolve_recipient_value(channel.recipients[0])
91104
if channel.recipients
92105
else None
93106
)
94107

95-
# Assignee requires runtime resolution, store in metadata after resolving
108+
# Recipient requires runtime resolution, store in metadata after resolving
96109
if tool.metadata is not None:
97-
tool.metadata["assignee"] = assignee
110+
tool.metadata["recipient"] = recipient
98111

99112
result = interrupt(
100113
CreateEscalation(
101114
title=task_title,
102115
data=kwargs,
103-
assignee=assignee,
116+
recipient=recipient,
104117
app_name=channel.properties.app_name,
105118
app_folder_path=channel.properties.folder_name,
106119
app_version=channel.properties.app_version,

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)