> For the complete documentation index, see [llms.txt](https://docs.bardiel.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bardiel.tech/core-concepts/delegation-as-a-service.md).

# Delegation-as-a-Service

Bardiel is an **execution layer for agents** — an **“agent cloud”** they can call when they need remote, elastic, and **verifiable** work done.

Agents keep their **brains** — planning, reasoning, memory, and strategy — wherever they want. Bardiel handles **doing the work**:

* calling tools
* fetching and processing external data
* dispatching compute to Cortensor with redundancy and validation baked in

**Delegation-as-a-Service** is the `/delegate` surface for that.

> Agent / app / market → Bardiel (execution + verification) → Tools + Cortensor → Bardiel → ecosystem continues

Bardiel decides **how** to run the task — tooling, model class, redundancy, and validation tier.\
The calling agent, app, or market specifies **what** needs to be done and an optional **policy hint** about risk vs cost.

At a higher level, Delegation-as-a-Service makes Bardiel behave like **AWS for the agent economy**:

* agents do **not** stand up infra for every workflow
* they say: “Run this workflow over there, with these guarantees”
* Bardiel and Cortensor handle the rest

***

### Why Delegation Exists

Most agents blend two very different responsibilities:

* **Brain** — planning, goal decomposition, negotiation, strategy
* **Execution** — calling tools, hitting APIs, reading the web, crunching data, running long or parallel compute

Delegation-as-a-Service exists to **decouple** these:

* the agent keeps a clean, composable **brain**
* Bardiel provides the **execution layer** that:
  * calls external tools and data sources
  * offloads heavy or parallel compute to Cortensor
  * enforces structure and safety checks
  * attaches verification signals to results

Agents do **not** each need to design their own mini execution network.\
They plug into **Bardiel** and get reliable, verifiable task execution **as a service**.

***

### Where Delegation Fits

Delegation is designed for **Base, Virtual, ERC-8004, and other agent ecosystems**.

Examples include:

* **Base-native agents and apps**
  * run workflows with trusted execution before acting onchain
* **Virtual GAME agents and ACP markets**
  * offload research, tool chains, and pre-validated jobs into Cortensor
* **ERC-8004-compatible agents and marketplaces**
  * use Bardiel as a shared execution surface for delegated jobs
* **other onchain agent ecosystems**
  * rely on the same execution primitive without building custom infra from scratch

The integration surface may differ by ecosystem, but the core behavior is the same:

> describe the job, choose the trust level, and let Bardiel run it correctly.

***

### When to Use Delegation

Use Delegation-as-a-Service when an agent, app, or market:

* needs **reliable execution**, not just a single best-effort LLM call
* wants to offload:
  * web and data access
  * complex or parallel model calls
  * multi-step tool workflows
* wants outputs to come back with **confidence and evidence**, not just raw text
* prefers a single **agent-native call** instead of managing:
  * Cortensor sessions and miners
  * multiple external APIs
  * its own validation and retry logic

Typical use cases:

* long-context research and synthesis\
  for example: “read these URLs, cross-check, then summarize”
* structured data extraction or classification with schema guarantees
* preparing onchain or market actions with **pre-validated** payloads
* running risky or expensive tool chains and getting a result that has already been cross-checked
* delegated worker jobs for Base-native agents, Virtual agents, ACP markets, ERC-8004 systems, and other agent protocols

***

### High-Level Flow

1. **Agent, app, or market** calls Bardiel, for example:

   ```python
   delegate_to_bardiel(task, policy="safe")
   ```

   where `task` includes instructions, optional tool hints, and constraints such as latency, cost, and safety.
2. **Bardiel**:
   * parses the task and constraints
   * decides which tools and data sources to use
     * web fetch
     * search
     * spec normalizer
     * schema checks
     * other internal tools
   * chooses:
     * model or model class
     * redundancy level on Cortensor (1 / 3 / 5+ miners)
     * validation tier (`fast`, `safe`, `oracle`, or `adaptive`)
   * opens or reuses a **Cortensor session** (Stake-to-Use and/or x402 billing)
   * orchestrates the full execution:
     * external calls
     * data processing
     * Cortensor inference
3. **Cortensor Router**:
   * enqueues compute-heavy portions of the task
   * routes them to miners based on capability and SLA
4. **Miners**:
   * run the compute tasks, possibly in parallel
   * return outputs plus metadata and trust signals
5. **Bardiel**:
   * validates the combined result according to the chosen tier
   * checks schemas, constraints, and consistency where needed
   * returns to the caller:
     * final result
     * confidence score
     * a light evidence summary\
       for example: tier used, redundancy, agreement level, key tools used

From the caller’s point of view, this is still **one delegated call**.\
The agent stays in **brain mode**; Bardiel acts as its **execution layer**, handling “doing the work” in a verifiable way.

***

### Tooling Surface (Early Design)

Delegation is not “just call an LLM once”. It sits on top of a growing **tooling surface** that Bardiel can use internally whenever work is delegated.

Agents do **not** need to call these tools directly — they describe the task and let Bardiel choose the right tools.

#### 1. Context & Retrieval Tools

* HTTP / web fetcher for raw URLs (HTML / JSON / text) to inject into Cortensor context
* web page summarizer for “TL;DR this URL in N bullets” style jobs
* search over web or curated docs, returning top-k snippets and links into the delegation plan
* multi-URL ingest and basic file loading (PDF / DOC / MD) with simple vector lookup over prior specs, docs, FAQs

#### 2. Data & Structure Tools

* spec normalizer:
  * turn messy user instructions into a structured task spec
  * constraints
  * IO schema
  * edge cases
* schema / JSON validator to sanity-check tool outputs and auto-fix trivial formatting issues
* tabular / math helpers for CSV / JSON tables, quick calculations, and numerically sensitive tasks

#### 3. Web3, Storage & Trust Tools

* onchain state reader for balances, contract state, and relevant events
* price / market data helpers
* IPFS / object-storage helpers to attach large artifacts via URIs / CIDs

#### 4. Safety & Reputation Tools

* safety / policy checker to flag risky actions or content
* diff / comparison and log / evidence bundlers
* reputation or historical-behavior lookups to feed later validation and arbitration flows

All of this is **experimental by design**: the goal is to discover which tools matter most for real workloads, then harden them as part of the standard `/delegate` surface.

***

### Policy Hints

Delegation supports simple **policy hints** that tell Bardiel how cautious and expensive to be:

* **`fast`**
  * minimal redundancy
  * lightweight checks
  * lowest cost / latency
* **`safe`**
  * 3-way redundancy on key compute steps
  * consistency plus basic usefulness scoring
  * balanced cost vs trust
* **`oracle`**
  * 5+ runs, often across diverse miners / models
  * strict thresholds and richer evidence
  * for high-value or sensitive tasks
* **`adaptive`**
  * starts like `fast`
  * automatically escalates to `safe` or `oracle` if confidence is low
  * cheap on easy tasks, strong on hard ones

Internally, Bardiel can adjust:

* how much redundancy to use
* which tools, data sources, or models to call
* how aggressively to validate and cross-check

Callers keep a simple `policy` parameter while Bardiel evolves its execution and validation logic.

***

### Example 1: High-Trust Summary

**Goal:** A Virtual agent wants a **high-trust summary** of a long report before acting on it.

The Worker calls Bardiel with a task like:

```json
{
  "mode": "delegation",
  "task": {
    "type": "summarize",
    "input": {
      "text": "<long report text>"
    },
    "spec": {
      "max_summary_words": 200,
      "style": "concise_bullets"
    }
  },
  "policy": "safe",
  "context": {
    "caller": "agent_123",
    "surface": "GAME"
  }
}
```

Bardiel:

* chooses an appropriate summarization model or model class
* uses **3 miners in parallel** because `policy = "safe"`
* clusters outputs using PoI-style similarity
* scores them for coverage and brevity using PoUW-style rubrics
* discards obvious outliers or low-quality attempts

Bardiel returns something like:

```json
{
  "status": "VALID",
  "result": {
    "summary": [
      "Key point 1...",
      "Key point 2...",
      "Key point 3..."
    ]
  },
  "confidence": 0.91,
  "evidence": {
    "redundancy": 3,
    "poi_cluster_agreement": 0.87,
    "tier": "safe"
  },
  "retry_instructions": null,
  "trace_id": "bardiel-trace-abc123",
  "bardiel_version": "v0.1.0"
}
```

The agent does **not** need to know which miners ran, how many retries were needed, or how PoI / PoUW were combined.\
It simply receives a **trusted summary** with a clear status and confidence score.

***

### Example 2: Research + Pre-Validated Summary

**Goal:** A Base-native or Virtual agent needs a reliable summary of a topic plus links and wants to avoid hallucinated citations.

The caller sends Bardiel a task like:

```json
{
  "mode": "delegation",
  "task": {
    "type": "research_and_summarize",
    "input": {
      "topic": "X"
    },
    "spec": {
      "bullets": 10,
      "require_web_sources": true,
      "require_link_per_bullet": true
    }
  },
  "policy": "safe",
  "context": {
    "caller": "agent_456",
    "surface": "APP"
  }
}
```

Bardiel:

* runs search plus URL fetch tools
* normalizes the spec into a structured internal plan
* uses Cortensor for summarization and cross-checking with redundancy
* validates that:
  * bullets are grounded in fetched pages
  * links actually support the claims
  * the output respects structure and length constraints

Bardiel returns:

* a 10-bullet summary
* links per bullet
* a confidence score
* a short evidence summary\
  for example: number of sources, redundancy used, agreement level

For the agent, Bardiel is the **execution layer with verifiable results**:\
it does the work, checks itself, and hands back something the ecosystem can safely reason over.
