# uip codedagent

> Syntax and options for `uip codedagent`, a bridge to the Python UiPath CLI for building and running Coded Agents.

`uip codedagent` is a thin bridge to the Python-based [UiPath Coded Agents](https://docs.uipath.com/) workflow. It detects a suitable Python interpreter, confirms the `uipath` Python package is installed, and forwards a fixed whitelist of subcommands into the Python CLI — so new, dev, pack, publish, and other lifecycle verbs come from the Python package rather than this tool. `review` is the one exception: it's a native command implemented directly in this tool, not forwarded.

Refer to [Tools (plugins)](./concepts-tools.md) for how thin wrappers differ from full tools.

## Synopsis

```
uip codedagent setup [--force]
uip codedagent review [path] [--checks <categories>]
uip codedagent <whitelisted-command> [args...]
```

`setup`, `review`, and any forwarded command honor the [global options](./global-options.md) (`--output`, `--output-filter`, `--log-level`, `--log-file`). Exit codes follow the [standard contract](./exit-codes.md).

## uip codedagent review

Review a coded agent project against a deterministic rule set — no Python interpreter needed, this runs natively in the CLI. Returns a verdict (`PASS`/`FAIL`), a score (0-100), a letter grade (`A+`...`F`), and a list of issues.

### Arguments

| Name | Required | Purpose |
|---|---|---|
| `[path]` | no | Agent project directory. Default: `.`. |

### Options

- `--checks <categories>` — Comma-separated rule categories to run. Omit to run all rules. Known categories include `evals`, `schema`, `tools`, `guardrails`, `code`, `general` (run `uip codedagent review --help` for the live list).

### Examples

```bash
uip codedagent review ./my-coded-agent
uip codedagent review --checks code
```

### Data shape (`--output json`)

```json
{
  "Code": "CodedAgentReview",
  "Data": {
    "ProjectDir": "./my-coded-agent",
    "Verdict": "PASS",
    "Score": 100,
    "Grade": "A+",
    "Issues": [],
    "Strengths": [],
    "Stats": {
      "errors": 0,
      "warnings": 0,
      "infos": 0,
      "byCategory": { "evals": 0, "schema": 0, "tools": 0, "guardrails": 0, "code": 0, "general": 0 }
    }
  }
}
```

An unrecognized `--checks` value fails with `Code: "CodedAgentReviewInvalidChecks"`, listing the known categories.

## uip codedagent setup

Detect Python and verify the `uipath` package is installed. Results are cached in a per-user file so subsequent `codedagent` commands can resolve the Python binary instantly. The cache is shared with [`uip function setup`](./uip-function.md#uip-function-setup), so running either command configures Python for both.

When a virtual environment is active (`VIRTUAL_ENV` is set), setup binds the Python interpreter and the `uipath` executable from that environment. A cached result whose `uipath` executable is outside the active virtual environment is detected again.

### Arguments

None.

### Options

- `--force` — Re-run detection even if a cached result is present.

### Examples

```bash
uip codedagent setup
uip codedagent setup --force
```

### Data shape (`--output json`)

```json
{
  "Code": "CodedAgentsSetup",
  "Data": {
    "PythonPath": "/usr/bin/python3.11",
    "Package": "uipath",
    "PackageInstalled": "Yes",
    "PackageVersion": "1.0.0",
    "UipathPath": "/home/me/my-agent/.venv/bin/uipath",
    "Source": "venv"
  }
}
```

| Field | Description |
|---|---|
| `PythonPath` | Python interpreter that setup bound. |
| `Package` | Python package that setup checked. |
| `PackageInstalled` | `Yes` or `No`. |
| `PackageVersion` | Installed package version, or `N/A`. |
| `UipathPath` | Path to the `uipath` executable that forwarded commands run. |
| `Source` | Where the interpreter came from: `venv` (the virtual environment active through `VIRTUAL_ENV` during setup) or `path` (an interpreter found by name on `PATH`). |

### Environment checks

- Allowed Python versions are configured via the environment variable `PYTHON_TOOL_PYTHON_VERSIONS`. An empty list raises `Failure` at setup time.
- The installed `uipath` package must meet the minimum version that the CLI declares. Setup fails, and writes no cache, when the package is older or its version cannot be read. Every forwarded command checks the version again before it runs and fails the same way. Upgrade the package, then re-run `uip codedagent setup --force`.
- When a virtual environment is active but the `uipath` package is not installed in it, setup fails and asks you to install the package inside that environment, then re-run `uip codedagent setup --force`.
- If a `.venv` directory exists in the current working directory but no virtual environment is activated (`VIRTUAL_ENV` is not set), setup refuses to run and suggests activating it first (`.venv\Scripts\activate` on Windows, `source .venv/bin/activate` elsewhere).

## Forwarded commands

A fixed whitelist of subcommand names is forwarded to the `uipath` Python CLI as `codedagent exec <subcommand> ...`: `add`, `debug`, `deploy`, `dev`, `eval`, `init`, `invoke`, `list-models`, `new`, `pack`, `publish`, `pull`, `push`, `register`, `run`. Anything outside this list — including a typo — is rejected by Commander as an unknown command before any forwarding is attempted; it is not passed through to Python.

### Examples

```bash
# Hand off to the Python CLI's new command
uip codedagent new my-agent

# Run the Python CLI's help for a sub-verb
uip codedagent init --help

# Execute a dev loop defined by the Python package
uip codedagent dev
```

:::note
Because these commands are defined by the `uipath` Python package, their flags and output shape are whatever that package emits — not the CLI's standard `Code`/`Data` envelope. Treat the CLI here as a transport. For the argument surface, run `uip codedagent <command> --help`, which forwards into Python. Bare `uip codedagent help` is **not** forwarded — `codedagent-tool` never registers a `help` command, so it shows Commander's own generated help for this tool instead.
:::

**Auth relay**: before forwarding, the CLI reads the session created by [`uip login`](./uip-login.md) and injects these environment variables into the Python subprocess so the SDK picks them up automatically:

- `UIPATH_ACCESS_TOKEN`
- `UIPATH_URL` (composed as `<baseUrl>/<org>/<tenant>`)
- `UIPATH_ORGANIZATION_ID`, `UIPATH_ORGANIZATION_NAME`
- `UIPATH_TENANT_ID`, `UIPATH_TENANT_NAME`

If you are not logged in, forwarding still works; the Python CLI runs without those variables.

**`new` from a solution root**: when the current directory holds a `.uipx` file, `uip codedagent new <name>` forwards `--dir <name>`, so the project is scaffolded into a new `./<name>` member folder instead of beside the solution file. A `<name>` that already exists there is refused with `Result: ValidationError` and exit code `3`, and nothing is written. Anywhere else, `new` scaffolds into the current directory. A `--dir` that you pass yourself is forwarded unchanged.

**`--force` is always stripped**: this tool defines no command-specific rules for `--force`, so it is unconditionally and silently stripped from every forwarded command's arguments before they reach the Python CLI. It never reaches Python, and no error is emitted — passing `--force` to a forwarded subcommand is simply a no-op.

**`push` requires `UIPATH_PROJECT_ID`** — a required environment variable, checked natively (in this tool, before forwarding to Python), not something the Python CLI enforces on its own. Set it once per project:

```bash
echo "UIPATH_PROJECT_ID=<id>" >> .env
uip codedagent push
```

Get `<id>` from an existing Coded Agent project in Studio Web. The check is skipped for `uip codedagent push --help`.

**`deploy`/`publish --my-workspace` (or `-w`) requires a personal-workspace-capable login scope** — another native, pre-forwarding check. It reads your current [`uip login`](./uip-login.md) access token and requires the umbrella `OrchestratorApiUserAccess` scope or the granular `OR.Users` or `OR.Users.Read` scope (any one satisfies it); a token missing all of them fails before anything reaches Python:

```json
{
  "Result": "Failure",
  "Message": "Current login token is missing the OrchestratorApiUserAccess (or granular OR.Users.Read) scope required for --my-workspace.",
  "Instructions": "The personal workspace publish path calls Orchestrator GetCurrentUserExtended and requires either the umbrella OrchestratorApiUserAccess scope or the granular OR.Users.Read scope. If you are using the default client, run `uip login` again — IdentityServer attaches OrchestratorApiUserAccess to issued tokens automatically. ..."
}
```

The default `uip login` client picks up `OrchestratorApiUserAccess` automatically, so this only bites custom clients or a restricted scope list. Skip the check entirely by deploying to the tenant feed instead: `uip codedagent deploy --tenant`. This check only applies to `deploy`/`publish` when `--my-workspace`/`-w` is passed — it does not run for a plain `deploy`/`publish` or any other whitelisted command.

## Exit codes

Standard [exit codes](./exit-codes.md) apply. The forwarded subprocess's exit code is relayed directly to the parent shell, so a Python-side failure exits `uip codedagent` with the same non-zero status.

## Related

- [Tools (plugins)](./concepts-tools.md) — thin-wrapper tool model.
- [`uip login`](./uip-login.md) — creates the session that is relayed to the Python runtime.
- [`uip tools`](./uip-tools.md) — install, update, uninstall the `codedagent-tool` package itself.
