Skip to content

feat: add set_conversational_output tool + generate-output prompt for conversational agents#1785

Open
maxduu wants to merge 2 commits into
mainfrom
convo-agent-output
Open

feat: add set_conversational_output tool + generate-output prompt for conversational agents#1785
maxduu wants to merge 2 commits into
mainfrom
convo-agent-output

Conversation

@maxduu

@maxduu maxduu commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Two additive changes in uipath/agent/react/:

  1. New flow-control tool set_conversational_output — a framework-internal tool bound by the langchain runtime's GENERATE_CONVERSATIONAL_OUTPUT node to reliably extract structured output fields from a conversational agent's turn. Mirrors the existing end_execution/raise_error shape.
  2. New generate-output instruction prompt — the framework-internal HumanMessage appended to the extraction LLM call, telling the model to fill the tool's args from the conversation with per-turn priority and "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:

Test plan

  • `uv run pytest packages/uipath/tests/agent/react/test_conversational_prompts.py` (26 tests pass)
  • `ruff check` + `ruff format --check` clean

Copilot AI review requested due to automatic review settings July 2, 2026 05:55
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-integrations labels Jul 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants