Skip to content

Agents and trusted workloads

An agent is a workspace member that isn’t a person. It has its own credentials, it appears under its own name in logs and spend, and the workspace policy’s proxy settings apply to it. An agent lives in exactly one workspace.

Managing agents needs the workspace admin role.

On the workspace’s Members page, switch the add form to Agent and enter a name. Or:

Terminal window
avant org agents create review-bot --workspace <workspace-id>

Then give it a credential: a workspace key, or trust for its workload.

Open the workspace’s Connect page and choose Generate key next to the agent. The key is shown once. Store it in your secret manager and set it on the agent:

Terminal window
ANTHROPIC_BASE_URL=https://proxy.avant.codes
ANTHROPIC_API_KEY=ws_<workspaceId>_<secret>

Anyone with the key can act as the agent until you regenerate it. Regenerating invalidates the old key right away.

If the agent runs somewhere that issues OIDC tokens, Avant can trust that identity directly. The workload trades its own token for an Avant token that lasts an hour, so there’s no long-lived secret to store or leak.

A trusted workload is an issuer, an exact subject, an audience and, optionally, extra claims that must match. Avant reads the issuer’s keys through OIDC discovery.

Workload Issuer Subject
GitHub Actions https://token.actions.githubusercontent.com repo:<owner>/<repo>:environment:<name>, …:ref:refs/heads/<branch> or …:ref:refs/tags/<tag>
Google Cloud service account https://accounts.google.com The service account’s numeric unique ID, not its email
Kubernetes service account Your cluster’s issuer URL system:serviceaccount:<namespace>:<name>
Any OIDC issuer Its https:// URL The exact sub, plus any claims you list

The audience defaults to urn:avant:workspace:<workspace-id>. You can change it per workload.

On the agent’s page, under Authentication, pick the workload, fill in its fields and choose Trust this workload. The page then shows a snippet for that workload type. From the CLI:

Terminal window
avant org agents workloads add review-bot --github acme/api --environment production
avant org agents workloads add review-bot --github acme/api --branch main
avant org agents workloads add review-bot \
--issuer https://gitlab.example.com --subject project_path:acme/api:ref_type:branch:ref:main \
--claim namespace_path=acme

The workload requests an OIDC token from its issuer with the trusted audience, then exchanges it (RFC 8693 token exchange):

Terminal window
curl -sSf https://proxy.avant.codes/token \
-d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
-d subject_token_type=urn:ietf:params:oauth:token-type:jwt \
--data-urlencode subject_token="$OIDC" \
-d audience=<workspace-id>

The response holds access_token, token_type: "Bearer" and expires_in. Use access_token as the API key, the same way as a workspace key. Get a new one before it expires.

The subject token must not live longer than 24 hours. A refused exchange returns an OAuth error (invalid_grant, invalid_request, invalid_target) with an error_description.

permissions:
id-token: write
steps:
- name: Get an Avant token
run: |
OIDC=$(curl -sSf -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=urn%3Aavant%3Aworkspace%3A<workspace-id>" | jq -r .value)
AVANT_TOKEN=$(curl -sSf https://proxy.avant.codes/token \
-d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
-d subject_token_type=urn:ietf:params:oauth:token-type:jwt \
--data-urlencode subject_token="$OIDC" \
-d audience=<workspace-id> | jq -r .access_token)
echo "::add-mask::$AVANT_TOKEN"
echo "AVANT_TOKEN=$AVANT_TOKEN" >> "$GITHUB_ENV"

Restrict the trusted workload to an environment, branch or tag. Trusting a whole repository would let any workflow run in it act as the agent.

On Cloud Run, GCE or GKE with Workload Identity, ask the metadata server for an ID token:

Terminal window
OIDC=$(curl -sSf -H "Metadata-Flavor: Google" \
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience=urn%3Aavant%3Aworkspace%3A<workspace-id>&format=full")

Then exchange it as above.

Mount a projected service account token with the audience, then exchange the file’s contents:

volumes:
- name: avant-token
projected:
sources:
- serviceAccountToken:
audience: urn:avant:workspace:<workspace-id>
expirationSeconds: 3600
path: token

The cluster’s issuer must be reachable over HTTPS with OIDC discovery. Managed clusters (GKE, EKS, AKS) publish one.

Each agent has its own auth mode:

Mode Accepts
key Only the workspace key
key_and_token Both. Use this while you move over.
token Only exchanged tokens. Deletes the key.
Terminal window
avant org agents auth-mode review-bot token

An exchange for an agent in key mode is refused.

Terminal window
avant org agents workloads list review-bot
avant org agents workloads remove review-bot <id>
avant org agents move review-bot <other-workspace-id>

Removing a trusted workload stops its tokens from working on their next request. Moving an agent revokes its key and trusted workloads in the old workspace, so set its authentication up again in the new one.