CI/CD templates
Ship an agent properly: automated build on tag, test on PR, deploy to the
tenant's agent registry, run eval scenarios against the deployed version.
Templates for the two most common CI systems — GitHub Actions and Azure
DevOps Pipelines — are in the SDK repo at
sdk/ci-templates/.
Pattern#
Code
Developer pushes tag `v0.2.0`
│
▼
┌─────────────────────────────┐
│ Build + test │ pytest / dotnet test / vitest
│ │ manifest validate
└─────────────────────────────┘
│
▼
┌─────────────────────────────┐
│ Docker build + push │ → ghcr.io/<org>/<agent>:v0.2.0
└─────────────────────────────┘
│
▼
┌─────────────────────────────┐
│ konstera agent deploy │ POST /api/agents + upload manifest
│ │ — platform validates on upload
└─────────────────────────────┘
│
▼
┌─────────────────────────────┐
│ konstera eval run │ Runs manifest's eval.scenarios[]
│ --fail-on 0.9 │ CI fails if pass rate < 90%
└─────────────────────────────┘
GitHub Actions — deploy on tag#
.github/workflows/deploy.yml:
YAML
name: Deploy agent
on:
push:
tags: ["v*.*.*"]
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write # for OIDC login to Konstera (if using trusted publishers)
steps:
- uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install SDK + test
run: |
pip install -e ".[dev]"
pytest tests/
- name: Validate manifest matches tag version
run: |
MANIFEST_VERSION=$(jq -r .version manifest.json)
if [ "$MANIFEST_VERSION" != "${{ steps.version.outputs.version }}" ]; then
echo "::error::manifest.json version ($MANIFEST_VERSION) doesn't match tag (v${{ steps.version.outputs.version }})"
exit 1
fi
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build + push image
run: |
IMAGE="ghcr.io/${{ github.repository_owner }}/my-agent"
docker build -t "$IMAGE:${{ steps.version.outputs.version }}" .
docker push "$IMAGE:${{ steps.version.outputs.version }}"
- name: Install Konstera CLI
run: |
curl -sSL https://konstera.ai/install.sh | sh
konstera login --token "${{ secrets.KONSTERA_API_TOKEN }}" \
--api-url "${{ secrets.KONSTERA_API_URL }}"
- name: Deploy
run: |
konstera agent deploy \
--manifest manifest.json \
--image ghcr.io/${{ github.repository_owner }}/my-agent:${{ steps.version.outputs.version }}
- name: Run eval scenarios
run: |
konstera eval run io.konstera.my-agent \
--version ${{ steps.version.outputs.version }} \
--fail-on 0.9
GitHub Actions — eval on PR#
.github/workflows/eval-on-pr.yml:
YAML
name: Eval on PR
on:
pull_request:
branches: [main]
jobs:
eval:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Build image (not pushed)
run: docker build -t pr-${{ github.event.pull_request.number }} .
- name: Install Konstera CLI
run: curl -sSL https://konstera.ai/install.sh | sh
- name: Upload as draft version
run: |
konstera agent upload \
--manifest manifest.json \
--image pr-${{ github.event.pull_request.number }} \
--draft
- name: Run eval + comment results
id: eval
run: |
konstera eval run io.konstera.my-agent \
--version pr-${{ github.event.pull_request.number }} \
--output eval-results.json
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const results = JSON.parse(fs.readFileSync('eval-results.json'));
const body = `## Eval results\n\nPass rate: **${results.pass_rate}** (${results.passed}/${results.total})\n\n` +
(results.failures || []).map(f => `- ❌ ${f.scenario_id}: ${f.reason}`).join('\n');
github.rest.issues.createComment({
owner: context.repo.owner, repo: context.repo.repo,
issue_number: context.issue.number, body
});
Azure DevOps Pipelines — deploy on tag#
azure-pipelines.yml:
YAML
trigger:
tags:
include: ["v*"]
pool:
vmImage: ubuntu-latest
variables:
- group: konstera-prod # contains KONSTERA_API_TOKEN, KONSTERA_API_URL
steps:
- task: UsePythonVersion@0
inputs: { versionSpec: "3.13" }
- script: |
pip install -e ".[dev]"
pytest tests/
displayName: Build + test
- script: |
VERSION=$(echo $(Build.SourceBranch) | sed 's|refs/tags/v||')
echo "##vso[task.setvariable variable=version]$VERSION"
displayName: Extract version
- task: Docker@2
displayName: Build + push image
inputs:
containerRegistry: $(DOCKER_REGISTRY_SERVICE_CONNECTION)
repository: $(ORG)/my-agent
command: buildAndPush
Dockerfile: Dockerfile
tags: $(version)
- script: |
curl -sSL https://konstera.ai/install.sh | sh
konstera login --token "$KONSTERA_API_TOKEN" --api-url "$KONSTERA_API_URL"
konstera agent deploy --manifest manifest.json --image <registry>/<org>/my-agent:$(version)
konstera eval run io.konstera.my-agent --version $(version) --fail-on 0.9
env:
KONSTERA_API_TOKEN: $(KONSTERA_API_TOKEN)
KONSTERA_API_URL: $(KONSTERA_API_URL)
displayName: Deploy + eval
Secret management#
GitHub Actions#
KONSTERA_API_TOKEN— repo secret or (preferred) OIDC trusted publisher config matching the workflow filenameKONSTERA_API_URL— repo variable (https://api.konstera.aior self-hosted URL)
Azure DevOps#
- Variable group
konstera-prodwithKONSTERA_API_TOKENmarked secret - Service connection to the Docker registry
Rollback pattern#
If an eval fails post-deploy OR a production incident surfaces, rollback is one command:
Terminal
konstera agent rollback io.konstera.my-agent --to-version 0.1.9
The platform:
- Marks
v0.2.0asdeprecated(not deleted — audit history retained) - Points active instances at
v0.1.9's image - Drains in-flight invocations of
v0.2.0and resumes them onv0.1.9
Pitfalls#
- Deploy before image push completes: the platform validates the image
is reachable; if your CI deploys before the image push finishes, you'll
get
[VAL-003]. Order matters. - Eval runs against a draft that was already garbage-collected: draft uploads expire after 7 days. If your eval job is slow, convert to a real version before timeout.
- Secret leaks via
set -xorecho $TOKEN: standard CI hygiene — CI logs are visible to repo collaborators. Don't echo secrets.
See also#
- RELEASING.md on SDK repo — SDK publish pipelines (pattern basis for agent pipelines)
- Eval-driven recipe — the eval surface this CI uses
- Debugging — what to do when CI fails on eval