agentbreeder

Local Development

Run the full AgentBreeder stack on your machine.

This guide covers setting up AgentBreeder for local development and contributing.

Prerequisites

ToolVersionPurpose
Python3.11+Backend, CLI, engine
Node.js22+Studio frontend
Docker & ComposeLatestLocal services, container builds
GitLatestVersion control

Setup

1. Clone and install

git clone https://github.com/agentbreeder/agentbreeder.git
cd agentbreeder

# Python environment
python -m venv venv
source venv/bin/activate
pip install -e ".[dev]"

# Copy environment config
cp .env.example .env

2. Start local services

# Start PostgreSQL and Redis
docker compose -f deploy/docker-compose.yml up -d postgres redis

Wait for services to be healthy:

docker compose -f deploy/docker-compose.yml ps

3. Run database migrations

alembic upgrade head

4. Start the API server

uvicorn api.main:app --reload --port 8000

API is available at http://localhost:8000. OpenAPI docs at http://localhost:8000/docs.

5. Start Studio

cd dashboard
npm install
npm run dev

Studio is available at http://localhost:5173. It proxies API requests to port 8000 via Vite config.

6. Verify the CLI

agentbreeder --help
agentbreeder list agents

Auth

All 247/247 management API routes under /api/v1/* are auth-gated via Depends(get_current_user) or Depends(require_role(...)). Only auth/login and auth/register are open by design.

Bootstrap a token once per development session:

# 1. Register an account (first time only)
curl -X POST http://localhost:8000/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"you@company.com","password":"…","name":"You"}'

# 2. Login → JWT
curl -X POST http://localhost:8000/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"you@company.com","password":"…"}'
# → {"access_token": "eyJ…", "token_type": "bearer"}

# 3. Export — the CLI picks this up automatically
export AGENTBREEDER_API_TOKEN=eyJ…

Without AGENTBREEDER_API_TOKEN set, registry CLI commands will fail with 401.

Agent runtime auth (AGENT_AUTH_TOKEN)

Deployed agent runtimes use a separate bearer token, supplied via the AGENT_AUTH_TOKEN env var on the runtime container. It gates /invoke and /stream; /health stays open for k8s and Cloud Run probes. Both Python (6 servers) and Node (9 servers) runtime templates ship with the same auth contract.

Use the registry CLI

The registry CLI manages prompts, tools, and agents — the three entities resolved at agent startup (file-first, with the registry as DB-backed fallback).

# Prompts
agentbreeder registry prompt push <file.md> [--name --version --team --description]
agentbreeder registry prompt list [--team]
agentbreeder registry prompt try <name> --input "..." [--model gemini-2.5-flash]

# Tools — auto-detects .py → python:<abs>, .ts/.js → node:<abs>, module path → as-is
agentbreeder registry tool push <module-or-file> [--description]
agentbreeder registry tool list
agentbreeder registry tool run <name> [--args '{"key":"value"}']

# Agents
agentbreeder registry agent push agent.yaml
agentbreeder registry agent list [--team]
agentbreeder registry agent invoke <name> --input "..." [--endpoint URL --token T --session SID]

All commands require AGENTBREEDER_API_TOKEN. See the How-To Guide → Push prompts and tools for end-to-end examples.

Reference example agents

Several reference agents demonstrate the full registry + auth + deploy chain end-to-end. Use them when migrating an existing agent into the AgentBreeder pattern:

ExampleWhat it shows
examples/google-adk-agentGoogle ADK runtime, registry-backed prompt + tools, local + Cloud Run deploy
examples/ai-news-digestScheduled agent, multiple stdlib tools, prompt versioning
examples/registry-pattern-tsTypeScript runtime — resolvePrompt() / resolveTool() from engine/runtimes/templates/node/_shared_loader.ts

The canonical reference is microlearning-ebook-agent: 1 prompt registered (microlearning-system v1.0.2), 2 stdlib tools (web-search, markdown-writer), all /health /invoke /stream endpoints gated by AGENT_AUTH_TOKEN, deployed to Cloud Run with secrets in Secret Manager.

End-to-end verification script

microlearning-ebook-agent/scripts/e2e_test.sh runs 7 verifications against a running stack — auth gates, prompt versioning, tool registry, runtime auth, real-tool-chat — and exits non-zero on any failure. Use it as a smoke test after schema changes:

cd microlearning-ebook-agent/
./scripts/e2e_test.sh
# 7/7 pass

Full Stack (Docker Compose)

To run everything in Docker (API + Studio + Postgres + Redis + migrations):

docker compose -f deploy/docker-compose.yml up -d
ServiceURL
Studiohttp://localhost:3001
APIhttp://localhost:8000
API Docshttp://localhost:8000/docs
PostgreSQLlocalhost:5432
Redislocalhost:6379

Default credentials for local dev:

  • DB: agentbreeder / agentbreeder / database agentbreeder
  • App login: admin@agentbreeder.local / plant (Studio forces a password rotation on first sign-in)

Running Tests

Python unit tests

pytest tests/unit/                        # All unit tests
pytest tests/unit/test_api_routes.py      # Specific file
pytest tests/unit/ -k "test_deploy"       # Pattern match
pytest tests/unit/ --cov=api --cov-report=html  # With coverage

Playwright E2E tests

cd dashboard

# Install browsers (first time only)
npx playwright install --with-deps chromium

# Run tests
npx playwright test                    # Headless
npx playwright test --headed           # Watch in browser
npx playwright test --ui               # Interactive UI mode
npx playwright test tests/e2e/agents   # Specific directory

Live Docker E2E tests (full stack)

Runs 97 Playwright tests against the real Docker Compose stack — no mocks. Covers all 12 feature domains: providers, prompts, tools, RAG, MCP servers, agent builders (no-code + YAML), playground execution, tracing, evaluations, cost tracking, and RBAC.

# Start the stack first
docker compose -f deploy/docker-compose.yml up -d

# Run all 97 live E2E tests
cd dashboard && npm run test:e2e:live

# Watch tests run in a browser (recommended for development)
npm run test:e2e:live:ui

# Debug a single failing test
npm run test:e2e:live:debug -- --grep "provider"

Test credentials and stack config are in dashboard/.env.e2e. The global setup provisions test users and teardown cleans them up automatically.

Coverage report

pytest tests/unit/ tests/integration/ \
  --cov=api --cov=engine --cov=cli --cov=registry --cov=connectors --cov=sdk \
  --cov-report=html

# Open htmlcov/index.html in your browser
# Current baseline: 95% source coverage (3,666 tests)

Linting & Formatting

Python

# Lint
ruff check .

# Auto-fix
ruff check --fix .

# Format
ruff format .

# Type check
mypy api/ engine/ cli/ registry/ connectors/

TypeScript

cd dashboard

# Lint
npm run lint

# Type check
npx tsc -b --noEmit

Database Migrations

# Apply all pending migrations
alembic upgrade head

# Create a new migration from model changes
alembic revision --autogenerate -m "add new column to agents"

# Downgrade one version
alembic downgrade -1

# View migration history
alembic history

Project Layout

agentbreeder/
├── api/                    # FastAPI backend
│   ├── main.py             # App entry, middleware, routers
│   ├── routes/             # REST endpoints
│   │   ├── agents.py       # Agent CRUD
│   │   ├── deploys.py      # Deploy from Studio (POST /api/v1/deploys)
│   │   ├── prompts.py      # Prompts + test panel (POST /api/v1/prompts/test)
│   │   ├── sandbox.py      # Tool sandbox execution (POST /api/v1/tools/sandbox/execute)
│   │   ├── rag.py          # RAG indexes, file ingestion, hybrid search
│   │   ├── memory.py       # Memory configs, conversation storage
│   │   ├── git.py          # Git workflow + PR review backend
│   │   ├── providers.py    # Provider config endpoints
│   │   └── ...
│   ├── services/           # Business logic
│   │   ├── git_service.py  # Git operations
│   │   └── pr_service.py   # Pull request workflow
│   ├── models/             # SQLAlchemy models + Pydantic schemas
│   └── auth.py             # Auth dependencies
├── cli/                    # CLI (Typer + Rich)
│   ├── main.py             # App entry, command registration
│   └── commands/           # One file per command
├── engine/                 # Deploy pipeline
│   ├── config_parser.py    # YAML parsing + validation
│   ├── builder.py          # Container image builder
│   ├── providers/          # Provider abstraction (OpenAI, Ollama, fallback chains)
│   ├── runtimes/           # Framework-specific builders (LangGraph, OpenAI Agents)
│   ├── deployers/          # Cloud-specific deployers (Docker Compose, GCP Cloud Run)
│   └── schema/             # JSON Schema for agent.yaml
├── registry/               # Catalog services (CRUD + search)
├── connectors/             # Integration plugins
├── dashboard/              # React frontend
│   ├── src/pages/          # Page components (see list below)
│   ├── src/components/     # Shared UI components
│   ├── src/hooks/          # React Query hooks
│   ├── src/lib/            # API client, utilities
│   └── tests/e2e/          # Playwright tests
├── deploy/                 # Docker Compose config
├── tests/unit/             # Python unit tests
└── alembic/                # Database migrations

Studio Pages

PagePathDescription
Agents/agentsAgent registry browser
Agent Detail/agents/:idAgent detail + deploy history
Agent Builder/agents/builderVisual drag-and-drop agent builder (ReactFlow canvas, 8 node types)
Deploys/deploysDeploy from Studio with 8-step pipeline dialog
Prompts/promptsPrompt registry + test panel
Prompt Builder/prompts/builderTemplate variables, live preview, versioning
Tools/toolsTool registry
Tool Builder/tools/builderTool builder + sandbox execution
MCP Servers/mcp-serversMCP server registry
Models/modelsModel registry + model compare
RAG Builder/ragRAG index management, file ingestion, hybrid search
Memory Builder/memoryMemory config management, conversation storage
Approvals/approvalsApproval workflow, PR review UI, environment promotion
Activity/activityActivity feed / audit log
Settings/settingsOrg + user settings

API Route Groups

MethodEndpoint prefixDescription
GET/POST/api/v1/agentsAgent CRUD + clone, validate, from-yaml
POST/api/v1/deploysTrigger deploy; poll status
GET/POST/api/v1/promptsPrompt registry; /prompts/test for live testing
GET/POST/api/v1/registry/toolsTool registry
GET/POST/api/v1/ragRAG indexes, file ingestion, hybrid search
GET/POST/api/v1/memoryMemory configs, conversation storage
GET/POST/api/v1/mcp-serversMCP server registry (CRUD, test, discover, execute)
GET/POST/api/v1/gitGit workflow + PR review
GET/POST/api/v1/providersLLM provider config
POST/api/v1/tools/sandbox/executeExecute a tool in sandbox
GET/POST/api/v1/teamsTeam management
GET/api/v1/costsCost tracking (filterable by team/agent/model)
GET/api/v1/auditAudit trail
GET/POST/api/v1/tracingDistributed tracing
GET/POST/api/v1/evalsAgent evaluation
GET/POST/api/v1/playgroundChat playground
GET/POST/api/v1/a2aAgent-to-agent (A2A) communication
GET/api/v1/agentopsFleet operations page in Studio
GET/api/v1/gatewayModel gateway status + proxy
GET/POST/api/v1/marketplaceCommunity marketplace
GET/POST/api/v1/templatesAgent templates
GET/POST/api/v1/orchestrationsOrchestration management
GET/api/v1/registry/searchCross-entity registry search
GET/api/v2/agentsv2 agents endpoint (cursor pagination)

Environment Variables

Key variables in .env:

# Required
DATABASE_URL=postgresql+asyncpg://agentbreeder:agentbreeder@localhost:5432/agentbreeder
REDIS_URL=redis://localhost:6379
SECRET_KEY=dev-secret-key
AGENTBREEDER_ENV=development

# Auth
JWT_SECRET_KEY=dev-jwt-secret
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=1440

# Optional integrations
LITELLM_BASE_URL=http://localhost:4000

Common Tasks

Add a new API endpoint

  1. Add route in api/routes/
  2. Add service logic in api/services/ or registry/
  3. Add Pydantic schemas in api/models/schemas.py
  4. Write unit tests in tests/unit/

Add a new CLI command

  1. Create cli/commands/your_command.py
  2. Register in cli/main.py: app.command(name="your-command")(your_module.your_function)
  3. Write unit tests

Add a new Studio page

  1. Create page in dashboard/src/pages/
  2. Add route in dashboard/src/App.tsx
  3. Add navigation link in dashboard/src/components/shell.tsx
  4. Write Playwright E2E test in dashboard/tests/e2e/

Modify the database schema

  1. Update SQLAlchemy model in api/models/
  2. Create migration: alembic revision --autogenerate -m "description"
  3. Review the generated migration file
  4. Apply: alembic upgrade head

Troubleshooting

Port already in use:

lsof -i :8000    # Find what's using the port
kill -9 <PID>    # Kill it

Database connection refused:

docker compose -f deploy/docker-compose.yml ps    # Check if postgres is running
docker compose -f deploy/docker-compose.yml up -d postgres

Stale migrations:

alembic downgrade base && alembic upgrade head    # Reset DB

Node modules issues:

cd dashboard && rm -rf node_modules && npm install

On this page