---
sidebar_position: 6
title: Pipeline supervisor
---

# `pipeline-supervisor` — Zibby managing Zibby

A scheduled supervisor agent that watches the project's *other* agents, finds the ones that are failing or slow, and posts a human-reviewable improvement proposal to Slack or Lark.

v1 is strictly **READ → PROPOSE → NOTIFY**. It never edits another agent's graph — that's the safe starting point. The auto-PATCH step is a deliberate TODO, not implemented.

```
scan_pipelines        (deterministic + Zibby REST API, PAT-authed)
   → propose_improvements (LLM — one proposal per flagged agent)
   → notify               (LLM + SKILLS.CHAT_NOTIFY — one review card)
```

If `scan_pipelines` flags nothing, the graph short-circuits straight to `notify` (which posts/skips without an LLM call on the proposer).

## How it reads other agents

A direct authed `GET /executions?projectId=<id>&limit=200` against the Zibby REST API (the same route the dashboard and remote MCP server use), carrying a **user personal access token** in `Authorization: Bearer`.

It must be a USER PAT (`zby_pat_…`), **not** the Fargate-injected `PROJECT_API_TOKEN`: every cross-agent read route requires a `userId` from the authorizer, and a project token carries none — so it 401s.

## Config (ENV tab)

Required:

- `ZIBBY_PAT` — user personal access token the supervisor reads executions with.
- `SLACK_CHANNEL` **or** `LARK_RECEIVE_ID` — where the review card goes.

Optional:

- `SUPERVISOR_PROJECT_ID` — project to supervise (defaults to the running project).
- `SLACK_MENTIONS` / `LARK_MENTIONS` — JSON array of mentions on the card.

## Input (per-run dials)

| Field | Default | Meaning |
|---|---|---|
| `lookbackHours` | 24 | Hours of execution history to scan |
| `minFailRate` | 0.4 | Flag an agent failing ≥ this fraction of recent runs |
| `targetWorkflowTypes` | — | Optional name filter (case-insensitive substring) |
| `maxPipelines` | 25 | Cap on distinct agents analyzed per run |

## Trigger

Cron — typically daily or hourly, depending on how active the supervised project is.

## Deploy

```bash
zibby agent templates                                       # browse the marketplace
zibby agent new pipeline-supervisor -t pipeline-supervisor  # scaffold
zibby agent deploy pipeline-supervisor
```
