# Where an AI agent belongs when the client already runs UiPath and BPMN

> Existing bots become tools the agent can call, while the BPMN process still draws every route the agent is allowed to take.

Original: https://fdetimes.net/en/guides/ai-agent-uipath-bpmn-integration/

Camunda's documentation defines an agent in a single sentence: a loop in which the model decides for itself what to do next, which tool to call and when to stop.

For a client with a fleet of UiPath bots and BPMN processes that have run reliably for years, that sentence is both appealing and alarming. A self-directing loop will touch systems the operations team spent years taming.

So with this kind of client, an FDE's first job is to decide where the agent is allowed to stand, before any question of which model to use. Put it in the wrong place and one of two things happens: you break the audit trail compliance depends on, or the agent becomes an expensive RPA bot that decides nothing.

The good news is that Camunda and UiPath have both already marked out that place, each in its own way. Understand the two approaches and you know where to connect and which failures to guard against.

## The agent chooses the route but does not draw it

Camunda divides responsibility clearly: the LLM picks a branch from the permitted options, while the engine holds the process boundaries and execution reliability. When you walk into an existing system, this is the most useful way to see it. The BPMN process still sets the rules, and the agent exercises judgment only in the stretches the rules allow.

Technically, Camunda reserves the ad-hoc sub-process as the place for that judgment and calls it a "governed toolbox". The AI Agent connector is the main building block for bringing an agent into a process. An existing UiPath bot can perfectly well be one of the tools in the box, because Camunda 8 ships a connector for orchestrating bots from a BPMN process.

**Key point:** The agent chooses the path, but the process diagram is what draws it.

That gives three layers. At the top sits the BPMN process, which holds order, deadlines and incidents. In the middle is the agent, present only where judgment is needed. At the bottom is the RPA bot, which handles execution on the existing systems. The agent's arrival does not make the bot disappear. The bot becomes a tool in the box.

## Three entry points, three different behaviors

How you connect a bot to the process depends on the platform the client runs. Each entry point has a runtime behavior you need to know before writing the first line of code.

| Platform | How the bot is called | What you must handle |
|---|---|---|
| Camunda 8 | The UiPath connector creates a queue item | Queue items do not run immediately, so the BPMN model must poll for the result and cap the number of attempts |
| Camunda 7 | RPA Bridge passes service task input through Orchestrator to the robot | A failed bot shows up as an incident in Cockpit |
| UiPath Maestro | A service task calls a deployed RPA workflow or agent, waits for it to finish, then moves on | Each child process is a separate Orchestrator job and by default runs under any free identity in the folder |

UiPath Maestro takes the opposite direction to Camunda: Maestro itself runs BPMN to orchestrate agents, robots and people in the same process.

The same kind of service task can start a deployed RPA workflow or a UiPath agent. Separately hosted third-party agents have their own deployment type.

If the client has gone all in on UiPath, this is the lowest-friction route to reusing old bots.

## Mismatched invoices: the agent stands only on the exception branch

The following scenario is hypothetical. The client runs Camunda 8, with a supplier invoice process and a UiPath bot that looks up purchase orders in a legacy ERP. Invoices that match go straight through. Invoices that don't currently sit waiting for an accountant to handle them by hand.

The agent belongs on the "mismatched invoice" branch and nowhere else. You model that branch as an ad-hoc sub-process holding three tools: the UiPath bot that looks up purchase orders (called through the UiPath connector), a service task that reads payment history, and a user task for asking the accountant.

The agent reads the invoice, decides which tool to call and how many times, then concludes "approve", "reject" or "escalate to a person". Those three outcomes map to three branches already drawn after the sub-process. The agent cannot create a fourth.

The most fragile part is the bot. Queue items do not run immediately, so after creating an item the BPMN model has to loop: wait on a timer, check the status, increment a counter and exit to an error branch once the limit is exceeded. If the client needs a separate integration service outside the connector, the waiting code looks like this (the API-calling functions are abbreviated for brevity):

```python
import time

TOKEN_TTL = 3600       # Orchestrator tokens live for only one hour
REFRESH_MARGIN = 300   # refresh 5 minutes early

class TokenCache:
    token = None
    issued_at = 0.0

def get_token(cache: TokenCache) -> str:
    if cache.token and time.time() < cache.issued_at + TOKEN_TTL - REFRESH_MARGIN:
        return cache.token
    # The external application must request the OR.Default scope to get fine-grained, role-based permissions
    cache.token = request_token(scope="OR.Default")
    cache.issued_at = time.time()
    return cache.token

def wait_for_queue_item(cache, item_id, max_polls=10, interval_s=30):
    for attempt in range(max_polls):
        status = get_queue_item_status(get_token(cache), item_id)
        if status == "done":
            return "done"
        if status == "failed":
            return "failed"          # let BPMN raise an incident; don't swallow the error
        time.sleep(interval_s)
    return "timeout"                 # a separate BPMN branch, handled by a person
```

The values of `max_polls` and `interval_s` are yours to choose with the operations team, based on how long the bot usually takes. What is mandatory is a limit, and a "timeout" branch that leads to a human. An agent waiting forever on a hung bot is the kind of incident an operations team remembers for a long time.

## At a real client, start from the process map

Leave the model alone for now. List the existing BPMN steps, mark the ones that currently need human judgment, and treat only those as candidates for the agent. Every other step stays as it is.

Next, inventory the bots. For each bot you plan to put in the toolbox, record which entry point calls it, which identity it runs under, how long it takes and where it reports failures. In Maestro, a child process takes any free identity in the folder by default, so confirm that identity has exactly the permissions it needs and no more.

Finally, choose the design pattern according to the audit requirements. Besides the looping ad-hoc sub-process used in the invoice example, Camunda offers the AI Agent sub-process connector pattern, which Camunda says is more compact and easier to govern.

But Camunda itself warns that the compact pattern is a poor fit if the client needs a detailed audit trail. For clients in tightly regulated industries, keep the invoice-example approach: an ad-hoc sub-process with every tool visible on the diagram.

Consider the compact pattern only once compliance has confirmed it does not need that level of detail.

## The mistakes that send a project back to the starting line

A common temptation in demos is to have the agent call the Orchestrator API directly and bypass BPMN. Do that and you discard the very things that made the client choose BPMN: process boundaries, incidents and execution history. The bot should always be called as a task within the process.

A polling loop with no ceiling is the next trap. Then comes treating the token as a constant: Orchestrator tokens expire after an hour, so a service that ran smoothly all morning can suddenly return authentication errors mid-shift. In Maestro, leave the default identity in place and one day a child process will run with far broader permissions than its step requires.

For your career, when reading FDE job postings, watch for RPA, BPMN, UiPath Orchestrator or Camunda appearing next to the word "agent". Chances are that company's clients already have bots and processes, and need someone to connect agents without breaking them.

On a CV, a line such as "introduced an agent into the exception branch of a BPMN process, reusing existing UiPath bots and preserving incidents and the audit trail" says more than a page of frameworks.

Clients who already have bots and processes rarely need anyone to replace them. They need someone who knows where to place judgment, and who can then prove that everything else still runs as before.

**Try this week:**

- Pick a BPMN process with a human-handled exception step and redraw that step as an ad-hoc sub-process with three tools, one of them an existing bot
- Write a queue-item wait function with a cap on polls, plus a test for the case where the bot never returns a result
- Ask the client's operations team which identity and which Orchestrator folder each bot runs under

## Sources

- [AI agents | Camunda 8 Docs (version 8.11, unreleased)](https://docs.camunda.io/docs/next/components/agentic-orchestration/ai-agents/)

- [Designing AI Agents in Camunda: The AI Agent Sub-Process Connector](https://camunda.com/blog/2025/11/designing-ai-agents-in-camunda-the-ai-agent-sub-process-connector/)

- [UiPath connector | Camunda 8 Docs](https://docs.camunda.io/docs/components/connectors/out-of-the-box-connectors/uipath)

- [Orchestrating RPA Bots (Camunda 7 docs)](https://docs.camunda.org/get-started/rpa/orchestrating-bots)

- [What you get (UiPath Maestro docs)](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/value-proposition)

- [Service task (UiPath Maestro docs)](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/service-task)

- [External Applications (OAuth) – UiPath Orchestrator API Guide 2024.10](https://docs.uipath.com/orchestrator/standalone/2024.10/api-guide/accessing-uipath-resources-using-external-applications)
