Skip to content

Commit b8d2f65

Browse files
authored
feat: add set_conversational_output tool + generate-output prompt for conversational agents (#1785)
1 parent 1f3d655 commit b8d2f65

6 files changed

Lines changed: 63 additions & 2 deletions

File tree

packages/uipath/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.13.5"
3+
version = "2.13.6"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

packages/uipath/src/uipath/agent/react/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,31 @@
66
from .conversational_prompts import (
77
PromptUserSettings,
88
get_chat_system_prompt,
9+
get_generate_output_prompt,
910
)
1011
from .conversational_voice_prompts import get_voice_system_prompt
1112
from .prompts import AGENT_SYSTEM_PROMPT_TEMPLATE
1213
from .tools import (
1314
END_EXECUTION_TOOL,
1415
RAISE_ERROR_TOOL,
16+
SET_CONVERSATIONAL_OUTPUT_TOOL,
1517
EndExecutionToolSchemaModel,
1618
FlowControlToolConfig,
1719
RaiseErrorToolSchemaModel,
20+
SetConversationalOutputToolSchemaModel,
1821
)
1922

2023
__all__ = [
2124
"AGENT_SYSTEM_PROMPT_TEMPLATE",
2225
"FlowControlToolConfig",
2326
"END_EXECUTION_TOOL",
2427
"RAISE_ERROR_TOOL",
28+
"SET_CONVERSATIONAL_OUTPUT_TOOL",
2529
"EndExecutionToolSchemaModel",
2630
"RaiseErrorToolSchemaModel",
31+
"SetConversationalOutputToolSchemaModel",
2732
"PromptUserSettings",
2833
"get_chat_system_prompt",
34+
"get_generate_output_prompt",
2935
"get_voice_system_prompt",
3036
]

packages/uipath/src/uipath/agent/react/conversational_prompts.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,21 @@ def get_conversation_id_template(conversation_id: str | None) -> str:
233233
if not conversation_id:
234234
return ""
235235
return _CONVERSATION_ID_TEMPLATE.format(conversation_id=conversation_id)
236+
237+
238+
_GENERATE_OUTPUT_INSTRUCTION = """The conversational response for this turn has already been delivered to the user. Call the `set_conversational_output` tool to record the structured output fields for this turn.
239+
240+
Rules:
241+
- For each field, use values inferred from the conversation's recent turn.
242+
- For optional fields that are not yet relevant or determinable (e.g. the conversation is still gathering context, or the topic hasn't surfaced yet), omit them entirely.
243+
- For required fields that cannot yet be determined, provide a default placeholder. DO NOT fabricate, guess, or hallucinate meaningful values.
244+
- Do not produce any text response, as this will not be seen by the user. Only call the tool."""
245+
246+
247+
def get_generate_output_prompt() -> str:
248+
"""Return the framework-internal generate-output instruction.
249+
250+
Appended as a final user-message to the conversational structured-output
251+
node's LLM call.
252+
"""
253+
return _GENERATE_OUTPUT_INSTRUCTION

packages/uipath/src/uipath/agent/react/tools.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class FlowControlToolName(str, Enum):
1111

1212
END_EXECUTION = "end_execution"
1313
RAISE_ERROR = "raise_error"
14+
SET_CONVERSATIONAL_OUTPUT = "set_conversational_output"
1415

1516

1617
@dataclass(frozen=True)
@@ -72,3 +73,25 @@ class RaiseErrorToolSchemaModel(BaseModel):
7273
description="Raises an error and ends the execution of the agent",
7374
args_schema=RaiseErrorToolSchemaModel,
7475
)
76+
77+
78+
class SetConversationalOutputToolSchemaModel(BaseModel):
79+
"""Placeholder args_schema for the `set_conversational_output` tool.
80+
81+
Always overridden at construction time with the agent's stripped output
82+
schema (i.e. the user's `outputSchema` with `uipath__agent_response_messages`
83+
removed). Declared here so the tool entry has a well-typed default.
84+
"""
85+
86+
model_config = ConfigDict(extra="forbid")
87+
88+
89+
SET_CONVERSATIONAL_OUTPUT_TOOL = FlowControlToolConfig(
90+
name=FlowControlToolName.SET_CONVERSATIONAL_OUTPUT,
91+
description=(
92+
"Sets the structured output fields for the current conversational "
93+
"turn. Called once per turn after the conversational response has been "
94+
"delivered, to populate fields as the agent's output."
95+
),
96+
args_schema=SetConversationalOutputToolSchemaModel,
97+
)

packages/uipath/tests/agent/react/test_conversational_prompts.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from uipath.agent.react.conversational_prompts import (
99
PromptUserSettings,
1010
get_chat_system_prompt,
11+
get_generate_output_prompt,
1112
get_user_settings_template,
1213
)
1314

@@ -348,3 +349,16 @@ def test_full_settings_json_format(self):
348349
assert json_data["company"] == "Big Corp"
349350
assert json_data["country"] == "UK"
350351
assert json_data["timezone"] == "Europe/London"
352+
353+
354+
class TestGetGenerateOutputPrompt:
355+
"""Tests for get_generate_output_prompt function."""
356+
357+
def test_returns_non_empty_string(self):
358+
instruction = get_generate_output_prompt()
359+
assert isinstance(instruction, str)
360+
assert instruction.strip()
361+
362+
def test_references_set_conversational_output_tool(self):
363+
"""The instruction must name the tool the new node binds."""
364+
assert "set_conversational_output" in get_generate_output_prompt()

packages/uipath/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)