API Reference

Task server REST endpoints, CLI commands, and configuration schema.

Task Server

The task server is a FastAPI application running at http://127.0.0.1:8052 (port configurable). It is the single source of truth for all task state.

ℹ️

The server is started automatically by bernstein run. You can also start it standalone with bernstein server start for scripting use cases.

Tasks

POST /tasks

Create a new task.

curl -s -X POST http://127.0.0.1:8052/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Add pagination to users API",
    "role": "backend",
    "description": "Implement cursor-based pagination on GET /users.",
    "priority": 1,
    "scope": "small",
    "complexity": "low"
  }'

Body fields:

FieldTypeRequiredDescription
titlestringShort task name
rolestringAgent role: manager, backend, qa, security, frontend, devops
descriptionstringFull task description injected into the agent prompt
priorityint1 = critical, 2 = normal, 3 = nice-to-have. Default: 2
scopestringsmall / medium / large. Affects model selection.
complexitystringlow / medium / high. Affects effort level.
depends_onstring[]Task IDs that must complete before this task is claimable
completion_signalsobject[]Janitor checks these before marking done (see Completion Signals)
filesstring[]File paths this task owns (prevents parallel conflicts)
estimated_minutesintTime budget hint for the spawner
GET /tasks

List tasks. Optionally filter by status or role.

curl http://127.0.0.1:8052/tasks
curl "http://127.0.0.1:8052/tasks?status=open"
curl "http://127.0.0.1:8052/tasks?status=in_progress"
curl "http://127.0.0.1:8052/tasks?role=backend"

Query params: status (open | in_progress | done | failed | blocked), role

GET /tasks/{task_id}

Get a single task by ID.

curl http://127.0.0.1:8052/tasks/abc123
GET /tasks/next/{role}

Claim the next open task for a given role. Used by agent adapters to pick up work.

curl http://127.0.0.1:8052/tasks/next/backend

Returns 404 if no tasks are available for that role.

POST /tasks/{task_id}/claim

Claim a specific task by ID.

curl -X POST http://127.0.0.1:8052/tasks/abc123/claim \
  -H "Content-Type: application/json" \
  -d '{"agent_id": "agent-42"}'
POST /tasks/{task_id}/complete

Mark a task as done. The janitor will verify completion signals before finalising.

curl -X POST http://127.0.0.1:8052/tasks/abc123/complete \
  -H "Content-Type: application/json" \
  -d '{"result_summary": "Added cursor pagination to GET /users"}'
POST /tasks/{task_id}/fail

Mark a task as failed.

curl -X POST http://127.0.0.1:8052/tasks/abc123/fail \
  -H "Content-Type: application/json" \
  -d '{"reason": "Cannot resolve import — missing dependency"}'
GET /tasks/archive

Recent completed and failed task records.

curl http://127.0.0.1:8052/tasks/archive
GET /status

Dashboard summary — task counts per status and agent summary.

curl http://127.0.0.1:8052/status

Example response:

{
  "tasks": { "open": 4, "in_progress": 3, "done": 7, "failed": 0 },
  "agents": { "active": 3, "idle": 0 },
  "uptime_seconds": 312
}

Agents

POST /agents/{agent_id}/heartbeat

Register agent liveness. Agents must heartbeat every heartbeat_timeout seconds or the spawner will kill and respawn them.

curl -X POST http://127.0.0.1:8052/agents/agent-42/heartbeat

Costs

GET /costs

Aggregated cost breakdown by model, role, and task.

curl http://127.0.0.1:8052/costs
GET /costs/live

Real-time cost data for the current run.

GET /costs/alerts

Active cost alerts (budget threshold warnings).

GET /costs/history

Historical cost records across previous runs.

GET /costs/{run_id}

Cost breakdown for a specific run.

Quality

GET /quality

Quality dashboard data: pass rates, verification results, and trends.

GET /quality/models

Per-model quality metrics (success rates, average scores).

Webhooks

GET /alerts

Active system alerts (task failures, budget warnings, agent health).

POST /webhooks/github

GitHub webhook receiver. Processes push events, PR events, and CI status updates to create or update tasks automatically.

Auth

GET /auth/providers

List configured authentication providers (OIDC, SAML).

GET /auth/login

Initiate OIDC login flow (redirects to provider).

POST /auth/cli/device

Start CLI device code flow for headless authentication.

GET /auth/me

Current authenticated user profile.

Plans

GET /plans

List all plans (pending, approved, rejected).

GET /plans/{plan_id}

Get a specific plan by ID.

POST /plans/{plan_id}/approve

Approve a pending plan. Approved plans are converted into tasks.

POST /plans/{plan_id}/reject

Reject a pending plan with an optional reason.

Graduation

GET /graduation/status

Overview of agent graduation status across all sessions.

GET /graduation/{session_id}

Graduation details for a specific agent session.

POST /graduation/{session_id}/promote

Promote an agent session to a higher trust level based on performance.

Slack

POST /webhooks/slack/commands

Slack slash command handler. Supports /bernstein status, /bernstein run, etc.

POST /webhooks/slack/events

Slack Events API handler for real-time notifications.

ACP (Agent Communication Protocol)

GET /.well-known/acp.json

ACP discovery document. Describes available agents, capabilities, and protocol version.

GET /acp/v0/agents

List agents available via the ACP protocol.

POST /acp/v0/runs

Create a new ACP run (submit work to an agent).

GET /acp/v0/runs/{run_id}

Check the status of an ACP run.

Bulletin Board

POST /bulletin

Post a message to the bulletin board. Agents use this to share findings or warnings with each other.

curl -X POST http://127.0.0.1:8052/bulletin \
  -H "Content-Type: application/json" \
  -d '{"message": "Found deprecated auth API — all agents should avoid /auth/v1"}'
GET /bulletin

Read bulletin messages, optionally since a timestamp.

curl "http://127.0.0.1:8052/bulletin?since=1711574400"

Health & Status

GET /health

Server liveness check. Returns 200 {"status": "ok"} when healthy.

curl http://127.0.0.1:8052/health
GET /metrics

Prometheus-format metrics for Grafana and alerting.

GET /events

Server-Sent Events (SSE) stream for real-time dashboard updates.

GET /routing/bandit

Bandit-based model routing statistics (arm weights, selection counts).

GET /cache-stats

Semantic cache hit/miss statistics.

CLI Commands

Core

CommandDescription
bernstein initInitialise a .sdd/ workspace in the current directory
bernstein -g "<goal>"Run with a plain-English goal
bernstein --seed-file <path>Run with a YAML seed file
bernstein stopGraceful shutdown
bernstein stop --forceHard stop (kill immediately)
bernstein checkpointSave progress for later resume
bernstein wrap-upEnd session with summary and learnings

Flags

FlagDescription
--headlessSuppress live dashboard, write to logs only
--dry-runPreview task plan without spawning agents
--budget NCost cap in USD (0 = unlimited)
--approval auto|review|prApproval gate before merge
--freshIgnore saved session, start clean
--cli claude|codex|gemini|qwen|autoForce a specific agent adapter
--model MODELForce a specific model
--evolve / -eEnable continuous self-improvement mode
--max-cycles NStop after N evolve cycles
--interval NSeconds between evolve cycles (default: 300)

Monitoring

CommandDescription
bernstein liveAttach interactive TUI dashboard to running session
bernstein dashboardOpen web dashboard in browser
bernstein statusShow current task/agent status
bernstein psShow running agent processes
bernstein logs [AGENT_ID]Tail agent log output
bernstein costShow spend breakdown by model, role, task

Task management

CommandDescription
bernstein planShow task backlog
bernstein add-taskAdd a task to the backlog
bernstein list-tasksList all tasks
bernstein cancel <ID>Cancel a running or queued task
bernstein reviewReview completed tasks
bernstein approveApprove a task for merge
bernstein rejectReject a task
bernstein pendingList tasks pending review

Diagnostics

CommandDescription
bernstein doctorPre-flight check: adapters, API keys, ports
bernstein recapPost-run summary: tasks, pass/fail, cost
bernstein retroDetailed retrospective report
bernstein trace <ID>Step-by-step agent decision trace
bernstein replay <ID>Re-run a task from its trace
bernstein auditAudit tasks and code quality
bernstein verifyVerify task completion signals
bernstein benchmark runRun the golden benchmark suite

Evolution subcommands

CommandDescription
bernstein evolve reviewList proposals awaiting human review
bernstein evolve approve <id>Approve a deferred proposal
bernstein evolve runRun one autoresearch cycle manually

Agents and infrastructure

CommandDescription
bernstein agents listList available agents
bernstein agents syncSync from remote catalogs
bernstein agents discoverAuto-detect installed CLI agents
bernstein workspaceShow multi-repo workspace status
bernstein configView and edit configuration
bernstein mcpStart MCP server for tool integration
bernstein pluginsList discovered plugins
bernstein demoZero-to-running demo
bernstein chaosChaos testing commands

Config Schema

.sdd/config.yaml — created by bernstein init, edit to customise:

# Task server
server_port: 8052

# Agent concurrency
max_workers: 6

# Default model and effort for workers (overridden per task by the router)
default_model: sonnet      # sonnet | opus
default_effort: high       # normal | high | max

# CLI adapter
adapter: auto              # auto | claude | codex | gemini | qwen (auto detects installed agents)

# Heartbeat: kill agent if silent for this many seconds
heartbeat_timeout: 120

# Cost budget for a single run ($0 = unlimited)
budget: 0

Task Schema

Full task metadata structure (YAML or JSON):

id: "TSK-042"                    # auto-assigned, or set manually
title: "Implement BM25 index"    # required
role: "backend"                  # required: manager | backend | qa | security | frontend | devops

# Routing (optional — defaults applied if omitted)
priority: 1                      # 1=critical, 2=normal, 3=nice-to-have
scope: "medium"                  # small | medium | large
complexity: "high"               # low | medium | high
estimated_minutes: 30

# Dependencies
depends_on: ["TSK-040"]          # task IDs that must complete first

# Verification
completion_signals:
  - type: path_exists
    path: "src/retrieval/bm25.py"
  - type: test_passes
    command: "pytest tests/test_bm25.py"

# Ownership (prevents parallel file conflicts)
files:
  - "src/retrieval/bm25.py"
  - "tests/test_bm25.py"

# Full prompt injected into the agent session
description: |
  Implement a BM25 sparse index alongside the dense vector index in
  src/retrieval/. Expose it via the same Retriever interface.

Completion Signals

The janitor checks these before marking a task done. Define them in the task's completion_signals field.

TypeFieldsDescription
path_exists path File or directory must exist at the given path
test_passes command Shell command must exit with code 0
file_contains path, text File at path must contain text as a substring
api_responds url, status HTTP GET to url must return the expected status code

Example:

completion_signals:
  - type: path_exists
    path: "src/auth/jwt.py"
  - type: test_passes
    command: "pytest tests/test_auth.py -x -q"
  - type: file_contains
    path: "src/auth/jwt.py"
    text: "def verify_token"