|
14 | 14 | AgentEscalationRecipient, |
15 | 15 | AgentEscalationRecipientType, |
16 | 16 | AgentEscalationResourceConfig, |
| 17 | + AgentQuickFormEscalationChannel, |
17 | 18 | ArgumentEmailRecipient, |
18 | 19 | ArgumentGroupNameRecipient, |
19 | 20 | AssetRecipient, |
@@ -254,10 +255,19 @@ def create_escalation_tool( |
254 | 255 | resource: AgentEscalationResourceConfig, |
255 | 256 | agent: LowCodeAgentDefinition | None = None, |
256 | 257 | ) -> StructuredTool: |
257 | | - """Uses interrupt() for Action Center human-in-the-loop.""" |
| 258 | + """Uses interrupt() for Action Center human-in-the-loop. |
| 259 | +
|
| 260 | + Handles both Action Center app-task channels (``actionCenter``) and |
| 261 | + quick-form channels (``actionCenterQuickForm``). Quick-form channels render |
| 262 | + a schema-first FormLib task via |
| 263 | + :meth:`uipath.platform.action_center.tasks.TasksService.create_quickform_async` |
| 264 | + using ``channel.properties.schema`` instead of dispatching to an Action |
| 265 | + Center app. |
| 266 | + """ |
258 | 267 |
|
259 | 268 | tool_name: str = f"escalate_{sanitize_tool_name(resource.name)}" |
260 | 269 | channel: AgentEscalationChannel = resource.channels[0] |
| 270 | + is_quick_form = isinstance(channel, AgentQuickFormEscalationChannel) |
261 | 271 |
|
262 | 272 | input_model: Any = create_model(channel.input_schema) |
263 | 273 | output_model: Any = create_model(channel.output_schema) |
@@ -327,25 +337,50 @@ async def escalate(**_tool_kwargs: Any): |
327 | 337 | @durable_interrupt |
328 | 338 | async def create_escalation_task(): |
329 | 339 | client = UiPath() |
330 | | - created_task = await client.tasks.create_async( |
331 | | - title=task_title, |
332 | | - data=serialized_data, |
333 | | - app_name=channel.properties.app_name, |
334 | | - app_folder_path=folder_path, |
335 | | - recipient=recipient, |
336 | | - priority=channel.priority, |
337 | | - labels=channel.labels, |
338 | | - is_actionable_message_enabled=channel.properties.is_actionable_message_enabled, |
339 | | - actionable_message_metadata=channel.properties.actionable_message_meta_data, |
340 | | - ) |
| 340 | + if isinstance(channel, AgentQuickFormEscalationChannel): |
| 341 | + schema_id = channel.properties.schema_id |
| 342 | + if schema_id is None: |
| 343 | + raise AgentRuntimeError( |
| 344 | + code=AgentRuntimeErrorCode.TERMINATION_ESCALATION_ERROR, |
| 345 | + title="Quick form escalation is missing a schema id", |
| 346 | + detail=( |
| 347 | + f"Escalation '{resource.name}' has a quick form " |
| 348 | + "schema without a schemaId." |
| 349 | + ), |
| 350 | + category=UiPathErrorCategory.USER, |
| 351 | + ) |
| 352 | + created_task = await client.tasks.create_quickform_async( |
| 353 | + title=task_title, |
| 354 | + task_schema_key=schema_id, |
| 355 | + schema=channel.properties.schema, |
| 356 | + data=serialized_data, |
| 357 | + folder_path=folder_path, |
| 358 | + recipient=recipient, |
| 359 | + priority=channel.priority, |
| 360 | + labels=channel.labels, |
| 361 | + is_actionable_message_enabled=channel.properties.is_actionable_message_enabled, |
| 362 | + actionable_message_metadata=channel.properties.actionable_message_meta_data, |
| 363 | + ) |
| 364 | + else: |
| 365 | + created_task = await client.tasks.create_async( |
| 366 | + title=task_title, |
| 367 | + data=serialized_data, |
| 368 | + app_name=channel.properties.app_name, |
| 369 | + app_folder_path=folder_path, |
| 370 | + recipient=recipient, |
| 371 | + priority=channel.priority, |
| 372 | + labels=channel.labels, |
| 373 | + is_actionable_message_enabled=channel.properties.is_actionable_message_enabled, |
| 374 | + actionable_message_metadata=channel.properties.actionable_message_meta_data, |
| 375 | + ) |
341 | 376 |
|
342 | 377 | if created_task.id is not None: |
343 | 378 | _bts_context["task_key"] = str(created_task.id) |
344 | 379 |
|
345 | 380 | return WaitEscalation( |
346 | 381 | action=created_task, |
347 | 382 | app_folder_path=folder_path, |
348 | | - app_name=channel.properties.app_name, |
| 383 | + app_name=None if is_quick_form else channel.properties.app_name, |
349 | 384 | recipient=recipient, |
350 | 385 | ) |
351 | 386 |
|
@@ -487,7 +522,7 @@ async def escalation_wrapper( |
487 | 522 | argument_properties=channel.argument_properties, |
488 | 523 | metadata={ |
489 | 524 | "tool_type": "escalation", |
490 | | - "display_name": channel.properties.app_name, |
| 525 | + "display_name": channel.properties.app_name or channel.name, |
491 | 526 | "channel_type": channel.type, |
492 | 527 | "recipient": None, |
493 | 528 | "args_schema": input_model, |
|
0 commit comments