From 7e39419435ba86e504d4dc52d531993516497b32 Mon Sep 17 00:00:00 2001 From: Maxwell Du <60411452+maxduu@users.noreply.github.com> Date: Fri, 24 Apr 2026 01:20:27 -0400 Subject: [PATCH 1/5] feat: allow conversation id to be part of convo agent prompt --- .../agent/react/conversational_prompts.py | 30 ++++++++++- .../react/test_conversational_prompts.py | 53 +++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/packages/uipath/src/uipath/agent/react/conversational_prompts.py b/packages/uipath/src/uipath/agent/react/conversational_prompts.py index 7732c7f69..0e05ba846 100644 --- a/packages/uipath/src/uipath/agent/react/conversational_prompts.py +++ b/packages/uipath/src/uipath/agent/react/conversational_prompts.py @@ -24,6 +24,7 @@ class PromptUserSettings(BaseModel): _AGENT_SYSTEM_PROMPT_PREFIX_TEMPLATE = """You are {{CONVERSATIONAL_AGENT_SERVICE_PREFIX_agentName}}. The current date is: {{CONVERSATIONAL_AGENT_SERVICE_PREFIX_currentDate}}. Understand user goals through conversation and use appropriate tools to fulfill requests. +{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}} ===================================================================== PRECEDENCE HIERARCHY @@ -136,18 +137,27 @@ class PromptUserSettings(BaseModel): {user_settings_json} ```""" +_CONVERSATION_ID_TEMPLATE = """ +The current conversation ID is {conversation_id}. +You should generally not discuss this conversation ID with the user, but it may be useful to include as a tool-call argument when relevant." +""" + def get_chat_system_prompt( model: str, system_message: str, agent_name: str | None, user_settings: PromptUserSettings | None = None, + conversation_id: str | None = None, ) -> str: """Generate a system prompt for a conversational agent. Args: agent_definition: Conversational agent definition user_settings: Optional user data that is injected into the system prompt. + conversation_id: Optional conversation identifier. When provided, the + prompt informs the model of the current conversation ID so it can + use it as a tool-call argument without surfacing it to the user. Returns: The complete system prompt string @@ -177,6 +187,10 @@ def get_chat_system_prompt( "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_userSettingsPrompt}}", get_user_settings_template(user_settings), ) + prompt = prompt.replace( + "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}", + get_conversation_id_template(conversation_id), + ) return prompt @@ -190,7 +204,7 @@ def get_user_settings_template( user_settings: User profile information Returns: - The user context template with JSON or empty string + The filled-in user settings template if user_settings is provided, otherwise an empty string """ if user_settings is None: return "" @@ -205,3 +219,17 @@ def get_user_settings_template( user_settings_json = json.dumps(settings_dict, ensure_ascii=False) return _USER_CONTEXT_TEMPLATE.format(user_settings_json=user_settings_json) + + +def get_conversation_id_template(conversation_id: str | None) -> str: + """Get the conversation-ID prompt section. + + Args: + conversation_id: The ID of the current conversation, if any + + Returns: + The filled-in conversation ID template if conversation_id is provided, otherwise an empty string + """ + if not conversation_id: + return "" + return _CONVERSATION_ID_TEMPLATE.format(conversation_id=conversation_id) diff --git a/packages/uipath/tests/agent/react/test_conversational_prompts.py b/packages/uipath/tests/agent/react/test_conversational_prompts.py index a58a94807..0a3c4231f 100644 --- a/packages/uipath/tests/agent/react/test_conversational_prompts.py +++ b/packages/uipath/tests/agent/react/test_conversational_prompts.py @@ -149,6 +149,59 @@ def test_generate_system_prompt_unnamed_agent_uses_default(self): assert "You are Unnamed Agent." in prompt +class TestConversationIdInPrompt: + """Tests for conversation_id in generated prompts.""" + + def test_prompt_includes_conversation_id_when_provided(self): + prompt = get_chat_system_prompt( + model="claude-3-sonnet", + system_message=SYSTEM_MESSAGE, + agent_name="Test Agent", + user_settings=None, + conversation_id="conv-abc-123", + ) + + assert "The current conversation ID is conv-abc-123" in prompt + assert "You should generally not discuss this conversation ID with the user, but it may be useful to include as a tool-call argument when relevant." in prompt + assert "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + + def test_prompt_omits_conversation_id_section_when_none(self): + prompt = get_chat_system_prompt( + model="claude-3-sonnet", + system_message=SYSTEM_MESSAGE, + agent_name="Test Agent", + user_settings=None, + conversation_id=None, + ) + + assert "conversation ID" not in prompt + assert "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + + def test_prompt_omits_conversation_id_section_when_empty_string(self): + prompt = get_chat_system_prompt( + model="claude-3-sonnet", + system_message=SYSTEM_MESSAGE, + agent_name="Test Agent", + user_settings=None, + conversation_id="", + ) + + assert "conversation ID" not in prompt + + def test_prompt_defaults_to_no_conversation_id(self): + """conversation_id parameter defaults to None — call sites that don't + pass it must not get a dangling placeholder.""" + prompt = get_chat_system_prompt( + model="claude-3-sonnet", + system_message=SYSTEM_MESSAGE, + agent_name="Test Agent", + user_settings=None, + ) + + assert "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + assert "conversation ID" not in prompt + + class TestCitationFormat: """Tests for citation format in generated prompts.""" From f60e65e5f26d7e9b9c1f1d0e7c9668339e3b60c6 Mon Sep 17 00:00:00 2001 From: Maxwell Du <60411452+maxduu@users.noreply.github.com> Date: Fri, 24 Apr 2026 01:20:52 -0400 Subject: [PATCH 2/5] fix: formatting --- .../agent/react/test_conversational_prompts.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/uipath/tests/agent/react/test_conversational_prompts.py b/packages/uipath/tests/agent/react/test_conversational_prompts.py index 0a3c4231f..5ec556d22 100644 --- a/packages/uipath/tests/agent/react/test_conversational_prompts.py +++ b/packages/uipath/tests/agent/react/test_conversational_prompts.py @@ -162,8 +162,13 @@ def test_prompt_includes_conversation_id_when_provided(self): ) assert "The current conversation ID is conv-abc-123" in prompt - assert "You should generally not discuss this conversation ID with the user, but it may be useful to include as a tool-call argument when relevant." in prompt - assert "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + assert ( + "You should generally not discuss this conversation ID with the user, but it may be useful to include as a tool-call argument when relevant." + in prompt + ) + assert ( + "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + ) def test_prompt_omits_conversation_id_section_when_none(self): prompt = get_chat_system_prompt( @@ -175,7 +180,9 @@ def test_prompt_omits_conversation_id_section_when_none(self): ) assert "conversation ID" not in prompt - assert "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + assert ( + "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + ) def test_prompt_omits_conversation_id_section_when_empty_string(self): prompt = get_chat_system_prompt( @@ -198,7 +205,9 @@ def test_prompt_defaults_to_no_conversation_id(self): user_settings=None, ) - assert "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + assert ( + "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt + ) assert "conversation ID" not in prompt From 6be5d66fb81d864c953ddff886cf283361b100ac Mon Sep 17 00:00:00 2001 From: Maxwell Du <60411452+maxduu@users.noreply.github.com> Date: Fri, 24 Apr 2026 01:46:24 -0400 Subject: [PATCH 3/5] chore: update comment --- .../uipath/src/uipath/agent/react/conversational_prompts.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/uipath/src/uipath/agent/react/conversational_prompts.py b/packages/uipath/src/uipath/agent/react/conversational_prompts.py index 0e05ba846..8066f436d 100644 --- a/packages/uipath/src/uipath/agent/react/conversational_prompts.py +++ b/packages/uipath/src/uipath/agent/react/conversational_prompts.py @@ -155,9 +155,7 @@ def get_chat_system_prompt( Args: agent_definition: Conversational agent definition user_settings: Optional user data that is injected into the system prompt. - conversation_id: Optional conversation identifier. When provided, the - prompt informs the model of the current conversation ID so it can - use it as a tool-call argument without surfacing it to the user. + conversation_id: Optional conversation identifier that is injected into the system prompt. Returns: The complete system prompt string From 53dcb34755487247782dfc239c6f5a45f7817723 Mon Sep 17 00:00:00 2001 From: Maxwell Du <60411452+maxduu@users.noreply.github.com> Date: Thu, 4 Jun 2026 12:18:02 -0500 Subject: [PATCH 4/5] fix: prompt and tests --- .../src/uipath/agent/react/conversational_prompts.py | 8 ++++---- .../tests/agent/react/test_conversational_prompts.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/uipath/src/uipath/agent/react/conversational_prompts.py b/packages/uipath/src/uipath/agent/react/conversational_prompts.py index 8066f436d..a9d0ea944 100644 --- a/packages/uipath/src/uipath/agent/react/conversational_prompts.py +++ b/packages/uipath/src/uipath/agent/react/conversational_prompts.py @@ -24,7 +24,6 @@ class PromptUserSettings(BaseModel): _AGENT_SYSTEM_PROMPT_PREFIX_TEMPLATE = """You are {{CONVERSATIONAL_AGENT_SERVICE_PREFIX_agentName}}. The current date is: {{CONVERSATIONAL_AGENT_SERVICE_PREFIX_currentDate}}. Understand user goals through conversation and use appropriate tools to fulfill requests. -{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}} ===================================================================== PRECEDENCE HIERARCHY @@ -63,6 +62,8 @@ class PromptUserSettings(BaseModel): - Never attempt calls with incomplete data - On errors: modify parameters or change approach (never retry identical calls) +{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}} + ===================================================================== TOOL RESULTS ===================================================================== @@ -138,8 +139,7 @@ class PromptUserSettings(BaseModel): ```""" _CONVERSATION_ID_TEMPLATE = """ -The current conversation ID is {conversation_id}. -You should generally not discuss this conversation ID with the user, but it may be useful to include as a tool-call argument when relevant." +The current conversation ID is {conversation_id}. This may be useful to include in tool-calls when tool parameters specify passing in the conversation ID. Other than tool-call inputs, this ID should not be mentioned to the user. """ @@ -220,7 +220,7 @@ def get_user_settings_template( def get_conversation_id_template(conversation_id: str | None) -> str: - """Get the conversation-ID prompt section. + """Get the conversation ID prompt section. Args: conversation_id: The ID of the current conversation, if any diff --git a/packages/uipath/tests/agent/react/test_conversational_prompts.py b/packages/uipath/tests/agent/react/test_conversational_prompts.py index 5ec556d22..434f68465 100644 --- a/packages/uipath/tests/agent/react/test_conversational_prompts.py +++ b/packages/uipath/tests/agent/react/test_conversational_prompts.py @@ -163,14 +163,14 @@ def test_prompt_includes_conversation_id_when_provided(self): assert "The current conversation ID is conv-abc-123" in prompt assert ( - "You should generally not discuss this conversation ID with the user, but it may be useful to include as a tool-call argument when relevant." + "This may be useful to include in tool-calls when tool parameters specify passing in the conversation ID." in prompt ) assert ( "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt ) - def test_prompt_omits_conversation_id_section_when_none(self): + def test_prompt_omits_section_when_none(self): prompt = get_chat_system_prompt( model="claude-3-sonnet", system_message=SYSTEM_MESSAGE, @@ -184,7 +184,7 @@ def test_prompt_omits_conversation_id_section_when_none(self): "{{CONVERSATIONAL_AGENT_SERVICE_PREFIX_conversationIdPrompt}}" not in prompt ) - def test_prompt_omits_conversation_id_section_when_empty_string(self): + def test_prompt_omits_section_when_empty_string(self): prompt = get_chat_system_prompt( model="claude-3-sonnet", system_message=SYSTEM_MESSAGE, @@ -196,8 +196,8 @@ def test_prompt_omits_conversation_id_section_when_empty_string(self): assert "conversation ID" not in prompt def test_prompt_defaults_to_no_conversation_id(self): - """conversation_id parameter defaults to None — call sites that don't - pass it must not get a dangling placeholder.""" + """conversation_id defaults to None — call sites that don't pass it + must not get a dangling placeholder.""" prompt = get_chat_system_prompt( model="claude-3-sonnet", system_message=SYSTEM_MESSAGE, From 0d3f203b66d9b838d94f082ecfce6e54dcca86bd Mon Sep 17 00:00:00 2001 From: Maxwell Du <60411452+maxduu@users.noreply.github.com> Date: Thu, 4 Jun 2026 12:20:55 -0500 Subject: [PATCH 5/5] fix: squash commits fix: update uv.lock fix: upgrade version --- packages/uipath/pyproject.toml | 2 +- .../uipath/src/uipath/agent/react/conversational_prompts.py | 4 +++- packages/uipath/uv.lock | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/uipath/pyproject.toml b/packages/uipath/pyproject.toml index fae01ad9c..c1a3ebddf 100644 --- a/packages/uipath/pyproject.toml +++ b/packages/uipath/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath" -version = "2.10.76" +version = "2.10.77" description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools." readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/packages/uipath/src/uipath/agent/react/conversational_prompts.py b/packages/uipath/src/uipath/agent/react/conversational_prompts.py index a9d0ea944..f79de6185 100644 --- a/packages/uipath/src/uipath/agent/react/conversational_prompts.py +++ b/packages/uipath/src/uipath/agent/react/conversational_prompts.py @@ -153,7 +153,9 @@ def get_chat_system_prompt( """Generate a system prompt for a conversational agent. Args: - agent_definition: Conversational agent definition + model: Model identifier. + system_message: The agent system prompt content. + agent_name: The agent display name; defaults to "Unnamed Agent" when None. user_settings: Optional user data that is injected into the system prompt. conversation_id: Optional conversation identifier that is injected into the system prompt. diff --git a/packages/uipath/uv.lock b/packages/uipath/uv.lock index 96764f7fb..cf11b2a5b 100644 --- a/packages/uipath/uv.lock +++ b/packages/uipath/uv.lock @@ -2552,7 +2552,7 @@ wheels = [ [[package]] name = "uipath" -version = "2.10.76" +version = "2.10.77" source = { editable = "." } dependencies = [ { name = "applicationinsights" },