|
| 1 | +# Python Coded Agents |
| 2 | + |
| 3 | +A coded agent is Python code that uses an LLM reasoning loop to make decisions, call tools, and produce a result. You write the agent logic using a framework of your choice — the `uipath` SDK provides the platform layer: authentication, assets, buckets, connections, tracing, and human-in-the-loop. Package it with the CLI and deploy it as an Orchestrator job. |
| 4 | + |
| 5 | +Use a coded agent when your automation needs multi-step reasoning, dynamic tool selection, or LLM-driven decisions. Use a [coded function](./functions.md) when your logic is deterministic and no LLM is required. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +Every coded agent is built from two layers: |
| 12 | + |
| 13 | +| Layer | Package | Responsibility | |
| 14 | +|-------|---------|---------------| |
| 15 | +| **Platform** | `uipath` | Auth, assets, buckets, connections, tracing, human-in-the-loop, CLI, packaging | |
| 16 | +| **Framework** | one extension (see below) | LLM calls, tool routing, agent loop, memory | |
| 17 | + |
| 18 | +The `uipath` package is always required. Add one framework extension on top: |
| 19 | + |
| 20 | +| Framework | Package | Best for | |
| 21 | +|-----------|---------|---------| |
| 22 | +| LangChain / LangGraph | `uipath-langchain` | Graph-based agents, complex multi-step flows | |
| 23 | +| LlamaIndex | `uipath-llamaindex` | RAG-heavy agents, document reasoning | |
| 24 | +| OpenAI Agents SDK | `uipath-openai-agents` | OpenAI-native tool use, handoffs | |
| 25 | +| PydanticAI | `uipath-pydantic-ai` | Type-safe agents with Pydantic models | |
| 26 | +| Google ADK | `uipath-google-adk` | Gemini models, Google ecosystem | |
| 27 | +| UiPath Agent Framework | `uipath-agent-framework` | UiPath-native agent primitives | |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Quickstart |
| 32 | + |
| 33 | +The example below uses LangChain. Swap `uipath-langchain` for the framework of your choice. |
| 34 | + |
| 35 | +//// tab | uv |
| 36 | + |
| 37 | +<!-- termynal --> |
| 38 | + |
| 39 | +```shell |
| 40 | +> mkdir my-agent && cd my-agent |
| 41 | +> uv init . --python 3.11 |
| 42 | +> uv add uipath uipath-langchain |
| 43 | + |
| 44 | +> uipath auth |
| 45 | +⠋ Authenticating with UiPath ... |
| 46 | +✓ Authentication successful. |
| 47 | + |
| 48 | +> uipath new agent |
| 49 | +✓ Created new agent project. |
| 50 | + |
| 51 | +> uipath init |
| 52 | +⠋ Initializing UiPath project ... |
| 53 | +✓ Created 'entry-points.json' file. |
| 54 | +✓ Created 'bindings.json' file. |
| 55 | + |
| 56 | +> uipath run agent '{"message": "hello"}' |
| 57 | +``` |
| 58 | + |
| 59 | +//// |
| 60 | + |
| 61 | +//// tab | pip |
| 62 | + |
| 63 | +<!-- termynal --> |
| 64 | + |
| 65 | +```shell |
| 66 | +> mkdir my-agent && cd my-agent |
| 67 | +> python -m venv .venv |
| 68 | +> source .venv/bin/activate |
| 69 | +> pip install uipath uipath-langchain |
| 70 | + |
| 71 | +> uipath auth |
| 72 | +⠋ Authenticating with UiPath ... |
| 73 | +✓ Authentication successful. |
| 74 | + |
| 75 | +> uipath new agent |
| 76 | +✓ Created new agent project. |
| 77 | + |
| 78 | +> uipath init |
| 79 | +⠋ Initializing UiPath project ... |
| 80 | +✓ Created 'entry-points.json' file. |
| 81 | +✓ Created 'bindings.json' file. |
| 82 | + |
| 83 | +> uipath run agent '{"message": "hello"}' |
| 84 | +``` |
| 85 | + |
| 86 | +//// |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## Project Structure |
| 91 | + |
| 92 | +``` |
| 93 | +my-agent/ |
| 94 | +├── main.py # agent logic |
| 95 | +├── pyproject.toml # project metadata and dependencies |
| 96 | +├── uipath.json # entry point declarations |
| 97 | +├── entry-points.json # generated — I/O JSON Schema |
| 98 | +└── bindings.json # generated — resource binding overrides |
| 99 | +``` |
| 100 | + |
| 101 | +### `uipath.json` |
| 102 | + |
| 103 | +```json |
| 104 | +{ |
| 105 | + "agents": { |
| 106 | + "agent": "main.py:agent" |
| 107 | + } |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +### `pyproject.toml` |
| 112 | + |
| 113 | +```toml |
| 114 | +[project] |
| 115 | +name = "my-agent" |
| 116 | +version = "0.1.0" |
| 117 | +description = "..." |
| 118 | +authors = [{ name = "Your Name", email = "you@example.com" }] |
| 119 | +requires-python = ">=3.11" |
| 120 | +dependencies = ["uipath>=2.0", "uipath-langchain>=2.0"] |
| 121 | + |
| 122 | +[tool.uipath] |
| 123 | +type = "agent" |
| 124 | +``` |
| 125 | + |
| 126 | +`[tool.uipath] type = "agent"` is required — it identifies the project as an agent to the runtime and packaging tools. |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Input & Output |
| 131 | + |
| 132 | +Define `Input` and `Output` as Python dataclasses, the same way as [coded functions](./functions.md#input--output): |
| 133 | + |
| 134 | +```python |
| 135 | +from dataclasses import dataclass |
| 136 | + |
| 137 | + |
| 138 | +@dataclass |
| 139 | +class Input: |
| 140 | + message: str |
| 141 | + |
| 142 | + |
| 143 | +@dataclass |
| 144 | +class Output: |
| 145 | + response: str |
| 146 | + |
| 147 | + |
| 148 | +def agent(input: Input) -> Output: |
| 149 | + ... |
| 150 | +``` |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +## Platform Services |
| 155 | + |
| 156 | +The `uipath` SDK gives your agent access to Orchestrator resources at runtime — credentials are injected automatically when running as a job. |
| 157 | + |
| 158 | +```python |
| 159 | +from uipath.platform import UiPath |
| 160 | + |
| 161 | +sdk = UiPath() |
| 162 | +``` |
| 163 | + |
| 164 | +The full set of Orchestrator services is available to agents: |
| 165 | + |
| 166 | +- **Assets** — read credentials and configuration: [Assets reference](./assets.md) |
| 167 | +- **Buckets** — download and upload files: [Buckets reference](./buckets.md) |
| 168 | +- **Connections** — Integration Service connections for ERP and SaaS: [Connections reference](./connections.md) |
| 169 | +- **Context Grounding** — semantic search over enterprise data: [Context Grounding reference](./context_grounding.md) |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +## Tracing |
| 174 | + |
| 175 | +Apply `@traced` to custom steps inside your agent to make them visible in the Orchestrator job trace view and Maestro dashboards. Do **not** trace the entry point — the runtime wraps it automatically. |
| 176 | + |
| 177 | +```python |
| 178 | +from uipath.tracing import traced |
| 179 | + |
| 180 | + |
| 181 | +@traced(name="lookup_vendor", run_type="uipath") |
| 182 | +def lookup_vendor(vendor_id: str) -> dict: |
| 183 | + ... |
| 184 | +``` |
| 185 | + |
| 186 | +See [Tracing](./traced.md) for the full decorator reference. |
| 187 | + |
| 188 | +--- |
| 189 | + |
| 190 | +## Framework Guides |
| 191 | + |
| 192 | +Each framework extension has its own getting started guide and sample agents: |
| 193 | + |
| 194 | +| Framework | Guide | Samples | |
| 195 | +|-----------|-------|---------| |
| 196 | +| LangChain / LangGraph | [Get Started](../langchain/quick_start.md) | [Samples](https://github.com/UiPath/uipath-langchain-python/tree/main/samples) | |
| 197 | +| LlamaIndex | [Get Started](../llamaindex/quick_start.md) | [Samples](https://github.com/UiPath/uipath-integrations-python/tree/main/packages/uipath-llamaindex/samples) | |
| 198 | +| OpenAI Agents SDK | [Get Started](../openai-agents/quick_start.md) | [Samples](https://github.com/UiPath/uipath-integrations-python/tree/main/packages/uipath-openai-agents/samples) | |
| 199 | +| PydanticAI | [README](https://github.com/UiPath/uipath-integrations-python/blob/main/packages/uipath-pydantic-ai/README.md) | [Samples](https://github.com/UiPath/uipath-integrations-python/tree/main/packages/uipath-pydantic-ai/samples) | |
| 200 | +| Google ADK | [README](https://github.com/UiPath/uipath-integrations-python/blob/main/packages/uipath-google-adk/README.md) | [Samples](https://github.com/UiPath/uipath-integrations-python/tree/main/packages/uipath-google-adk/samples) | |
| 201 | +| UiPath Agent Framework | [README](https://github.com/UiPath/uipath-integrations-python/blob/main/packages/uipath-agent-framework/README.md) | [Samples](https://github.com/UiPath/uipath-integrations-python/tree/main/packages/uipath-agent-framework/samples) | |
| 202 | + |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | +## Pack & Publish |
| 207 | + |
| 208 | +The same CLI workflow applies as for coded functions: |
| 209 | + |
| 210 | +<!-- termynal --> |
| 211 | + |
| 212 | +```shell |
| 213 | +> uipath pack |
| 214 | +⠋ Packaging project ... |
| 215 | +Name : my-agent |
| 216 | +Version : 0.1.0 |
| 217 | +Description: Add your description here |
| 218 | +Authors : Your Name |
| 219 | +✓ Project successfully packaged. |
| 220 | + |
| 221 | +> uipath publish |
| 222 | +⠋ Fetching available package feeds... |
| 223 | +Select feed number: 0 |
| 224 | +✓ Package published successfully! |
| 225 | +``` |
| 226 | + |
| 227 | +After publishing, the agent registers as an Orchestrator Process and can be invoked from Maestro, the Orchestrator API, or the CLI. |
| 228 | + |
| 229 | +See [CLI Reference](../cli/index.md) for full `pack`, `publish`, and `invoke` options. |
| 230 | + |
| 231 | +--- |
| 232 | + |
| 233 | +## Studio Web Integration |
| 234 | + |
| 235 | +Connect your agent to a Studio Web solution for cloud debugging, evaluation, and solution packaging. |
| 236 | + |
| 237 | +See [Studio Web Integration](./studio_web.md) for setup and sync details. |
| 238 | + |
| 239 | +--- |
| 240 | + |
| 241 | +## Evaluations |
| 242 | + |
| 243 | +Coded agents support evaluations in Studio Web and locally via `uipath eval`. Evaluators cover LLM output quality, tool call correctness, and trajectory analysis. |
| 244 | + |
| 245 | +See the [Evaluations documentation](../eval/index.md) for available evaluators and how to define evaluation sets. |
0 commit comments