# The LoopDesk model

LoopDesk implements human-in-the-loop as a **routing layer**, not a workflow tool. Every item your AI pipeline produces flows through one router, which makes one of three decisions in milliseconds.

## The three outcomes

```
                         ┌──────────────────┐
   suggestion ──────────►│  routing policy  │
                         └────────┬─────────┘
                                  │
              ┌───────────────────┼───────────────────┐
              ▼                   ▼                   ▼
        auto-approve          queue                escalate
       (no human seen)   (any reviewer)       (senior reviewer)
              │                   │                   │
              ▼                   ▼                   ▼
          decision            decision            decision
              │                   │                   │
              └──────────► outbound webhook ◄─────────┘
```

## Inputs to the router

Each submitted item carries:

| Field                    | Source           | Used for                                |
| ------------------------ | ---------------- | --------------------------------------- |
| `confidence` (0–1)       | Your model       | Primary threshold check                 |
| `risk_flags` (string\[]) | Your pipeline    | Hard rules, escalation                  |
| `project_id`             | Caller           | Loads the project's policy config       |
| `input` (jsonb)          | Original request | Reviewer context                        |
| `suggestion`             | AI output        | What the reviewer sees                  |
| `metadata` (jsonb)       | Optional         | Custom fields (user tier, region, etc.) |

## The decision

In pseudocode:

```
policy = load_project_policy(project_id)

if "block" in risk_flags:
    → reject (no human, hard policy violation)

if "escalate" in risk_flags:
    → escalate (senior reviewer only)

if confidence >= policy.auto_threshold AND len(risk_flags) == 0:
    → auto-approve

if confidence < policy.review_threshold OR len(risk_flags) > 0:
    → queue (any reviewer in pool)

# middle band
→ queue (with low-priority tag)
```

Defaults ship conservative (`auto_threshold = 0.95`, `review_threshold = 0.70`). Tune per project; see [Tuning thresholds](/hitl-docs/guides/tuning-thresholds.md).

## What humans see

Reviewers only ever see queued or escalated items. The queue UI shows:

* Original input + AI suggestion side by side
* Confidence and risk flags as badges
* Project guidelines (collapsible)
* Three primary actions: approve, edit & approve, reject
* Escalate as a secondary action

A reviewer's median decision time should be measured in seconds, not minutes. If it isn't, the items shouldn't be in front of a human in the first place.

## Why this works

* **Auditability without bottleneck.** Every decision — auto or human — is logged with the same schema. Compliance gets a single source of truth; throughput is not capped by team size.
* **Speed where speed is safe.** High-confidence, no-flag items ship in milliseconds.
* **Friction where friction matters.** Sensitive items always touch a human, and a specific one.
* **Closed loop by default.** Overrides become learnings become prompt/model improvements. The queue should shrink, not grow.

## What LoopDesk is *not*

* Not a model host — your pipeline produces the suggestion
* Not a workflow engine — no DAGs, no branching steps, no long-running tasks
* Not a labeling tool — labels are a byproduct of reviewing real production traffic, not the goal

Keep the router small, fast, and boring. That is the whole product.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hitl-01.gitbook.io/hitl-docs/human-in-the-loop/hitl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
