Skip to content

Commit 0afafbd

Browse files
committed
chore: system agent invocation sample
1 parent 7cfce44 commit 0afafbd

15 files changed

Lines changed: 4264 additions & 0 deletions

samples/system-agent-invocation/.agent/CLI_REFERENCE.md

Lines changed: 578 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
## Required Agent Structure
2+
3+
**IMPORTANT**: All UiPath coded agents MUST follow this standard structure unless explicitly specified otherwise by the user.
4+
5+
### Required Components
6+
7+
Every agent implementation MUST include these three Pydantic models:
8+
9+
```python
10+
from pydantic import BaseModel
11+
12+
class Input(BaseModel):
13+
"""Define input fields that the agent accepts"""
14+
# Add your input fields here
15+
pass
16+
17+
class State(BaseModel):
18+
"""Define the agent's internal state that flows between nodes"""
19+
# Add your state fields here
20+
pass
21+
22+
class Output(BaseModel):
23+
"""Define output fields that the agent returns"""
24+
# Add your output fields here
25+
pass
26+
```
27+
28+
### Required LLM Initialization
29+
30+
Unless the user explicitly requests a different LLM provider, always use `UiPathChat`:
31+
32+
```python
33+
from uipath_langchain.chat import UiPathChat
34+
35+
llm = UiPathChat(model="gpt-4o-2024-08-06", temperature=0.7)
36+
```
37+
38+
**Alternative LLMs** (only use if explicitly requested):
39+
- `ChatOpenAI` from `langchain_openai`
40+
- `ChatAnthropic` from `langchain_anthropic`
41+
- Other LangChain-compatible LLMs
42+
43+
### Standard Agent Template
44+
45+
Every agent should follow this basic structure:
46+
47+
```python
48+
from langchain_core.messages import SystemMessage, HumanMessage
49+
from langgraph.graph import START, StateGraph, END
50+
from uipath_langchain.chat import UiPathChat
51+
from pydantic import BaseModel
52+
53+
# 1. Define Input, State, and Output models
54+
class Input(BaseModel):
55+
field: str
56+
57+
class State(BaseModel):
58+
field: str
59+
result: str = ""
60+
61+
class Output(BaseModel):
62+
result: str
63+
64+
# 2. Initialize UiPathChat LLM
65+
llm = UiPathChat(model="gpt-4o-2024-08-06", temperature=0.7)
66+
67+
# 3. Define agent nodes (async functions)
68+
async def process_node(state: State) -> State:
69+
response = await llm.ainvoke([HumanMessage(state.field)])
70+
return State(field=state.field, result=response.content)
71+
72+
async def output_node(state: State) -> Output:
73+
return Output(result=state.result)
74+
75+
# 4. Build the graph
76+
builder = StateGraph(State, input=Input, output=Output)
77+
builder.add_node("process", process_node)
78+
builder.add_node("output", output_node)
79+
builder.add_edge(START, "process")
80+
builder.add_edge("process", "output")
81+
builder.add_edge("output", END)
82+
83+
# 5. Compile the graph
84+
graph = builder.compile()
85+
```
86+
87+
**Key Rules**:
88+
1. Always use async/await for all node functions
89+
2. All nodes (except output) must accept and return `State`
90+
3. The final output node must return `Output`
91+
4. Use `StateGraph(State, input=Input, output=Output)` for initialization
92+
5. Always compile with `graph = builder.compile()`

samples/system-agent-invocation/.agent/SDK_REFERENCE.md

Lines changed: 468 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Agent Code Patterns Reference
2+
3+
This document provides practical code patterns for building UiPath coded agents using LangGraph and the UiPath Python SDK.
4+
5+
---
6+
7+
## Documentation Structure
8+
9+
This documentation is split into multiple files for efficient context loading. Load only the files you need:
10+
11+
1. **@.agent/REQUIRED_STRUCTURE.md** - Agent structure patterns and templates
12+
- **When to load:** Creating a new agent or understanding required patterns
13+
- **Contains:** Required Pydantic models (Input, State, Output), LLM initialization patterns, standard agent template
14+
15+
2. **@.agent/SDK_REFERENCE.md** - Complete SDK API reference
16+
- **When to load:** Calling UiPath SDK methods, working with services (actions, assets, jobs, etc.)
17+
- **Contains:** All SDK services and methods with full signatures and type annotations
18+
19+
3. **@.agent/CLI_REFERENCE.md** - CLI commands documentation
20+
- **When to load:** Working with `uipath init`, `uipath run`, or `uipath eval` commands
21+
- **Contains:** Command syntax, options, usage examples, and workflows
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
flowchart TB
2+
__start__(__start__)
3+
generate_report(generate_report)
4+
__end__(__end__)
5+
__start__ --> generate_report
6+
generate_report --> __end__
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "2.0",
3+
"resources": []
4+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"$schema": "https://cloud.uipath.com/draft/2024-12/entry-point",
3+
"$id": "entry-points.json",
4+
"entryPoints": [
5+
{
6+
"filePath": "agent",
7+
"uniqueId": "3f503540-0374-44aa-be6d-7b0c4731c10a",
8+
"type": "agent",
9+
"input": {
10+
"type": "object",
11+
"properties": {
12+
"system_agent_name": {
13+
"title": "System Agent Name",
14+
"type": "string"
15+
},
16+
"entrypoint": {
17+
"title": "Entrypoint",
18+
"type": "string"
19+
},
20+
"system_agent_input": {
21+
"additionalProperties": true,
22+
"type": "object"
23+
},
24+
"folder_path": {
25+
"title": "Folder Path",
26+
"type": "string"
27+
}
28+
},
29+
"required": [
30+
"system_agent_name",
31+
"entrypoint",
32+
"folder_path"
33+
]
34+
},
35+
"output": {
36+
"type": "object",
37+
"properties": {
38+
"sys_agent_response": {
39+
"type": "string"
40+
}
41+
},
42+
"required": [
43+
"sys_agent_response"
44+
]
45+
},
46+
"graph": {
47+
"nodes": [
48+
{
49+
"id": "__start__",
50+
"name": "__start__",
51+
"type": "__start__",
52+
"subgraph": null,
53+
"metadata": {}
54+
},
55+
{
56+
"id": "generate_report",
57+
"name": "generate_report",
58+
"type": "node",
59+
"subgraph": null,
60+
"metadata": {}
61+
},
62+
{
63+
"id": "__end__",
64+
"name": "__end__",
65+
"type": "__end__",
66+
"subgraph": null,
67+
"metadata": {}
68+
}
69+
],
70+
"edges": [
71+
{
72+
"source": "__start__",
73+
"target": "generate_report",
74+
"label": null
75+
},
76+
{
77+
"source": "generate_report",
78+
"target": "__end__",
79+
"label": null
80+
}
81+
]
82+
}
83+
}
84+
]
85+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"system_agent_name": "low-code-convert-agent",
3+
"entrypoint": "agent",
4+
"system_agent_input": {
5+
"source_project_id": "168ea8be-6f8d-4785-a962-c10b3b20f7ba",
6+
"target_solution_id": "bdef7d66-6882-4848-1ad5-08de31825521",
7+
"new_project_name": "converted ixp file",
8+
"author": "radu.mocanu@email.com",
9+
"description": "description for example project"
10+
},
11+
"folder_path": "radu.mocanu@uipath.com's workspace"
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"system_agent_name": "",
3+
"entrypoint": "",
4+
"system_agent_input": {
5+
},
6+
"folder_path": ""
7+
}

0 commit comments

Comments
 (0)