diff --git a/src/uipath_langchain/agent/tools/escalation_tool.py b/src/uipath_langchain/agent/tools/escalation_tool.py index ead8fdef3..8ee07933e 100644 --- a/src/uipath_langchain/agent/tools/escalation_tool.py +++ b/src/uipath_langchain/agent/tools/escalation_tool.py @@ -11,6 +11,8 @@ AgentEscalationRecipient, AgentEscalationRecipientType, AgentEscalationResourceConfig, + ArgumentEmailRecipient, + ArgumentGroupNameRecipient, AssetRecipient, StandardRecipient, ) @@ -49,6 +51,7 @@ class EscalationAction(str, Enum): async def resolve_recipient_value( recipient: AgentEscalationRecipient, + input_args: dict[str, Any] | None = None, ) -> TaskRecipient | None: """Resolve recipient value based on recipient type.""" if isinstance(recipient, AssetRecipient): @@ -60,6 +63,18 @@ async def resolve_recipient_value( type = TaskRecipientType.GROUP_NAME return TaskRecipient(value=value, type=type, displayName=value) + if isinstance(recipient, ArgumentEmailRecipient): + value = (input_args or {}).get(recipient.argument_name) + return TaskRecipient( + value=value, type=TaskRecipientType.EMAIL, displayName=value + ) + + if isinstance(recipient, ArgumentGroupNameRecipient): + value = (input_args or {}).get(recipient.argument_name) + return TaskRecipient( + value=value, type=TaskRecipientType.GROUP_NAME, displayName=value + ) + if isinstance(recipient, StandardRecipient): type = TaskRecipientType(recipient.type) if recipient.type == AgentEscalationRecipientType.USER_EMAIL: @@ -160,7 +175,7 @@ class EscalationToolOutput(BaseModel): async def escalation_tool_fn(**kwargs: Any) -> dict[str, Any]: recipient: TaskRecipient | None = ( - await resolve_recipient_value(channel.recipients[0]) + await resolve_recipient_value(channel.recipients[0], input_args=kwargs) if channel.recipients else None )