feat: add set_conversational_output tool + generate-output prompt for conversational agents#1785
Open
maxduu wants to merge 2 commits into
Open
feat: add set_conversational_output tool + generate-output prompt for conversational agents#1785maxduu wants to merge 2 commits into
set_conversational_output tool + generate-output prompt for conversational agents#1785maxduu wants to merge 2 commits into
Conversation
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds framework primitives in uipath.agent.react to support reliable structured-output extraction for conversational agents by introducing a new flow-control tool (set_conversational_output) and a dedicated generate-output instruction prompt used during extraction.
Changes:
- Added
SET_CONVERSATIONAL_OUTPUT_TOOL(and supporting enum + placeholder schema model) to the ReAct flow-control tool set. - Added
_GENERATE_OUTPUT_INSTRUCTION+get_generate_output_prompt()to provide an internal instruction prompt for structured-output extraction. - Added tests validating the presence and key constraints of the generate-output prompt.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/uipath/src/uipath/agent/react/tools.py | Adds the new flow-control tool name, placeholder args schema model, and exported tool config. |
| packages/uipath/src/uipath/agent/react/conversational_prompts.py | Adds the generate-output instruction constant and accessor used during structured-output extraction. |
| packages/uipath/src/uipath/agent/react/init.py | Exports the new tool constant, schema model, and prompt accessor. |
| packages/uipath/tests/agent/react/test_conversational_prompts.py | Adds tests for the new generate-output prompt accessor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+354
to
+356
| class TestGetGenerateOutputInstruction: | ||
| """Tests for get_generate_output_prompt function.""" | ||
|
|
Comment on lines
+238
to
+244
| _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. | ||
|
|
||
| Rules: | ||
| - For each field, use values inferred from the conversation's recent turn. | ||
| - For optional fields that are not yet relevant or determinable from the conversation so far, omit them entirely. | ||
| - For required fields that cannot yet be determined (e.g., the conversation is still gathering context, or the topic hasn't surfaced yet), use a clear placeholder value (e.g. "N/A" or "unknown" for string fields). DO NOT fabricate, guess, or hallucinate values. | ||
| - Do not produce any text content — only call the tool.""" |
Comment on lines
+78
to
+87
| class SetConversationalOutputToolSchemaModel(BaseModel): | ||
| """Placeholder args_schema for the `set_conversational_output` tool. | ||
|
|
||
| Always overridden at construction time with the agent's stripped output | ||
| schema (i.e. the user's `outputSchema` with `uipath__agent_response_messages` | ||
| removed). Declared here so the tool entry has a well-typed default. | ||
| """ | ||
|
|
||
| model_config = ConfigDict(extra="forbid") | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Two additive changes in
uipath/agent/react/:set_conversational_output— a framework-internal tool bound by the langchain runtime'sGENERATE_CONVERSATIONAL_OUTPUTnode to reliably extract structured output fields from a conversational agent's turn. Mirrors the existingend_execution/raise_errorshape."N/A"-placeholder rules for un-yet-determinable required fields.Context
Part of a four-PR series enabling reliable structured-output extraction for conversational agents. This PR only adds primitives to `uipath`; the graph wiring lives in uipath-langchain, the runtime gating in uipath-agents, and the FPS field in uipath-runtime.
Related PRs
Part of a coordinated four-repo change. Each PR is independently reviewable, but they land together:
conversationalService.enableOutputsFPS flag onUiPathRuntimeContextuipath-runtime-python#142 — surfaces theconversationalService.enableOutputsFPS flag onUiPathRuntimeContext.set_conversational_outputtool + generate-output prompt for conversational agents #1785 — adds theset_conversational_outputflow-control tool + generate-output prompt primitives.GENERATE_CONVERSATIONAL_OUTPUTnode for reliable structured-output extraction uipath-langchain-python#965 — implements theGENERATE_CONVERSATIONAL_OUTPUTgraph node, router path, and terminate extraction (the main change).build_agent_graph.Test plan