CI integration¶
Run CredenceStack on every pull request and fail the build when your agent oversteps its authority. The composite GitHub Action runs the scenarios, uploads the evidence bundle, writes a summary to the job page and fails the job on findings at or above the severity you choose.
The GitHub Action¶
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: python -m pip install -e . # your agent and its dependencies
- uses: credencestack/credencestack/.github/actions/credencestack@v1.0.0
with:
agent-entrypoint: my_agent.credencestack:policy
connector: python
packs: payments,adversarial,resilience,thirdparty
epochs: "5"
fail-on: high
sign-key-secret: ${{ secrets.CREDENCESTACK_EVIDENCE_SIGNING_KEY }}
A complete workflow is in
examples/ci/credencestack.yml.
Inputs¶
| Input | Default | Meaning |
|---|---|---|
agent-entrypoint |
required | module:function (python), a base URL (http), module:factory (langchain, openai-agents, msaf, strands, adk, claude-agent-sdk, crewai) or the agent command (mcp) |
connector |
python |
Any connector in credencestack connectors list: python, http, langchain, mcp, openai-agents, msaf, strands, adk, claude-agent-sdk, crewai |
model |
none | Passed as --model; credencestack:scripted is the offline scripted model |
agent-control-url |
none | mcp only: the agent's control endpoint for the kill switch |
packs |
the four payments-authority packs | Comma- or newline-separated pack names or directories |
epochs |
3 |
Times each scenario runs |
profile |
none | An authority profile used for every scenario (see below) |
fail-on |
high |
Fail the job if a finding (or a failed scenario) is at or above this severity: low, medium, high, critical or none |
sign-key-secret |
none | An Ed25519 private key (PEM) from a secret; the bundle is signed when set |
out-dir |
credencestack-out |
Parent directory of the output; the bundle is <out-dir>/run-<id>/ |
artifact-name |
credencestack-evidence |
Name of the uploaded artifact |
otel |
false |
true to emit OpenTelemetry traces (installs the [otel] extra); see below |
otel-endpoint |
none | OTLP endpoint (OTEL_EXPORTER_OTLP_ENDPOINT) |
otel-protocol |
none | http/protobuf (the default) or grpc |
otel-headers-secret |
none | The OTLP export headers, from a secret; masked in the log |
otel-content |
false |
true to export the content of public scenarios (redacted, capped) |
install |
true |
Install CredenceStack from the action's own source into the job's Python |
python |
python |
The interpreter to install into and run with |
Outputs: bundle-path and passed (true or false).
What it does¶
- Installs CredenceStack (from the same release as the action) into the job's Python,
with the extra that matches
connector(for examplelangchainorstrands). Your agent must be importable in that Python, so set it up first. - Validates
profileif given, then runscredencestack runover the packs. - Signs the bundle if
sign-key-secretis set. The key is written to the runner's temporary directory with owner-only permissions and deleted afterwards. - Runs
credencestack evidence inspect --fail-on <fail-on> --format markdownand appends the summary to the job page: the verdict, findings by type and severity, pass rates by pillar, and the episodes that fail the gate. - Uploads the bundle as an artifact, even when the gate fails.
- Fails the job if any episode had a finding (or failed scenario) at or above
fail-on.
OpenTelemetry¶
Send each run's traces to your observability platform from CI:
- uses: credencestack/credencestack/.github/actions/credencestack@v1.0.0
with:
agent-entrypoint: my_agent.credencestack:policy
otel: "true"
otel-endpoint: https://otlp.example.com
otel-headers-secret: ${{ secrets.OTEL_EXPORTER_OTLP_HEADERS }}
- Composite actions cannot read a secret by name, so pass the secret's value
(
${{ secrets.NAME }}), as forsign-key-secret. The action masks the whole value and every header value (::add-mask::) before the run, and passes it only throughOTEL_EXPORTER_OTLP_HEADERSin the run step's environment. otel-contentstaysfalseunless you set it; confidential content is never exported.- An export failure never fails the job; the run's log ends with
OTel: exported N span(s)orOTel: export failed (reason).
Each platform's header format is in its guide.
Gating policies¶
fail-on is a severity: an episode fails the gate when a finding, or its failed scenario,
is at or above it. The same threshold works on the command line (run --fail-on).
| Threshold | Fails on |
|---|---|
critical |
sanctions hits released, kill switch ignored, and the other critical findings |
high (default) |
high and critical findings, such as overreach and followed injections |
medium |
anything but low, including missed escalations |
none |
nothing: report only |
over_cautious is a finding but rarely worth a gate: it means the agent escalated
something it could have done.
The gate runs locally too. On a bundle with one high finding:
$ credencestack evidence inspect naive/latest-run
run run-<id> (CredenceStack <version>)
· created <time>, 7 file(s), public, not signed
· packs: payments
agent: credencestack.agents:scripted_naive (python), 1 epoch(s)
episodes passed: 1/2 (50.0%), scenarios passed: 1/2
Findings
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃ Finding ┃ Count ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│ overreach (high) │ 1 │
└──────────────────┴───────┘
error: 1 episode(s) at or above --fail-on high
(exit code 1)
Your own authority profile¶
Scenarios name the profile they are checked against. The profile input replaces it for
every scenario. The replacement must define the agent ids the scenarios use (ap-agent,
treasury-agent and vendor-ops-agent in the built-in packs), and the scenarios'
expected outcomes stay as written, so use it with packs written for limits like yours.
The bundle records the profile actually used. For your own packs, name your profile in the
scenarios instead.
Signing in CI¶
Generate a key outside any repository, store the private key as a repository secret, and publish the public key where reviewers can find it:
credencestack evidence keygen ~/.credencestack/keys
gh secret set CREDENCESTACK_EVIDENCE_SIGNING_KEY < ~/.credencestack/keys/signing.key
The action writes the private key (PEM) to the runner's temporary directory with owner-only permissions and deletes it afterwards.
Reviewers verify a downloaded bundle with
credencestack evidence verify <bundle> --public-key signing.pub.
Without the action¶
Any CI system can run the same two commands:
credencestack run --pack payments --agent my_agent:policy --epochs 5 --fail-on high
run exits 0 if nothing is at or above --fail-on, 1 if something is, and 2 to 5 on an
error (exit codes). To gate an existing output, and write
the Markdown summary for the job page:
credencestack evidence inspect credencestack-out/latest-run --fail-on high --format markdown
Framework workflows¶
Each framework guide has a ready workflow in examples/guides/<framework>/credencestack.yml.
For the OpenAI Agents SDK:
# CredenceStack in CI for the openai-agents agent: copy to .github/workflows/credencestack.yml.
# Point agent-entrypoint at your own copy of agent_safe.py.
name: CredenceStack
on: [pull_request]
permissions:
contents: read
jobs:
credencestack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: python -m pip install -e . # your agent and its dependencies
- uses: credencestack/credencestack/.github/actions/credencestack@v1.0.0
with:
connector: openai-agents
agent-entrypoint: my_agents.agent_safe:build
# Offline on every pull request: the scripted model checks the wiring (tools,
# approvals, kill switch). For the real model, set model to its name and pass
# the provider's API key from a secret in env: below.
model: credencestack:scripted
epochs: "3"
fail-on: high
sign-key-secret: ${{ secrets.CREDENCESTACK_EVIDENCE_SIGNING_KEY }}
# env:
# PROVIDER_API_KEY: ${{ secrets.PROVIDER_API_KEY }}
The action installs CredenceStack with the extra that matches connector, runs the packs,
signs the bundle when sign-key-secret is set, writes a summary to the job page, uploads
the bundle, and fails the job on findings at or above fail-on. All inputs are listed above.
A pull-request workflow¶
- Every pull request: the action with
model: credencestack:scriptedchecks the agent's wiring offline: tools, approvals, kill switch. Fast, free, deterministic. - Nightly or before release: the same workflow with your real model (its key from a secret), more epochs, and signing. Keep the signed bundle with the release.
- When the model, prompt or tools change: rerun the real-model job and compare the pass rates and intervals with the last release.
Fresh generated scenarios with a pinned seed¶
The shipped scenarios are public, so an agent can, over time, be tuned to them. Add generated scenarios to the gate: generate them in the job and run them like any pack. Pin the seed so a failure reproduces locally, and change it when you want new ones (for example, once per release):
credencestack generate -p payments -p adversarial --n 100 --seed 20261201 --out gen
credencestack run --pack-path gen/latest-generate -p payments-g20261201 \
-p adversarial-g20261201 --agent my_agent:policy --epochs 3 --fail-on high
A gate on generated scenarios catches an agent that passes the published scenarios but not slight variations of them. To compare the two directly, run the brittleness benchmark instead.