Skip to main content

CI/CD for LLM behavior. Prompts don't ship until behavior passes tests.

Project description

BehaviorCI

CI/CD for LLM behavior.

Prompts don't ship until behavior passes tests.

BehaviorCI adds a merge gate in front of AI systems.
You define expected behavior as specs + tests + thresholds.
Every prompt or model change is evaluated in CI—and fails the build if behavior regresses.

Think GitHub Actions for LLM behavior.


Why this exists

LLM behavior silently regresses:

  • Prompt tweaks break edge cases
  • Model updates shift outputs
  • Fixes aren't captured as tests
  • The same failures reappear

Traditional CI protects code, not behavior.

BehaviorCI turns LLM behavior into an engineering artifact:

  • Versioned in git
  • Reviewed in PRs
  • Tested on every change
  • Promoted only if thresholds pass
  • Rollbackable when behavior breaks

What it is (and isn't)

✅ It is

  • CI/CD for LLM behavior
  • A file-first spec format ("Behavior Bundles")
  • Deterministic eval runs with reports & diffs
  • Merge-blocking gates

❌ It is not

  • A prompt optimizer
  • Observability or monitoring
  • An agent framework
  • A hosted black box

Installation

pip install behaviorci

Quickstart

# Create an example bundle
behaviorci init bundles/my-test

# Validate configuration
behaviorci validate bundles/my-test/bundle.yaml

# Run with mock provider (no API key needed)
behaviorci run bundles/my-test/bundle.yaml --provider mock

# Run with OpenAI
export OPENAI_API_KEY=sk-xxx
behaviorci run bundles/my-test/bundle.yaml

If thresholds fail → exit code ≠ 0 → CI fails.


Core Concept: Behavior Bundles

A Behavior Bundle defines:

Component Purpose
bundle.yaml Configuration: prompt path, dataset, thresholds
prompt.md Prompt template with {{ variables }}
dataset.jsonl Test cases (one JSON per line)
schema.json Output structure validation (optional)

Example bundle.yaml

name: my-feature
version: "1.0"

prompt_path: prompt.md
dataset_path: dataset.jsonl

output_contract:
  schema_path: schema.json
  invariants:
    - "len(raw_output) < 1000"

thresholds:
  - metric: pass_rate
    operator: ">="
    value: 0.9

provider:
  name: openai
  model: gpt-4o-mini
  temperature: 0.0

See docs/behavior-bundles.md for full specification.


CI Integration

GitHub Actions

name: Behavior Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v5
      with:
        python-version: "3.11"
    - run: pip install behaviorci
    - run: behaviorci run bundles/my-feature/bundle.yaml
      env:
        OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

See docs/ci-integration.md for GitLab, CircleCI, and Azure DevOps examples.


Providers

Provider Environment Variable Example Models
OpenAI OPENAI_API_KEY gpt-4o, gpt-4o-mini
Anthropic ANTHROPIC_API_KEY claude-3-opus, claude-3-sonnet
Mock (none) Deterministic test responses

CLI Commands

Command Description
behaviorci init [path] Scaffold example bundle
behaviorci validate <bundle> Validate configuration
behaviorci run <bundle> Execute tests and emit report

Run Options

behaviorci run bundle.yaml --provider openai  # Override provider
behaviorci run bundle.yaml --format json      # JSON output
behaviorci run bundle.yaml --output report.md # Write to file
behaviorci run bundle.yaml --verbose          # Detailed output

See docs/cli.md for full reference.


Documentation

Document Description
Quickstart Get started in 5 minutes
Architecture System design and components
Behavior Bundles Full bundle specification
CLI Reference All commands and options
CI Integration GitHub, GitLab, CircleCI guides
FAQ Common questions
Roadmap What's coming next

Development

# Clone and install in development mode
git clone https://github.com/behaviorci/behaviorci
cd behaviorci
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Lint
ruff check behaviorci/

# Type check
mypy behaviorci/

See CONTRIBUTING.md for guidelines.


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

behaviorci-0.1.0.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

behaviorci-0.1.0-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file behaviorci-0.1.0.tar.gz.

File metadata

  • Download URL: behaviorci-0.1.0.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.21

File hashes

Hashes for behaviorci-0.1.0.tar.gz
Algorithm Hash digest
SHA256 250fe41e7f6500875cb3f235cc965278850e8d6b0e418ab400394941ce35470a
MD5 5271f37a6a96378b17b8e550b20fb8ea
BLAKE2b-256 a777e8e870ff86b00ddadc1aea6b99a967211a6050914a19fe70f1dbb5fd3cee

See more details on using hashes here.

File details

Details for the file behaviorci-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: behaviorci-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.21

File hashes

Hashes for behaviorci-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2904a7a92fefcb06a3db2e549a4a62a9a61862160deaba6db8bcdfc041dd07e4
MD5 82b60b41edb5de3193fef257e8cae63b
BLAKE2b-256 296a133862da1994b9e8bcf9f5593d12739d774821a317baadd4c8e502cace58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page