Skip to content

Commit 3d5029c

Browse files
refactor(agent/tools): extract _channel_app_name helper
Replace the duplicated isinstance-based app_name derivation in create_escalation_tool and ixp_escalation_tool with one shared _channel_app_name helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4f91533 commit 3d5029c

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

src/uipath_langchain/agent/tools/escalation_tool.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ def _get_exported_trace_id(trace_id: str | None) -> str | None:
252252
return trace_id
253253

254254

255+
def _channel_app_name(channel: EscalationChannel) -> str | None:
256+
return (
257+
channel.properties.app_name
258+
if isinstance(channel, AgentEscalationChannel)
259+
else None
260+
)
261+
262+
255263
async def create_task_for_channel(
256264
client: UiPath,
257265
channel: EscalationChannel,
@@ -307,11 +315,7 @@ def create_escalation_tool(
307315

308316
tool_name: str = f"escalate_{sanitize_tool_name(resource.name)}"
309317
channel: EscalationChannel = resource.channels[0]
310-
app_name = (
311-
channel.properties.app_name
312-
if isinstance(channel, AgentEscalationChannel)
313-
else None
314-
)
318+
app_name = _channel_app_name(channel)
315319

316320
input_model: Any = create_model(channel.input_schema)
317321
output_model: Any = create_model(channel.output_schema)

src/uipath_langchain/agent/tools/ixp_escalation_tool.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
from langchain_core.messages import ToolCall
77
from langchain_core.tools import StructuredTool
88
from pydantic import BaseModel
9-
from uipath.agent.models.agent import (
10-
AgentEscalationChannel,
11-
AgentIxpVsEscalationResourceConfig,
12-
)
9+
from uipath.agent.models.agent import AgentIxpVsEscalationResourceConfig
1310
from uipath.eval.mocks import mockable
1411
from uipath.platform import UiPath
1512
from uipath.platform.common import WaitDocumentExtractionValidation
@@ -29,6 +26,7 @@
2926
)
3027

3128
from ..exceptions import AgentRuntimeError, AgentRuntimeErrorCode
29+
from .escalation_tool import _channel_app_name
3230
from .structured_tool_with_output_type import StructuredToolWithOutputType
3331
from .utils import (
3432
resolve_task_title,
@@ -160,11 +158,7 @@ async def ixp_escalation_tool_wrapper(
160158
output_type=OutputSchema,
161159
metadata={
162160
"tool_type": "vs_escalation",
163-
"display_name": (
164-
channel.properties.app_name
165-
if isinstance(channel, AgentEscalationChannel)
166-
else None
167-
),
161+
"display_name": _channel_app_name(channel),
168162
"channel_type": channel.type,
169163
"ixp_tool_id": ixp_tool_name,
170164
"storage_bucket_name": storage_bucket_name,

0 commit comments

Comments
 (0)