Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-langchain"
version = "0.4.16"
version = "0.4.17"
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
13 changes: 9 additions & 4 deletions src/uipath_langchain/agent/guardrails/actions/escalate_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from langchain_core.messages import AIMessage, AnyMessage, BaseMessage, ToolMessage
from langgraph.types import Command, interrupt
from uipath._utils import UiPathUrl
from uipath.agent.models.agent import AgentEscalationRecipient
from uipath.platform.common import CreateEscalation, UiPathConfig
from uipath.platform.guardrails import (
BaseGuardrail,
Expand All @@ -18,6 +19,7 @@
from ...exceptions import AgentStateException, AgentTerminationException
from ...react.types import AgentGuardrailsGraphState
from ...react.utils import extract_current_tool_call_index, find_latest_ai_message
from ...tools.escalation_tool import resolve_recipient_value
from ..types import ExecutionStage
from ..utils import _extract_tool_args_from_message, get_message_content
from .base_action import GuardrailAction, GuardrailActionNode
Expand All @@ -36,20 +38,20 @@ def __init__(
app_name: str,
app_folder_path: str,
version: int,
assignee: str,
recipient: AgentEscalationRecipient,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a similar class, but not tied to the low coded agent? We tried to not use such objects here. Instead we mapped from agent-related objects to core objects, in the guardrails_factory

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment there's no core recipient object available. As discussed with @ctiliescuuipath and @dianapirvulescu, this type of object will be added in their changes regarding adding support for groupId and userId, where they'll need to make resolve_recipient_value return an actual object to preserve its type (not just a string).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reading you comments right now I was thinking if should be a better place to convert resolve the assets into guardrails_factory. @dianagrecu-uipath do you know if assets will be used for guardrails also in coded agents ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ctiliescuuipath no sorry, I don't know if assets will be used in coded agents as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@valentinabojan @ctiliescuuipath are you good with merging these changes?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, go ahead

):
"""Initialize EscalateAction with escalation app configuration.

Args:
app_name: Name of the escalation app.
app_folder_path: Folder path where the escalation app is located.
version: Version of the escalation app.
assignee: User or role assigned to handle the escalation.
recipient: Recipient object (StandardRecipient or AssetRecipient).
"""
self.app_name = app_name
self.app_folder_path = app_folder_path
self.version = version
self.assignee = assignee
self.recipient = recipient

def action_node(
self,
Expand All @@ -75,6 +77,9 @@ def action_node(
async def _node(
state: AgentGuardrailsGraphState,
) -> Dict[str, Any] | Command[Any]:
# Resolve recipient value (handles both StandardRecipient and AssetRecipient)
assignee = await resolve_recipient_value(self.recipient)

# Validate message count based on execution stage
_validate_message_count(state, execution_stage)

Expand Down Expand Up @@ -135,7 +140,7 @@ async def _node(
app_folder_path=self.app_folder_path,
title="Agents Guardrail Task",
data=data,
assignee=self.assignee,
assignee=assignee,
)
)

Expand Down
22 changes: 10 additions & 12 deletions src/uipath_langchain/agent/guardrails/guardrails_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
AgentUnknownGuardrail,
AgentWordOperator,
AgentWordRule,
StandardRecipient,
)
from uipath.core.guardrails import (
AllFieldsSelector,
Expand Down Expand Up @@ -507,18 +506,17 @@ def build_guardrails_with_actions(
)
)
elif isinstance(action, AgentGuardrailEscalateAction):
if isinstance(action.recipient, StandardRecipient):
result.append(
(
converted_guardrail,
EscalateAction(
app_name=action.app.name,
app_folder_path=action.app.folder_name,
version=action.app.version,
assignee=action.recipient.value,
),
)
result.append(
(
converted_guardrail,
EscalateAction(
app_name=action.app.name,
app_folder_path=action.app.folder_name,
version=action.app.version,
recipient=action.recipient,
),
)
)
elif isinstance(action, AgentGuardrailFilterAction):
result.append((converted_guardrail, FilterAction(fields=action.fields)))
return result
Loading