# Run an Agent

### Architecture

<figure><img src="https://1889477862-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FG042xWWqiDkSJlg00aF9%2Fuploads%2FxXvghmmP0U9vsTPwsCnu%2Fdiagram-export-28-10-2025-22_47_51.png?alt=media&#x26;token=1d827227-278e-4bc7-aa24-f62450a48f63" alt=""><figcaption></figcaption></figure>

### UI - Palliora Explorer

1. Go to the Agents tab on Palliora Explorer.
2. Select the agent you want to run.
3. Pay the Palliora tokens required for running that agent.
4. You will be redirected to a chat UI where you can start interacting with the agent.

### CLI

1. Use the Palliora indexer to fetch the `agentRef` ciphertext's using the API call:<br>

   ````
   Implement an API to do the following:
   Fetch the blockHt & extrinsic from agentConfigRef:

   ```
   statescan-polkadot-agent -> registry collection -> Agent doc.agentConfigRef -> blockHt
   ```

   Use the blockHt & extrinsic to get the agent ciphertext data
   ```
   statescan-polkadot-data -> blob collection -> "indexer.blockHeight": blockHt -> data
   ```
   ````
2. Once you have the `agentConfig` ciphertext, run the following cmd from Palliora CLI<br>

   ```
   node mindcrypt-cli/dist run-agent --agentRef ${agentRefCipherText}
   ```
3. This will emit a `daccRunAgent` event to notify the guardian network's calculator nodes to run the agent.
4. The guardian network will perform threshold decryption on the agent's ciphertext which will expose the agent container reference and .env variables to the node.
5. The calculator node will then be able to pull the agent container image, serve the model required by the agent through ollama and execute `docker run` for the agent to start running.
6. The node will also expose an access url for your client to establish a connection with the agent, which will be encrypted against the client's public key.
7. You can fetch the result of the run agent call from the `daccComputeResult` event, decrypt the `data` to get the `accessURL` . This should be a websocket URL.
8. Use the `accessURL` to establish a direct connection with your agent and start interacting!
