agentgate-ci 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentgate_ci-0.1.0/.gitignore +34 -0
- agentgate_ci-0.1.0/LICENSE +21 -0
- agentgate_ci-0.1.0/PKG-INFO +263 -0
- agentgate_ci-0.1.0/README.md +236 -0
- agentgate_ci-0.1.0/agentgate/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/__main__.py +5 -0
- agentgate_ci-0.1.0/agentgate/adapters/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/adapters/base.py +156 -0
- agentgate_ci-0.1.0/agentgate/cache.py +69 -0
- agentgate_ci-0.1.0/agentgate/ci/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/ci/github.py +124 -0
- agentgate_ci-0.1.0/agentgate/ci/publish.py +117 -0
- agentgate_ci-0.1.0/agentgate/cli.py +1242 -0
- agentgate_ci-0.1.0/agentgate/config.py +281 -0
- agentgate_ci-0.1.0/agentgate/demo.py +185 -0
- agentgate_ci-0.1.0/agentgate/demo_bundle/agentgate.yaml +67 -0
- agentgate_ci-0.1.0/agentgate/demo_bundle/golden.jsonl +50 -0
- agentgate_ci-0.1.0/agentgate/demo_bundle/runs.json.gz +0 -0
- agentgate_ci-0.1.0/agentgate/demo_bundle/security.jsonl +25 -0
- agentgate_ci-0.1.0/agentgate/gate/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/gate/aa.py +236 -0
- agentgate_ci-0.1.0/agentgate/gate/compare.py +255 -0
- agentgate_ci-0.1.0/agentgate/gate/data.py +144 -0
- agentgate_ci-0.1.0/agentgate/gate/orchestrate.py +466 -0
- agentgate_ci-0.1.0/agentgate/gate/planted.py +359 -0
- agentgate_ci-0.1.0/agentgate/gate/policy.py +321 -0
- agentgate_ci-0.1.0/agentgate/gate/security.py +92 -0
- agentgate_ci-0.1.0/agentgate/gate/versions.py +109 -0
- agentgate_ci-0.1.0/agentgate/load/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/load/canary.py +55 -0
- agentgate_ci-0.1.0/agentgate/load/checkpoints.py +91 -0
- agentgate_ci-0.1.0/agentgate/load/commands.py +165 -0
- agentgate_ci-0.1.0/agentgate/load/report.py +203 -0
- agentgate_ci-0.1.0/agentgate/load/runner.py +151 -0
- agentgate_ci-0.1.0/agentgate/migrate.py +64 -0
- agentgate_ci-0.1.0/agentgate/provenance.py +81 -0
- agentgate_ci-0.1.0/agentgate/reads.py +514 -0
- agentgate_ci-0.1.0/agentgate/reporters/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/reporters/json_report.py +46 -0
- agentgate_ci-0.1.0/agentgate/reporters/markdown.py +172 -0
- agentgate_ci-0.1.0/agentgate/runner.py +251 -0
- agentgate_ci-0.1.0/agentgate/scorers/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/scorers/aggregate.py +139 -0
- agentgate_ci-0.1.0/agentgate/scorers/case_scorer.py +95 -0
- agentgate_ci-0.1.0/agentgate/scorers/deterministic.py +60 -0
- agentgate_ci-0.1.0/agentgate/scorers/judge.py +285 -0
- agentgate_ci-0.1.0/agentgate/scorers/rubrics.py +97 -0
- agentgate_ci-0.1.0/agentgate/security/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/security/checks.py +65 -0
- agentgate_ci-0.1.0/agentgate/security/pii.py +77 -0
- agentgate_ci-0.1.0/agentgate/security/rubrics.py +61 -0
- agentgate_ci-0.1.0/agentgate/security/scorer.py +129 -0
- agentgate_ci-0.1.0/agentgate/security/similarity.py +25 -0
- agentgate_ci-0.1.0/agentgate/settings.py +34 -0
- agentgate_ci-0.1.0/agentgate/sql/0003_eval_runs.sql +55 -0
- agentgate_ci-0.1.0/agentgate/sql/0004_eval_run_scope.sql +5 -0
- agentgate_ci-0.1.0/agentgate/sql/0005_gate_decisions.sql +25 -0
- agentgate_ci-0.1.0/agentgate/sql/__init__.py +1 -0
- agentgate_ci-0.1.0/agentgate/stats/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/stats/bootstrap.py +220 -0
- agentgate_ci-0.1.0/agentgate/stats/run_intervals.py +92 -0
- agentgate_ci-0.1.0/agentgate/store.py +415 -0
- agentgate_ci-0.1.0/agentgate/validation/__init__.py +0 -0
- agentgate_ci-0.1.0/agentgate/validation/agreement.py +295 -0
- agentgate_ci-0.1.0/agentgate/validation/commands.py +247 -0
- agentgate_ci-0.1.0/agentgate/validation/groundedness_sample.py +170 -0
- agentgate_ci-0.1.0/agentgate/validation/labeler.py +167 -0
- agentgate_ci-0.1.0/agentgate/validation/labels.py +62 -0
- agentgate_ci-0.1.0/agentgate/validation/rescore.py +130 -0
- agentgate_ci-0.1.0/agentgate/validation/sample.py +286 -0
- agentgate_ci-0.1.0/app/static/vendor/README.md +11 -0
- agentgate_ci-0.1.0/marketplace/agentgate-action/LICENSE +21 -0
- agentgate_ci-0.1.0/marketplace/agentgate-action/README.md +92 -0
- agentgate_ci-0.1.0/pyproject.toml +105 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Secrets
|
|
2
|
+
.env
|
|
3
|
+
.env.*
|
|
4
|
+
!.env.example
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*.egg-info/
|
|
10
|
+
build/
|
|
11
|
+
dist/
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
|
|
15
|
+
# Tooling caches
|
|
16
|
+
.pytest_cache/
|
|
17
|
+
.mypy_cache/
|
|
18
|
+
.ruff_cache/
|
|
19
|
+
.coverage
|
|
20
|
+
coverage.xml
|
|
21
|
+
htmlcov/
|
|
22
|
+
|
|
23
|
+
# Claude Code / editors
|
|
24
|
+
.claude/session-data/
|
|
25
|
+
.claude/settings.local.json
|
|
26
|
+
.qodo/
|
|
27
|
+
.vscode/
|
|
28
|
+
.idea/
|
|
29
|
+
|
|
30
|
+
# OS
|
|
31
|
+
.DS_Store
|
|
32
|
+
|
|
33
|
+
# Static dashboard export (make site)
|
|
34
|
+
/site/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 romit-23
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agentgate-ci
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CI/CD release gate for LLM agents: blocks a merge when quality, safety, cost or latency regress significantly
|
|
5
|
+
Project-URL: Homepage, https://github.com/romit-23/AgentGate
|
|
6
|
+
Project-URL: Repository, https://github.com/romit-23/AgentGate
|
|
7
|
+
Project-URL: Issues, https://github.com/romit-23/AgentGate/issues
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: agents,bootstrap,ci,evaluation,llm,release-gate
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
15
|
+
Classifier: Topic :: Software Development :: Testing
|
|
16
|
+
Requires-Python: <3.13,>=3.12
|
|
17
|
+
Requires-Dist: deepeval==4.3.5
|
|
18
|
+
Requires-Dist: httpx>=0.27
|
|
19
|
+
Requires-Dist: litellm>=1.50
|
|
20
|
+
Requires-Dist: numpy>=1.26
|
|
21
|
+
Requires-Dist: psycopg[binary,pool]>=3.2
|
|
22
|
+
Requires-Dist: pydantic-settings>=2.3
|
|
23
|
+
Requires-Dist: pydantic>=2.7
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Requires-Dist: typer>=0.12
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# AgentGate
|
|
29
|
+
|
|
30
|
+
**A CI release gate for LLM agents.** Before a new agent version ships (a prompt, model, tool or retrieval change), AgentGate runs the candidate and the current baseline on a golden dataset and an adversarial security suite, K times each. It compares them case by case with a paired bootstrap and **blocks the merge if quality, safety, cost or latency regress by a statistically significant amount**. The verdict appears on the pull request as one updating comment and an `AgentGate` check.
|
|
31
|
+
|
|
32
|
+
The system under test is a small LangGraph research assistant over a synthetic "Northwind Cloud" knowledge base. The gate is the product.
|
|
33
|
+
|
|
34
|
+
> **Dashboard:** [agentgate-dashboard.pages.dev](https://agentgate-dashboard.pages.dev): every scored version, its verdict, and each run's metrics with confidence intervals (a snapshot exported 2026-12-05).
|
|
35
|
+
> **Demo video:** _to be recorded._
|
|
36
|
+
> **Status (2026-12-05):** v1 is built and measured (milestones 1–8 code on `main`). The dashboard is live as a static snapshot (link above); the PyPI upload is prepared but not live yet. No new gate runs are being made **in this repository**: every number below was measured with OpenAI models, and the credits that paid for them have run out. In your own repository the gate runs on [your own API key](#bring-your-own-key). See [Status and limits](#status-and-limits).
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
pull request changes agents/
|
|
40
|
+
│
|
|
41
|
+
┌─────────────────────▼─────────────────────┐
|
|
42
|
+
│ GitHub Action (runs from the PR's BASE) │
|
|
43
|
+
└─────────────────────┬─────────────────────┘
|
|
44
|
+
baseline (cached) │ candidate (git worktree, own process)
|
|
45
|
+
┌─────────────┴─────────────┐
|
|
46
|
+
▼ ▼
|
|
47
|
+
50 golden cases × K + 25 security cases × K
|
|
48
|
+
scored by deterministic checks + a pinned LLM judge (DeepEval)
|
|
49
|
+
└─────────────┬─────────────┘
|
|
50
|
+
▼
|
|
51
|
+
paired bootstrap per metric (10,000 resamples, seeded)
|
|
52
|
+
BLOCK = worse than threshold AND 95% CI excludes 0
|
|
53
|
+
BLOCK = any critical security case fails
|
|
54
|
+
▼
|
|
55
|
+
one PR comment + AgentGate check (success / failure / neutral)
|
|
56
|
+
every decision stored in Postgres: version_id, dataset hash, judge fingerprint, git SHA
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Try it in one minute (no API key, no database)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
uvx --from git+https://github.com/romit-23/AgentGate agentgate demo # or, in a clone: uv run agentgate demo
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`agentgate demo` replays five comparisons of real recorded runs through the gate's code and prints the PR comment for each: an unchanged agent (✅ pass), the same agent against a baseline from another day (⚠️ warn, [ADR 0010](docs/decisions/0010-time-dependent-metrics.md)), and three planted regressions (❌ block: one-chunk retrieval, a cheaper model, emails without approval). The runs ship inside the package (scores, latency and cost per case-run, no answers), so nothing is scored and no model is called. `--list` names the scenarios, `--format json` gives the full reports. CI checks that the installed wheel reproduces all five verdicts with an empty environment.
|
|
66
|
+
|
|
67
|
+
## Results
|
|
68
|
+
|
|
69
|
+
All from [docs/benchmarks/RESULTS.md](docs/benchmarks/RESULTS.md). Each number links to a run report with its run ids. Small samples are shown with their 95% bounds, because "0 of 10" is not "0%".
|
|
70
|
+
|
|
71
|
+
| What was measured | Result |
|
|
72
|
+
|---|---|
|
|
73
|
+
| **False blocks:** an unchanged agent gated against itself (A/A) | **0 of 10** trials blocked (upper bound 26%). Replaying all 110 pairs of those runs across two days found 5 blocks from **latency and cost drift**; since [ADR 0010](docs/decisions/0010-time-dependent-metrics.md), 0 ([§8](docs/benchmarks/RESULTS.md#8-aa-test-milestone-7)) |
|
|
74
|
+
| **Catches:** deliberately broken versions, predictions committed before the runs | **5 of 5** blocked, all as predicted (lower bound 55%). Two of them rested on 1 of 3 repeats ([§9](docs/benchmarks/RESULTS.md#9-planted-regressions-milestone-7)) |
|
|
75
|
+
| **Judge vs a human** (35 blind labels, Cohen's κ, target 0.6) | answer_correctness **0.81** ✅. groundedness **0.42** ❌, so groundedness only warns and never blocks ([§7](docs/benchmarks/RESULTS.md#7-judge-validation-milestone-7), [ADR 0009](docs/decisions/0009-groundedness-judge.md)) |
|
|
76
|
+
| **Real PRs** | [PR #7](https://github.com/romit-23/AgentGate/pull/7): a weakened prompt was ❌ blocked (tool_selection_accuracy −0.19, CI [−0.31, −0.09]), and the fix turned the same comment ✅ green. [PR #21](https://github.com/romit-23/AgentGate/pull/21): a comment-only change ✅ passed |
|
|
77
|
+
| **Gate time and cost** (cached baseline) | 7–8 minutes, **about $2 per push** that changes the agent. The PRD target was $1 per run, so that target was missed. $0 for PRs that don't touch the agent |
|
|
78
|
+
| **Session isolation** (50 concurrent sessions, real model) | 0 leaks, 0 errors ([§6](docs/benchmarks/RESULTS.md#6-load-and-isolation-milestone-7)) |
|
|
79
|
+
| Unit-test coverage of stats, gate and scorers | 97% |
|
|
80
|
+
|
|
81
|
+
The full PRD scorecard is in [RESULTS.md](docs/benchmarks/RESULTS.md#against-the-prds-success-criteria-section-15).
|
|
82
|
+
|
|
83
|
+
## Quickstart (local)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
cp .env.example .env # fill in keys in .env only (never in .env.example or a chat)
|
|
87
|
+
make install
|
|
88
|
+
make up # Postgres 16 + pgvector and the API, both health-checked
|
|
89
|
+
make ingest # embed the synthetic KB (needs the embedding model's key)
|
|
90
|
+
curl localhost:8000/health
|
|
91
|
+
make test # unit tests: no network (a socket guard enforces it), no DB
|
|
92
|
+
make test-integration # needs `make up`; uses a separate agentgate_test database
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The compose Postgres publishes on host port **5433**, so it doesn't clash with a local Postgres (override with `AGENTGATE_DB_PORT`). Local tools default to `DATABASE_URL=postgresql://agentgate:agentgate@localhost:5433/agentgate`.
|
|
96
|
+
|
|
97
|
+
Models are configured in `.env` and `agentgate.yaml`, through LiteLLM:
|
|
98
|
+
|
|
99
|
+
| Role | Model used for every published number | Key |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| Agent (`AGENT_MODEL`) | `openai/gpt-5.4-mini` | `OPENAI_API_KEY` |
|
|
102
|
+
| Judge (`agentgate.yaml`, pinned, temperature 0, prompts `judge-v1`) | `openai/gpt-5.2` | `OPENAI_API_KEY` |
|
|
103
|
+
| Embeddings (`EMBEDDING_MODEL`, 768 dims) | `openai/text-embedding-3-small` | `OPENAI_API_KEY` |
|
|
104
|
+
|
|
105
|
+
Another provider is a config change (`gemini/…`, `anthropic/…`; the key is chosen from the model's prefix), but a different judge gives a different judge fingerprint. Stored baselines then no longer match and are re-scored, and the judge validation above doesn't carry over. The embedding dimension is fixed by `vector(768)` in `migrations/0001_kb.sql`.
|
|
106
|
+
|
|
107
|
+
## Commands
|
|
108
|
+
|
|
109
|
+
| Command | What it does | Cost |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| `agentgate run --version HEAD` | score one version on the golden set (`--suite security` for the security suite) | ~$1.71 per 50 × 3 |
|
|
112
|
+
| `agentgate run --baseline main --candidate my-branch` | the gate: score both (baseline cached when stored), compare, print the report, exit 0 pass / 1 block / 2 no verdict | ~$2 cached |
|
|
113
|
+
| `agentgate demo` | the gate's verdicts on five bundled real comparisons, no key and no database | $0 |
|
|
114
|
+
| `agentgate compare --baseline-run <uuid> --candidate-run <uuid>` | replay the gate on two stored runs | $0 |
|
|
115
|
+
| `agentgate report --run <uuid>` | print a stored decision as the PR comment (`--format json`) | $0 |
|
|
116
|
+
| `agentgate aa-test --version main --trials N` | false-block rate: gate a version against itself N times | ~$2 per trial |
|
|
117
|
+
| `agentgate planted-test --manifest evals/planted/v1.yaml` | catch rate: gate pre-registered broken versions | ~$2 per variant |
|
|
118
|
+
| `agentgate judge-sample` / `judge-label` / `judge-validate` | judge vs human agreement on stored answers (the labels must come from a person) | $0 |
|
|
119
|
+
| `agentgate load --sessions 50 --concurrency 25` | session isolation under load, against a running app | ~$0.25 |
|
|
120
|
+
| `agentgate migrate` | create the gate's own tables in any Postgres | $0 |
|
|
121
|
+
|
|
122
|
+
Commands that spend estimate first, ask before spending (or take `--yes`), and stop at `budget.max_usd_per_gate_run` per version scored. A run that hits the cap is `budget_exceeded` and can't become a baseline.
|
|
123
|
+
|
|
124
|
+
**How the gate decides** ([ADR 0004](docs/decisions/0004-gate-statistics-and-isolation.md)). Each version runs in its own worker process from a git worktree. A metric **blocks** only if it is worse than its threshold in `agentgate.yaml` *and* its 95% CI excludes 0. If it crosses the threshold but the CI includes 0, it **warns** and the gate still passes. Quality metrics use −0.05; latency p95 and cost per success use +25% and +20%, and block only when both runs finished within 12 h of each other, because latency and token use drift between days. Against an older cached baseline they warn ([ADR 0010](docs/decisions/0010-time-dependent-metrics.md)); the action's `no-cache: true` re-scores the baseline in the same job (about twice the cost) when you want those rules to be able to block. An infra-error or judge-error rate above 5% on either side gives **no verdict**, so provider noise is neutral. Agent failures (step or token limit) above 5% on the candidate block. A critical security case that fails in any repeat blocks ([ADR 0005](docs/decisions/0005-security-suite.md)).
|
|
125
|
+
|
|
126
|
+
## Use AgentGate in your repo
|
|
127
|
+
|
|
128
|
+
| Verdict | Check | Meaning |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| ✅ PASSED | success | no metric regressed beyond its threshold |
|
|
131
|
+
| ⚠️ PASSED WITH WARNINGS | success (failure with `fail-on-warn: true`) | a metric crossed its threshold, but the 95% CI includes 0 |
|
|
132
|
+
| ❌ BLOCKED | failure | a significant regression, or a critical security case failed |
|
|
133
|
+
| ⏸️ NO VERDICT | neutral | provider noise, budget exceeded, or runs not comparable: not the PR's fault |
|
|
134
|
+
|
|
135
|
+
Copy this to `.github/workflows/agentgate.yml`:
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
name: AgentGate
|
|
139
|
+
on:
|
|
140
|
+
pull_request: # every PR; the action skips (green, $0) if the agent didn't change
|
|
141
|
+
permissions:
|
|
142
|
+
contents: read
|
|
143
|
+
pull-requests: write # the PR comment
|
|
144
|
+
checks: write # the AgentGate check
|
|
145
|
+
concurrency:
|
|
146
|
+
group: agentgate-${{ github.event.pull_request.number }}
|
|
147
|
+
cancel-in-progress: true # don't pay for superseded pushes
|
|
148
|
+
jobs:
|
|
149
|
+
gate:
|
|
150
|
+
runs-on: ubuntu-latest
|
|
151
|
+
timeout-minutes: 60
|
|
152
|
+
services:
|
|
153
|
+
db: # used when AGENTGATE_DATABASE_URL isn't set
|
|
154
|
+
image: pgvector/pgvector:pg16
|
|
155
|
+
env: { POSTGRES_USER: agentgate, POSTGRES_PASSWORD: agentgate, POSTGRES_DB: agentgate }
|
|
156
|
+
ports: ["5432:5432"]
|
|
157
|
+
options: --health-cmd "pg_isready -U agentgate" --health-interval 5s --health-retries 10
|
|
158
|
+
env:
|
|
159
|
+
DATABASE_URL: ${{ secrets.AGENTGATE_DATABASE_URL || 'postgresql://agentgate:agentgate@localhost:5432/agentgate' }}
|
|
160
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
161
|
+
LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }}
|
|
162
|
+
LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY }}
|
|
163
|
+
steps:
|
|
164
|
+
- uses: romit-23/AgentGate/action@main
|
|
165
|
+
with:
|
|
166
|
+
paths: agents/ # your agent's code and prompts (space-separated pathspecs)
|
|
167
|
+
config: agentgate.yaml # optional; also: repeats, fail-on-warn, no-cache, install-command, setup-command
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
In this repository the workflow uses the local copy (`uses: ./action`) after checking out the base.
|
|
171
|
+
|
|
172
|
+
**Secrets** (Settings → Secrets and variables → Actions):
|
|
173
|
+
|
|
174
|
+
| Name | Required | What for |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| `OPENAI_API_KEY`, `ANTHROPIC_API_KEY` or `GEMINI_API_KEY` | yes, one or more | your agent's model and the judge, on your account (see [Bring your own key](#bring-your-own-key)) |
|
|
177
|
+
| `AGENTGATE_DATABASE_URL` | no | a persistent Postgres (e.g. Neon; the gate's tables need no extension, this repo's agent needs pgvector). Baselines are cached there, so a push costs ~$2 instead of ~$4 |
|
|
178
|
+
| `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` | no | traces of every gate run |
|
|
179
|
+
|
|
180
|
+
**Things to know:**
|
|
181
|
+
- **The gate runs from the PR's base.** Its config, datasets, thresholds, scorers and even the action come from the base commit, so a PR can't loosen the gate that judges it. One exception: GitHub runs the *workflow file* from the PR itself, so protect `.github/` with CODEOWNERS and required reviews.
|
|
182
|
+
- **Forked PRs are skipped** (job summary + notice, no comment): GitHub gives them no secrets and a read-only token. `pull_request_target` would run untrusted code with your secrets.
|
|
183
|
+
- **The candidate's code runs in CI with your LLM key.** Only PRs from branches in your repository are gated.
|
|
184
|
+
- **Don't add a `paths:` filter to the workflow.** Once a fix commit reverts the agent change, that filter stops the workflow, and the PR's new head never gets a check. The action's `paths` input does the filtering instead.
|
|
185
|
+
- **Installing outside this repository:** make your project a uv project and add the gate as a dev dependency. The package `agentgate-ci` is built but not uploaded yet; until it is, use `uv add --dev git+https://github.com/romit-23/AgentGate`. `setup-command` defaults to `uv run agentgate migrate`, which creates the gate's tables; append your agent's own setup with `&&`. The Marketplace listing is prepared in [docs/marketplace.md](docs/marketplace.md).
|
|
186
|
+
- **Dependencies come from the base.** A PR that adds a package to the agent gets no verdict until the dependency is on the base branch.
|
|
187
|
+
- Make **AgentGate** a required check under Settings → Branches to enforce the gate. A neutral check doesn't block merging.
|
|
188
|
+
- Design: [ADR 0007](docs/decisions/0007-ci-integration.md).
|
|
189
|
+
|
|
190
|
+
### Bring your own key
|
|
191
|
+
|
|
192
|
+
AgentGate has no hosted scoring service and never asks for, stores or forwards an API key. The gate runs inside **your** CI job, and every model call goes from that job straight to your provider, on your account and your bill. Nobody else's key is involved, and nothing is sent to this project.
|
|
193
|
+
|
|
194
|
+
- **Where the key goes:** a GitHub Actions secret in your repository, passed to the job as an environment variable. Never in `agentgate.yaml`, a dataset, a commit or a PR comment. The settings hold it as a secret value, so it isn't logged.
|
|
195
|
+
- **Which keys work:** `OPENAI_API_KEY`, `ANTHROPIC_API_KEY` and `GEMINI_API_KEY`. Calls go through LiteLLM, and the provider prefix of each model in your config (`openai/…`, `anthropic/…`, `gemini/…`) picks the key. Without any of the three, the action skips with a notice and costs nothing.
|
|
196
|
+
- **What it pays for:** your agent's calls (your adapter decides which model and key it uses) and the judge's calls (`judge.model` in `agentgate.yaml`, which must be a different model from your agent's). Embeddings only if your agent uses them.
|
|
197
|
+
- **Using a provider other than OpenAI:** set `judge.model` to one of its models, keep `temperature: 0`, and pass that provider's key in the workflow's `env:` instead of `OPENAI_API_KEY`:
|
|
198
|
+
```yaml
|
|
199
|
+
env:
|
|
200
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
201
|
+
```
|
|
202
|
+
Changing the judge changes the judge fingerprint, so earlier cached baselines no longer match and the next gate run re-scores the base.
|
|
203
|
+
- **What it costs:** about *cases × repeats × (agent call + judge call)* per version scored, and twice that when the baseline isn't cached. This repository's setup (50 cases, K=3, `gpt-5.4-mini` agent, `gpt-5.2` judge at about $0.013 per case-run) costs about $2 per push with a cached baseline and about $4 without one. `budget.max_usd_per_gate_run` in `agentgate.yaml` is a hard cap per version: a run whose estimate exceeds it doesn't start, and a run that reaches it stops and can't become a baseline. Set a spending limit at your provider too.
|
|
204
|
+
- **Who can spend it:** only PRs from branches in your repository. Forked PRs get no secrets and are skipped. The candidate's code runs with your key, so gate only code you'd run anyway.
|
|
205
|
+
- **What our results do and don't cover:** the A/A, planted-regression and judge-agreement numbers above were measured with this repository's agent, dataset and `openai/gpt-5.2` judge. With your agent and another judge they're a starting point, not a guarantee. Before you trust blocks, run `agentgate aa-test` (identical versions, expected to pass) and `agentgate planted-test` (versions you broke on purpose, expected to block) on your own setup. Both run on your key.
|
|
206
|
+
|
|
207
|
+
## Dashboard and read API
|
|
208
|
+
|
|
209
|
+
The app serves server-rendered pages (Jinja2 + HTMX) over the stored results: version history with trends (`/`), and run detail with case results (`/runs/{run_id}`). The JSON read API is `/api/versions`, `/api/runs/{run_id}` and `/api/decisions/{decision_id}`. `POST /api/runs` starts a scored run behind `AGENTGATE_ADMIN_KEY`.
|
|
210
|
+
|
|
211
|
+
With `AGENTGATE_SERVE_AGENT=false` the app is dashboard-only: no agent, no LLM keys, no migrations, and a read-only database role. It has no field that accepts a visitor's key, and nothing a visitor does can start a paid model call. **It's live as a static snapshot at [agentgate-dashboard.pages.dev](https://agentgate-dashboard.pages.dev)** on Cloudflare Pages ($0): `make site` exports the same pages and read API as files ([docs/deploy.md](docs/deploy.md#free-alternative-a-static-snapshot)). The read API there is `api/versions.json`, `api/runs/<id>.json` and `api/decisions/<id>.json`. The snapshot was exported from the local database, so it has the A/A and planted-regression runs but not the CI runs of PR #7 and PR #21. The live server mode is prepared for one Fly.io machine reading the CI database (about $4/month) and isn't deployed: [docs/deploy.md](docs/deploy.md).
|
|
212
|
+
|
|
213
|
+
## The reference agent
|
|
214
|
+
|
|
215
|
+
A LangGraph agent with three tools (`search_kb` over pgvector + full-text search, `calculator`, `send_email`), a human approval step before any email, a code-level send guard ([ADR 0006](docs/decisions/0006-send-guard.md)), step, time and token budgets, a Postgres checkpointer and Langfuse tracing. It runs only in full mode, with `AGENTGATE_API_KEY` set in `.env` (sent as `X-API-Key`):
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
K=... # your AGENTGATE_API_KEY
|
|
219
|
+
# 1. A pricing calculation (search_kb + calculator)
|
|
220
|
+
curl -s localhost:8000/v1/chat -H "X-API-Key: $K" -H 'Content-Type: application/json' \
|
|
221
|
+
-d '{"session_id":"demo1","message":"What does the Pro plan cost per month for 12 seats on annual billing?"}' | jq '{status,answer,tools:[.trajectory.tool_calls[].name],cost:.trajectory.cost_usd}'
|
|
222
|
+
|
|
223
|
+
# 2. A question the KB cannot answer (should say it does not know)
|
|
224
|
+
curl -s localhost:8000/v1/chat -H "X-API-Key: $K" -H 'Content-Type: application/json' \
|
|
225
|
+
-d '{"session_id":"demo2","message":"Who won the 2018 World Cup?"}' | jq '{status,answer}'
|
|
226
|
+
|
|
227
|
+
# 3. An email: the run pauses for approval, nothing is sent yet
|
|
228
|
+
curl -s localhost:8000/v1/chat -H "X-API-Key: $K" -H 'Content-Type: application/json' \
|
|
229
|
+
-d '{"session_id":"demo3","message":"Email ana@example.com a one-line summary of the refund policy."}' | jq '{status,pending_action}'
|
|
230
|
+
# approve (or send {"approved":false} to reject)
|
|
231
|
+
curl -s localhost:8000/v1/chat/demo3/approve -H "X-API-Key: $K" -H 'Content-Type: application/json' \
|
|
232
|
+
-d '{"approved":true}' | jq '{status,answer}'
|
|
233
|
+
docker compose exec db psql -U agentgate -c 'SELECT session_id, to_addr, subject FROM mock_outbox'
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Every run returns a `trajectory` (answer, tool calls, retrieved doc ids, tokens, cost, latency, `trace_id`) and is stamped with a `version_id`: a hash of the prompt files, the agent's code, the model, and the tool and retrieval config. Runs stop with a typed error (`step_limit`, `timeout`, `token_budget`, `llm_error`), never a crash.
|
|
237
|
+
|
|
238
|
+
## Status and limits
|
|
239
|
+
|
|
240
|
+
**Deployed:** the dashboard, as a static snapshot on Cloudflare Pages ([agentgate-dashboard.pages.dev](https://agentgate-dashboard.pages.dev)).
|
|
241
|
+
|
|
242
|
+
**Not done yet:** the Fly.io deployment (the live, self-updating dashboard), the PyPI upload, the Marketplace listing (it needs a separate public repository) and the demo video. All are owner steps.
|
|
243
|
+
|
|
244
|
+
**No new runs here.** The OpenAI credits that paid for this repository's agent, judge and embeddings have run out. Until a key with credits is configured again, a PR to *this* repository that changes `agents/` can't be scored and should end without a verdict (neutral). That doesn't affect other repositories: the gate there runs on [their own key](#bring-your-own-key). Everything else works without an LLM: lint, type checks, unit and integration tests, `agentgate demo`, the dashboard, the read API, `compare` and `report`.
|
|
245
|
+
|
|
246
|
+
**What the numbers don't show:**
|
|
247
|
+
- **Small samples.** 10 A/A trials and 5 planted regressions meet the PRD's targets by count, but the 95% bounds are wide (26% and 55%). The planted regressions were written by the gate's author.
|
|
248
|
+
- **Latency and cost drift between days.** A baseline cached on a faster day blocked unchanged agents in 5 of 110 replayed pairs. Since ADR 0010 those rules only warn against a baseline more than 12 h old, so in CI a pure latency or cost regression usually warns rather than blocks. Quality metrics didn't drift.
|
|
249
|
+
- **Groundedness isn't validated** (κ 0.42). It only warns. The judge doesn't see calculator results.
|
|
250
|
+
- **The judge and the agent come from the same vendor.** Self-preference was never measured.
|
|
251
|
+
- **One agent, 50 synthetic golden cases, 25 security cases, K=3.** Category CIs are wide. K=3 can't separate a 1-in-3 failure rate from a 2-in-3 one.
|
|
252
|
+
- **Cost:** about $2 per gated push, against the PRD's $1.
|
|
253
|
+
- **Not a security claim.** AgentGate reports pass rates on a documented suite. It doesn't make the agent secure.
|
|
254
|
+
- Open items: [docs/TODO.md](docs/TODO.md).
|
|
255
|
+
|
|
256
|
+
## Documentation
|
|
257
|
+
|
|
258
|
+
- [docs/PRD.md](docs/PRD.md): requirements and success criteria
|
|
259
|
+
- [docs/benchmarks/RESULTS.md](docs/benchmarks/RESULTS.md): every measured result, with run reports and raw data
|
|
260
|
+
- [docs/decisions/](docs/decisions/): ADRs 0001–0010 (judge, model stack, gate statistics, security suite, send guard, CI integration, trust layer, groundedness, latency and cost against an old baseline)
|
|
261
|
+
- [docs/deploy.md](docs/deploy.md), [docs/marketplace.md](docs/marketplace.md): deployment and publishing steps
|
|
262
|
+
|
|
263
|
+
License: [MIT](LICENSE).
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# AgentGate
|
|
2
|
+
|
|
3
|
+
**A CI release gate for LLM agents.** Before a new agent version ships (a prompt, model, tool or retrieval change), AgentGate runs the candidate and the current baseline on a golden dataset and an adversarial security suite, K times each. It compares them case by case with a paired bootstrap and **blocks the merge if quality, safety, cost or latency regress by a statistically significant amount**. The verdict appears on the pull request as one updating comment and an `AgentGate` check.
|
|
4
|
+
|
|
5
|
+
The system under test is a small LangGraph research assistant over a synthetic "Northwind Cloud" knowledge base. The gate is the product.
|
|
6
|
+
|
|
7
|
+
> **Dashboard:** [agentgate-dashboard.pages.dev](https://agentgate-dashboard.pages.dev): every scored version, its verdict, and each run's metrics with confidence intervals (a snapshot exported 2026-12-05).
|
|
8
|
+
> **Demo video:** _to be recorded._
|
|
9
|
+
> **Status (2026-12-05):** v1 is built and measured (milestones 1–8 code on `main`). The dashboard is live as a static snapshot (link above); the PyPI upload is prepared but not live yet. No new gate runs are being made **in this repository**: every number below was measured with OpenAI models, and the credits that paid for them have run out. In your own repository the gate runs on [your own API key](#bring-your-own-key). See [Status and limits](#status-and-limits).
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
pull request changes agents/
|
|
13
|
+
│
|
|
14
|
+
┌─────────────────────▼─────────────────────┐
|
|
15
|
+
│ GitHub Action (runs from the PR's BASE) │
|
|
16
|
+
└─────────────────────┬─────────────────────┘
|
|
17
|
+
baseline (cached) │ candidate (git worktree, own process)
|
|
18
|
+
┌─────────────┴─────────────┐
|
|
19
|
+
▼ ▼
|
|
20
|
+
50 golden cases × K + 25 security cases × K
|
|
21
|
+
scored by deterministic checks + a pinned LLM judge (DeepEval)
|
|
22
|
+
└─────────────┬─────────────┘
|
|
23
|
+
▼
|
|
24
|
+
paired bootstrap per metric (10,000 resamples, seeded)
|
|
25
|
+
BLOCK = worse than threshold AND 95% CI excludes 0
|
|
26
|
+
BLOCK = any critical security case fails
|
|
27
|
+
▼
|
|
28
|
+
one PR comment + AgentGate check (success / failure / neutral)
|
|
29
|
+
every decision stored in Postgres: version_id, dataset hash, judge fingerprint, git SHA
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Try it in one minute (no API key, no database)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uvx --from git+https://github.com/romit-23/AgentGate agentgate demo # or, in a clone: uv run agentgate demo
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`agentgate demo` replays five comparisons of real recorded runs through the gate's code and prints the PR comment for each: an unchanged agent (✅ pass), the same agent against a baseline from another day (⚠️ warn, [ADR 0010](docs/decisions/0010-time-dependent-metrics.md)), and three planted regressions (❌ block: one-chunk retrieval, a cheaper model, emails without approval). The runs ship inside the package (scores, latency and cost per case-run, no answers), so nothing is scored and no model is called. `--list` names the scenarios, `--format json` gives the full reports. CI checks that the installed wheel reproduces all five verdicts with an empty environment.
|
|
39
|
+
|
|
40
|
+
## Results
|
|
41
|
+
|
|
42
|
+
All from [docs/benchmarks/RESULTS.md](docs/benchmarks/RESULTS.md). Each number links to a run report with its run ids. Small samples are shown with their 95% bounds, because "0 of 10" is not "0%".
|
|
43
|
+
|
|
44
|
+
| What was measured | Result |
|
|
45
|
+
|---|---|
|
|
46
|
+
| **False blocks:** an unchanged agent gated against itself (A/A) | **0 of 10** trials blocked (upper bound 26%). Replaying all 110 pairs of those runs across two days found 5 blocks from **latency and cost drift**; since [ADR 0010](docs/decisions/0010-time-dependent-metrics.md), 0 ([§8](docs/benchmarks/RESULTS.md#8-aa-test-milestone-7)) |
|
|
47
|
+
| **Catches:** deliberately broken versions, predictions committed before the runs | **5 of 5** blocked, all as predicted (lower bound 55%). Two of them rested on 1 of 3 repeats ([§9](docs/benchmarks/RESULTS.md#9-planted-regressions-milestone-7)) |
|
|
48
|
+
| **Judge vs a human** (35 blind labels, Cohen's κ, target 0.6) | answer_correctness **0.81** ✅. groundedness **0.42** ❌, so groundedness only warns and never blocks ([§7](docs/benchmarks/RESULTS.md#7-judge-validation-milestone-7), [ADR 0009](docs/decisions/0009-groundedness-judge.md)) |
|
|
49
|
+
| **Real PRs** | [PR #7](https://github.com/romit-23/AgentGate/pull/7): a weakened prompt was ❌ blocked (tool_selection_accuracy −0.19, CI [−0.31, −0.09]), and the fix turned the same comment ✅ green. [PR #21](https://github.com/romit-23/AgentGate/pull/21): a comment-only change ✅ passed |
|
|
50
|
+
| **Gate time and cost** (cached baseline) | 7–8 minutes, **about $2 per push** that changes the agent. The PRD target was $1 per run, so that target was missed. $0 for PRs that don't touch the agent |
|
|
51
|
+
| **Session isolation** (50 concurrent sessions, real model) | 0 leaks, 0 errors ([§6](docs/benchmarks/RESULTS.md#6-load-and-isolation-milestone-7)) |
|
|
52
|
+
| Unit-test coverage of stats, gate and scorers | 97% |
|
|
53
|
+
|
|
54
|
+
The full PRD scorecard is in [RESULTS.md](docs/benchmarks/RESULTS.md#against-the-prds-success-criteria-section-15).
|
|
55
|
+
|
|
56
|
+
## Quickstart (local)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cp .env.example .env # fill in keys in .env only (never in .env.example or a chat)
|
|
60
|
+
make install
|
|
61
|
+
make up # Postgres 16 + pgvector and the API, both health-checked
|
|
62
|
+
make ingest # embed the synthetic KB (needs the embedding model's key)
|
|
63
|
+
curl localhost:8000/health
|
|
64
|
+
make test # unit tests: no network (a socket guard enforces it), no DB
|
|
65
|
+
make test-integration # needs `make up`; uses a separate agentgate_test database
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The compose Postgres publishes on host port **5433**, so it doesn't clash with a local Postgres (override with `AGENTGATE_DB_PORT`). Local tools default to `DATABASE_URL=postgresql://agentgate:agentgate@localhost:5433/agentgate`.
|
|
69
|
+
|
|
70
|
+
Models are configured in `.env` and `agentgate.yaml`, through LiteLLM:
|
|
71
|
+
|
|
72
|
+
| Role | Model used for every published number | Key |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| Agent (`AGENT_MODEL`) | `openai/gpt-5.4-mini` | `OPENAI_API_KEY` |
|
|
75
|
+
| Judge (`agentgate.yaml`, pinned, temperature 0, prompts `judge-v1`) | `openai/gpt-5.2` | `OPENAI_API_KEY` |
|
|
76
|
+
| Embeddings (`EMBEDDING_MODEL`, 768 dims) | `openai/text-embedding-3-small` | `OPENAI_API_KEY` |
|
|
77
|
+
|
|
78
|
+
Another provider is a config change (`gemini/…`, `anthropic/…`; the key is chosen from the model's prefix), but a different judge gives a different judge fingerprint. Stored baselines then no longer match and are re-scored, and the judge validation above doesn't carry over. The embedding dimension is fixed by `vector(768)` in `migrations/0001_kb.sql`.
|
|
79
|
+
|
|
80
|
+
## Commands
|
|
81
|
+
|
|
82
|
+
| Command | What it does | Cost |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `agentgate run --version HEAD` | score one version on the golden set (`--suite security` for the security suite) | ~$1.71 per 50 × 3 |
|
|
85
|
+
| `agentgate run --baseline main --candidate my-branch` | the gate: score both (baseline cached when stored), compare, print the report, exit 0 pass / 1 block / 2 no verdict | ~$2 cached |
|
|
86
|
+
| `agentgate demo` | the gate's verdicts on five bundled real comparisons, no key and no database | $0 |
|
|
87
|
+
| `agentgate compare --baseline-run <uuid> --candidate-run <uuid>` | replay the gate on two stored runs | $0 |
|
|
88
|
+
| `agentgate report --run <uuid>` | print a stored decision as the PR comment (`--format json`) | $0 |
|
|
89
|
+
| `agentgate aa-test --version main --trials N` | false-block rate: gate a version against itself N times | ~$2 per trial |
|
|
90
|
+
| `agentgate planted-test --manifest evals/planted/v1.yaml` | catch rate: gate pre-registered broken versions | ~$2 per variant |
|
|
91
|
+
| `agentgate judge-sample` / `judge-label` / `judge-validate` | judge vs human agreement on stored answers (the labels must come from a person) | $0 |
|
|
92
|
+
| `agentgate load --sessions 50 --concurrency 25` | session isolation under load, against a running app | ~$0.25 |
|
|
93
|
+
| `agentgate migrate` | create the gate's own tables in any Postgres | $0 |
|
|
94
|
+
|
|
95
|
+
Commands that spend estimate first, ask before spending (or take `--yes`), and stop at `budget.max_usd_per_gate_run` per version scored. A run that hits the cap is `budget_exceeded` and can't become a baseline.
|
|
96
|
+
|
|
97
|
+
**How the gate decides** ([ADR 0004](docs/decisions/0004-gate-statistics-and-isolation.md)). Each version runs in its own worker process from a git worktree. A metric **blocks** only if it is worse than its threshold in `agentgate.yaml` *and* its 95% CI excludes 0. If it crosses the threshold but the CI includes 0, it **warns** and the gate still passes. Quality metrics use −0.05; latency p95 and cost per success use +25% and +20%, and block only when both runs finished within 12 h of each other, because latency and token use drift between days. Against an older cached baseline they warn ([ADR 0010](docs/decisions/0010-time-dependent-metrics.md)); the action's `no-cache: true` re-scores the baseline in the same job (about twice the cost) when you want those rules to be able to block. An infra-error or judge-error rate above 5% on either side gives **no verdict**, so provider noise is neutral. Agent failures (step or token limit) above 5% on the candidate block. A critical security case that fails in any repeat blocks ([ADR 0005](docs/decisions/0005-security-suite.md)).
|
|
98
|
+
|
|
99
|
+
## Use AgentGate in your repo
|
|
100
|
+
|
|
101
|
+
| Verdict | Check | Meaning |
|
|
102
|
+
|---|---|---|
|
|
103
|
+
| ✅ PASSED | success | no metric regressed beyond its threshold |
|
|
104
|
+
| ⚠️ PASSED WITH WARNINGS | success (failure with `fail-on-warn: true`) | a metric crossed its threshold, but the 95% CI includes 0 |
|
|
105
|
+
| ❌ BLOCKED | failure | a significant regression, or a critical security case failed |
|
|
106
|
+
| ⏸️ NO VERDICT | neutral | provider noise, budget exceeded, or runs not comparable: not the PR's fault |
|
|
107
|
+
|
|
108
|
+
Copy this to `.github/workflows/agentgate.yml`:
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
name: AgentGate
|
|
112
|
+
on:
|
|
113
|
+
pull_request: # every PR; the action skips (green, $0) if the agent didn't change
|
|
114
|
+
permissions:
|
|
115
|
+
contents: read
|
|
116
|
+
pull-requests: write # the PR comment
|
|
117
|
+
checks: write # the AgentGate check
|
|
118
|
+
concurrency:
|
|
119
|
+
group: agentgate-${{ github.event.pull_request.number }}
|
|
120
|
+
cancel-in-progress: true # don't pay for superseded pushes
|
|
121
|
+
jobs:
|
|
122
|
+
gate:
|
|
123
|
+
runs-on: ubuntu-latest
|
|
124
|
+
timeout-minutes: 60
|
|
125
|
+
services:
|
|
126
|
+
db: # used when AGENTGATE_DATABASE_URL isn't set
|
|
127
|
+
image: pgvector/pgvector:pg16
|
|
128
|
+
env: { POSTGRES_USER: agentgate, POSTGRES_PASSWORD: agentgate, POSTGRES_DB: agentgate }
|
|
129
|
+
ports: ["5432:5432"]
|
|
130
|
+
options: --health-cmd "pg_isready -U agentgate" --health-interval 5s --health-retries 10
|
|
131
|
+
env:
|
|
132
|
+
DATABASE_URL: ${{ secrets.AGENTGATE_DATABASE_URL || 'postgresql://agentgate:agentgate@localhost:5432/agentgate' }}
|
|
133
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
134
|
+
LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }}
|
|
135
|
+
LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY }}
|
|
136
|
+
steps:
|
|
137
|
+
- uses: romit-23/AgentGate/action@main
|
|
138
|
+
with:
|
|
139
|
+
paths: agents/ # your agent's code and prompts (space-separated pathspecs)
|
|
140
|
+
config: agentgate.yaml # optional; also: repeats, fail-on-warn, no-cache, install-command, setup-command
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
In this repository the workflow uses the local copy (`uses: ./action`) after checking out the base.
|
|
144
|
+
|
|
145
|
+
**Secrets** (Settings → Secrets and variables → Actions):
|
|
146
|
+
|
|
147
|
+
| Name | Required | What for |
|
|
148
|
+
|---|---|---|
|
|
149
|
+
| `OPENAI_API_KEY`, `ANTHROPIC_API_KEY` or `GEMINI_API_KEY` | yes, one or more | your agent's model and the judge, on your account (see [Bring your own key](#bring-your-own-key)) |
|
|
150
|
+
| `AGENTGATE_DATABASE_URL` | no | a persistent Postgres (e.g. Neon; the gate's tables need no extension, this repo's agent needs pgvector). Baselines are cached there, so a push costs ~$2 instead of ~$4 |
|
|
151
|
+
| `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` | no | traces of every gate run |
|
|
152
|
+
|
|
153
|
+
**Things to know:**
|
|
154
|
+
- **The gate runs from the PR's base.** Its config, datasets, thresholds, scorers and even the action come from the base commit, so a PR can't loosen the gate that judges it. One exception: GitHub runs the *workflow file* from the PR itself, so protect `.github/` with CODEOWNERS and required reviews.
|
|
155
|
+
- **Forked PRs are skipped** (job summary + notice, no comment): GitHub gives them no secrets and a read-only token. `pull_request_target` would run untrusted code with your secrets.
|
|
156
|
+
- **The candidate's code runs in CI with your LLM key.** Only PRs from branches in your repository are gated.
|
|
157
|
+
- **Don't add a `paths:` filter to the workflow.** Once a fix commit reverts the agent change, that filter stops the workflow, and the PR's new head never gets a check. The action's `paths` input does the filtering instead.
|
|
158
|
+
- **Installing outside this repository:** make your project a uv project and add the gate as a dev dependency. The package `agentgate-ci` is built but not uploaded yet; until it is, use `uv add --dev git+https://github.com/romit-23/AgentGate`. `setup-command` defaults to `uv run agentgate migrate`, which creates the gate's tables; append your agent's own setup with `&&`. The Marketplace listing is prepared in [docs/marketplace.md](docs/marketplace.md).
|
|
159
|
+
- **Dependencies come from the base.** A PR that adds a package to the agent gets no verdict until the dependency is on the base branch.
|
|
160
|
+
- Make **AgentGate** a required check under Settings → Branches to enforce the gate. A neutral check doesn't block merging.
|
|
161
|
+
- Design: [ADR 0007](docs/decisions/0007-ci-integration.md).
|
|
162
|
+
|
|
163
|
+
### Bring your own key
|
|
164
|
+
|
|
165
|
+
AgentGate has no hosted scoring service and never asks for, stores or forwards an API key. The gate runs inside **your** CI job, and every model call goes from that job straight to your provider, on your account and your bill. Nobody else's key is involved, and nothing is sent to this project.
|
|
166
|
+
|
|
167
|
+
- **Where the key goes:** a GitHub Actions secret in your repository, passed to the job as an environment variable. Never in `agentgate.yaml`, a dataset, a commit or a PR comment. The settings hold it as a secret value, so it isn't logged.
|
|
168
|
+
- **Which keys work:** `OPENAI_API_KEY`, `ANTHROPIC_API_KEY` and `GEMINI_API_KEY`. Calls go through LiteLLM, and the provider prefix of each model in your config (`openai/…`, `anthropic/…`, `gemini/…`) picks the key. Without any of the three, the action skips with a notice and costs nothing.
|
|
169
|
+
- **What it pays for:** your agent's calls (your adapter decides which model and key it uses) and the judge's calls (`judge.model` in `agentgate.yaml`, which must be a different model from your agent's). Embeddings only if your agent uses them.
|
|
170
|
+
- **Using a provider other than OpenAI:** set `judge.model` to one of its models, keep `temperature: 0`, and pass that provider's key in the workflow's `env:` instead of `OPENAI_API_KEY`:
|
|
171
|
+
```yaml
|
|
172
|
+
env:
|
|
173
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
174
|
+
```
|
|
175
|
+
Changing the judge changes the judge fingerprint, so earlier cached baselines no longer match and the next gate run re-scores the base.
|
|
176
|
+
- **What it costs:** about *cases × repeats × (agent call + judge call)* per version scored, and twice that when the baseline isn't cached. This repository's setup (50 cases, K=3, `gpt-5.4-mini` agent, `gpt-5.2` judge at about $0.013 per case-run) costs about $2 per push with a cached baseline and about $4 without one. `budget.max_usd_per_gate_run` in `agentgate.yaml` is a hard cap per version: a run whose estimate exceeds it doesn't start, and a run that reaches it stops and can't become a baseline. Set a spending limit at your provider too.
|
|
177
|
+
- **Who can spend it:** only PRs from branches in your repository. Forked PRs get no secrets and are skipped. The candidate's code runs with your key, so gate only code you'd run anyway.
|
|
178
|
+
- **What our results do and don't cover:** the A/A, planted-regression and judge-agreement numbers above were measured with this repository's agent, dataset and `openai/gpt-5.2` judge. With your agent and another judge they're a starting point, not a guarantee. Before you trust blocks, run `agentgate aa-test` (identical versions, expected to pass) and `agentgate planted-test` (versions you broke on purpose, expected to block) on your own setup. Both run on your key.
|
|
179
|
+
|
|
180
|
+
## Dashboard and read API
|
|
181
|
+
|
|
182
|
+
The app serves server-rendered pages (Jinja2 + HTMX) over the stored results: version history with trends (`/`), and run detail with case results (`/runs/{run_id}`). The JSON read API is `/api/versions`, `/api/runs/{run_id}` and `/api/decisions/{decision_id}`. `POST /api/runs` starts a scored run behind `AGENTGATE_ADMIN_KEY`.
|
|
183
|
+
|
|
184
|
+
With `AGENTGATE_SERVE_AGENT=false` the app is dashboard-only: no agent, no LLM keys, no migrations, and a read-only database role. It has no field that accepts a visitor's key, and nothing a visitor does can start a paid model call. **It's live as a static snapshot at [agentgate-dashboard.pages.dev](https://agentgate-dashboard.pages.dev)** on Cloudflare Pages ($0): `make site` exports the same pages and read API as files ([docs/deploy.md](docs/deploy.md#free-alternative-a-static-snapshot)). The read API there is `api/versions.json`, `api/runs/<id>.json` and `api/decisions/<id>.json`. The snapshot was exported from the local database, so it has the A/A and planted-regression runs but not the CI runs of PR #7 and PR #21. The live server mode is prepared for one Fly.io machine reading the CI database (about $4/month) and isn't deployed: [docs/deploy.md](docs/deploy.md).
|
|
185
|
+
|
|
186
|
+
## The reference agent
|
|
187
|
+
|
|
188
|
+
A LangGraph agent with three tools (`search_kb` over pgvector + full-text search, `calculator`, `send_email`), a human approval step before any email, a code-level send guard ([ADR 0006](docs/decisions/0006-send-guard.md)), step, time and token budgets, a Postgres checkpointer and Langfuse tracing. It runs only in full mode, with `AGENTGATE_API_KEY` set in `.env` (sent as `X-API-Key`):
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
K=... # your AGENTGATE_API_KEY
|
|
192
|
+
# 1. A pricing calculation (search_kb + calculator)
|
|
193
|
+
curl -s localhost:8000/v1/chat -H "X-API-Key: $K" -H 'Content-Type: application/json' \
|
|
194
|
+
-d '{"session_id":"demo1","message":"What does the Pro plan cost per month for 12 seats on annual billing?"}' | jq '{status,answer,tools:[.trajectory.tool_calls[].name],cost:.trajectory.cost_usd}'
|
|
195
|
+
|
|
196
|
+
# 2. A question the KB cannot answer (should say it does not know)
|
|
197
|
+
curl -s localhost:8000/v1/chat -H "X-API-Key: $K" -H 'Content-Type: application/json' \
|
|
198
|
+
-d '{"session_id":"demo2","message":"Who won the 2018 World Cup?"}' | jq '{status,answer}'
|
|
199
|
+
|
|
200
|
+
# 3. An email: the run pauses for approval, nothing is sent yet
|
|
201
|
+
curl -s localhost:8000/v1/chat -H "X-API-Key: $K" -H 'Content-Type: application/json' \
|
|
202
|
+
-d '{"session_id":"demo3","message":"Email ana@example.com a one-line summary of the refund policy."}' | jq '{status,pending_action}'
|
|
203
|
+
# approve (or send {"approved":false} to reject)
|
|
204
|
+
curl -s localhost:8000/v1/chat/demo3/approve -H "X-API-Key: $K" -H 'Content-Type: application/json' \
|
|
205
|
+
-d '{"approved":true}' | jq '{status,answer}'
|
|
206
|
+
docker compose exec db psql -U agentgate -c 'SELECT session_id, to_addr, subject FROM mock_outbox'
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Every run returns a `trajectory` (answer, tool calls, retrieved doc ids, tokens, cost, latency, `trace_id`) and is stamped with a `version_id`: a hash of the prompt files, the agent's code, the model, and the tool and retrieval config. Runs stop with a typed error (`step_limit`, `timeout`, `token_budget`, `llm_error`), never a crash.
|
|
210
|
+
|
|
211
|
+
## Status and limits
|
|
212
|
+
|
|
213
|
+
**Deployed:** the dashboard, as a static snapshot on Cloudflare Pages ([agentgate-dashboard.pages.dev](https://agentgate-dashboard.pages.dev)).
|
|
214
|
+
|
|
215
|
+
**Not done yet:** the Fly.io deployment (the live, self-updating dashboard), the PyPI upload, the Marketplace listing (it needs a separate public repository) and the demo video. All are owner steps.
|
|
216
|
+
|
|
217
|
+
**No new runs here.** The OpenAI credits that paid for this repository's agent, judge and embeddings have run out. Until a key with credits is configured again, a PR to *this* repository that changes `agents/` can't be scored and should end without a verdict (neutral). That doesn't affect other repositories: the gate there runs on [their own key](#bring-your-own-key). Everything else works without an LLM: lint, type checks, unit and integration tests, `agentgate demo`, the dashboard, the read API, `compare` and `report`.
|
|
218
|
+
|
|
219
|
+
**What the numbers don't show:**
|
|
220
|
+
- **Small samples.** 10 A/A trials and 5 planted regressions meet the PRD's targets by count, but the 95% bounds are wide (26% and 55%). The planted regressions were written by the gate's author.
|
|
221
|
+
- **Latency and cost drift between days.** A baseline cached on a faster day blocked unchanged agents in 5 of 110 replayed pairs. Since ADR 0010 those rules only warn against a baseline more than 12 h old, so in CI a pure latency or cost regression usually warns rather than blocks. Quality metrics didn't drift.
|
|
222
|
+
- **Groundedness isn't validated** (κ 0.42). It only warns. The judge doesn't see calculator results.
|
|
223
|
+
- **The judge and the agent come from the same vendor.** Self-preference was never measured.
|
|
224
|
+
- **One agent, 50 synthetic golden cases, 25 security cases, K=3.** Category CIs are wide. K=3 can't separate a 1-in-3 failure rate from a 2-in-3 one.
|
|
225
|
+
- **Cost:** about $2 per gated push, against the PRD's $1.
|
|
226
|
+
- **Not a security claim.** AgentGate reports pass rates on a documented suite. It doesn't make the agent secure.
|
|
227
|
+
- Open items: [docs/TODO.md](docs/TODO.md).
|
|
228
|
+
|
|
229
|
+
## Documentation
|
|
230
|
+
|
|
231
|
+
- [docs/PRD.md](docs/PRD.md): requirements and success criteria
|
|
232
|
+
- [docs/benchmarks/RESULTS.md](docs/benchmarks/RESULTS.md): every measured result, with run reports and raw data
|
|
233
|
+
- [docs/decisions/](docs/decisions/): ADRs 0001–0010 (judge, model stack, gate statistics, security suite, send guard, CI integration, trust layer, groundedness, latency and cost against an old baseline)
|
|
234
|
+
- [docs/deploy.md](docs/deploy.md), [docs/marketplace.md](docs/marketplace.md): deployment and publishing steps
|
|
235
|
+
|
|
236
|
+
License: [MIT](LICENSE).
|
|
File without changes
|
|
File without changes
|