Skip to content

Commit 675fe21

Browse files
authored
Merge pull request #191 from UiPath/feat/structured-output-support
feat: structured output support for schema inference and runtime extraction
2 parents fc1970c + 3e6ff28 commit 675fe21

22 files changed

Lines changed: 902 additions & 31 deletions

File tree

packages/uipath-agent-framework/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-agent-framework"
3-
version = "0.0.7"
3+
version = "0.0.8"
44
description = "Python SDK that enables developers to build and deploy Microsoft Agent Framework agents to the UiPath Cloud Platform"
55
readme = "README.md"
66
requires-python = ">=3.11"

packages/uipath-agent-framework/samples/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ Sample agents built with [Agent Framework](https://github.com/microsoft/agent-fr
77
| Sample | Description |
88
|--------|-------------|
99
| [quickstart-workflow](./quickstart-workflow/) | Single workflow agent with tool calling: fetches live weather data for any location |
10-
| [group-chat](./group-chat/) | Group chat orchestration: researcher, critic, and writer discuss a topic with an orchestrator picking speakers |
10+
| [structured-output](./structured-output/) | Structured output workflow: extracts city information and returns it as a typed Pydantic model |
11+
| [sequential-structured-output](./sequential-structured-output/) | Sequential pipeline with structured output: researcher and editor agents produce a typed Pydantic city profile |
12+
| [hitl-workflow](./hitl-workflow/) | Human-in-the-loop workflow: customer support with approval-gated billing and refund operations |
13+
| [sequential](./sequential/) | Sequential pipeline: writer, reviewer, and editor agents process a task one after another |
1114
| [concurrent](./concurrent/) | Concurrent orchestration: sentiment, topic extraction, and summarization agents analyze text in parallel |
1215
| [handoff](./handoff/) | Handoff orchestration: customer support agents transfer control to specialists with explicit routing rules |
13-
| [hitl-workflow](./hitl-workflow/) | Human-in-the-loop workflow: customer support with approval-gated billing and refund operations |
16+
| [group-chat](./group-chat/) | Group chat orchestration: researcher, critic, and writer discuss a topic with an orchestrator picking speakers |
17+
| [magentic](./magentic/) | Magentic-One orchestration: a manager dynamically coordinates researcher and analyst agents based on task progress |

packages/uipath-agent-framework/samples/hitl-workflow/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ uipath run agent '{"messages": [{"contentParts": [{"data": {"inline": "Transfer
5757
```
5858
uipath dev web
5959
```
60+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"agents": {
3+
"agent": "main.py:agent"
4+
}
5+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Sequential + Structured Output
2+
3+
A sequential pipeline that combines multi-agent processing with structured output. A researcher gathers facts about a city, then an editor organizes them into a well-defined Pydantic model (`CityInfo`). The final output is a typed JSON object — not free-form text.
4+
5+
## Agent Graph
6+
7+
```mermaid
8+
flowchart TB
9+
__start__(__start__)
10+
__end__(__end__)
11+
input-conversation(input-conversation)
12+
researcher(researcher)
13+
editor(editor)
14+
end_(end)
15+
__start__ --> |input|input-conversation
16+
input-conversation --> researcher
17+
researcher --> editor
18+
editor --> end_
19+
end_ --> |output|__end__
20+
```
21+
22+
Internally, the sequential orchestration chains:
23+
- **researcher** — gathers key facts about the city (country, population, landmarks, cultural significance)
24+
- **editor** — organizes the research into a structured `CityInfo` schema with `response_format`
25+
26+
Each agent sees the full conversation history from previous agents. The last agent's `response_format` determines the output schema.
27+
28+
## Prerequisites
29+
30+
Authenticate with UiPath to configure your `.env` file:
31+
32+
```bash
33+
uipath auth
34+
```
35+
36+
## Run
37+
38+
```
39+
uipath run agent '{"messages": [{"contentParts": [{"data": {"inline": "Tell me about Tokyo"}}], "role": "user"}]}'
40+
```
41+
42+
## Debug
43+
44+
```
45+
uipath dev web
46+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
flowchart TB
2+
__start__(__start__)
3+
__end__(__end__)
4+
input-conversation(input-conversation)
5+
researcher(researcher)
6+
editor(editor)
7+
end(end)
8+
__start__ --> |input|input-conversation
9+
input-conversation --> researcher
10+
researcher --> editor
11+
editor --> end
12+
end --> |output|__end__
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"agents": {
3+
"agent": "main.py:agent"
4+
}
5+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from agent_framework.orchestrations import SequentialBuilder
2+
from pydantic import BaseModel
3+
4+
from uipath_agent_framework.chat import UiPathOpenAIChatClient
5+
6+
7+
class CityInfo(BaseModel):
8+
"""Structured output for city information."""
9+
10+
city: str
11+
country: str
12+
description: str
13+
population_estimate: str
14+
famous_for: list[str]
15+
16+
17+
client = UiPathOpenAIChatClient(model="gpt-5-mini-2025-08-07")
18+
19+
researcher = client.as_agent(
20+
name="researcher",
21+
description="Researches factual information about a city.",
22+
instructions=(
23+
"You are a thorough researcher. Given a city name, gather key facts "
24+
"including its country, population, notable landmarks, cultural "
25+
"significance, and what it is famous for. Present your findings clearly."
26+
),
27+
)
28+
29+
editor = client.as_agent(
30+
name="editor",
31+
description="Edits research into a structured city profile.",
32+
instructions=(
33+
"You are a precise editor. Take the researcher's findings and organize "
34+
"them into a well-structured city profile. Ensure all facts are accurate "
35+
"and the description is concise and informative."
36+
),
37+
default_options={"response_format": CityInfo},
38+
)
39+
40+
workflow = SequentialBuilder(
41+
participants=[researcher, editor],
42+
).build()
43+
44+
agent = workflow.as_agent(name="sequential_structured_output_workflow")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[project]
2+
name = "sequential-structured-output"
3+
version = "0.0.1"
4+
description = "Sequential + structured output: agents process a task in a pipeline, the last agent returns data in a well-defined Pydantic schema"
5+
authors = [{ name = "John Doe" }]
6+
readme = "README.md"
7+
requires-python = ">=3.11"
8+
dependencies = [
9+
"uipath",
10+
"uipath-agent-framework",
11+
"agent-framework-core>=1.0.0rc1",
12+
"agent-framework-orchestrations>=1.0.0b260219",
13+
]
14+
15+
[dependency-groups]
16+
dev = [
17+
"uipath-dev",
18+
]
19+
20+
[tool.uv]
21+
prerelease = "allow"
22+
23+
[tool.uv.sources]
24+
uipath-dev = { path = "../../../../../uipath-dev-python", editable = true }
25+
uipath-agent-framework = { path = "../../", editable = true }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://cloud.uipath.com/draft/2024-12/uipath",
3+
"runtimeOptions": {
4+
"isConversational": false
5+
},
6+
"packOptions": {
7+
"fileExtensionsIncluded": [],
8+
"filesIncluded": [],
9+
"filesExcluded": [],
10+
"directoriesExcluded": [],
11+
"includeUvLock": true
12+
},
13+
"functions": {}
14+
}

0 commit comments

Comments
 (0)