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.4"
version = "0.4.5"
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
51 changes: 50 additions & 1 deletion src/uipath_langchain/agent/guardrails/actions/escalate_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

from langchain_core.messages import AIMessage, AnyMessage, BaseMessage, ToolMessage
from langgraph.types import Command, interrupt
from uipath.platform.common import CreateEscalation
from uipath._utils import UiPathUrl
from uipath.platform.common import CreateEscalation, UiPathConfig
from uipath.platform.guardrails import (
BaseGuardrail,
GuardrailScope,
Expand Down Expand Up @@ -85,6 +86,12 @@ async def _node(
"GuardrailResult": state.guardrail_validation_result,
}

# Add tenant and trace URL if base_url is configured
cloud_base_url = UiPathConfig.base_url
if cloud_base_url is not None:
data["TenantName"] = _get_tenant_name(cloud_base_url)
data["AgentTrace"] = _get_agent_execution_viewer_url(cloud_base_url)

# Add stage-specific fields
if execution_stage == ExecutionStage.PRE_EXECUTION:
# PRE_EXECUTION: Only Inputs field from last message
Expand Down Expand Up @@ -624,3 +631,45 @@ def _execution_stage_to_string(
if execution_stage == ExecutionStage.PRE_EXECUTION:
return "PreExecution"
return "PostExecution"


def _get_tenant_name(cloud_base_url: str) -> str:
"""Extract the tenant name from the UiPath base URL.

Args:
cloud_base_url: The UiPath cloud base URL to extract tenant name from.

Returns:
str: The tenant name extracted from the base URL.
"""
uiPath_Url = UiPathUrl(cloud_base_url)
return uiPath_Url.tenant_name


def _get_agent_execution_viewer_url(cloud_base_url: str) -> str:
"""Generate the agent execution viewer URL based on execution context.

Constructs the appropriate URL for viewing agent execution traces. The URL format
depends on whether the agent is running in a studio project (development) or
deployed (production) context.

Args:
cloud_base_url: The UiPath cloud base URL to use for constructing the viewer URL.

Returns:
str: The constructed agent execution viewer URL.
"""
uiPath_Url = UiPathUrl(cloud_base_url)
organization_id = UiPathConfig.organization_id
agent_id = UiPathConfig.project_id

# Route to appropriate URL based on source
if UiPathConfig.is_studio_project:
return f"{uiPath_Url.base_url}/{organization_id}/studio_/designer/{agent_id}"
else:
execution_folder_id = UiPathConfig.folder_key
process_uuid = UiPathConfig.process_uuid
trace_id = UiPathConfig.trace_id
package_version = UiPathConfig.process_version

return f"{uiPath_Url.base_url}/{organization_id}/agents_/deployed/{execution_folder_id}/{process_uuid}/{agent_id}/{package_version}/traces/{trace_id}"
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.