View as Markdown

Mandate · Guide

Record what agents did

Available on Pro, Growth and Enterprise

Use this when you need a record of what an agent team did that its agents can't change afterwards: for a dispute, an audit or your own review. Each agent sends its spans to the run's record. Provenance chains every batch to the one before it on receipt, adds its own decisions (each authorize, verify and delegate in the run, and each halt and resume), and writes the chain's head into the decision ledger.

The record proves what was sent and that it wasn't changed afterwards. It can't prove an agent reported everything it did.

Before you begin: start a run and join the team to it (see halt a run). Register each agent's signing key to sign its batches (sign your agent's requests).

1. Send spans

POST /v1/mandate/runs/{id}/record takes OTLP/HTTP JSON, so an OpenTelemetry collector can point at it, or batches in the record's own form:

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5

curl -s $PROVENANCE_API/v1/mandate/runs \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "name": "Restock printer paper" }' | tee run.json
export RUN_ID=$(jq -r .id run.json)

curl -s $PROVENANCE_API/v1/mandate/runs/$RUN_ID/record \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "spans": [ { "name": "search_prices", "kind": "client", "start_time": "2027-01-01T00:00:00.000Z",
        "end_time": "2027-01-01T00:00:01.000Z", "status": { "code": "ok" }, "trace_id": null, "span_id": null,
        "parent_span_id": null, "attributes": { "tool.name": "search_prices" } } ] }'
{
  "object": "run_record_batch",
  "seq": 1,
  "signed_by": null
}

A batch holds at most 1,000 spans and 1 MB, and a span at most 64 attributes of 4 KB each. Spans are sealed at rest.

To send from a collector, add an otlphttp exporter with the run in the path:

exporters:
  otlphttp/provenance:
    traces_endpoint: https://api.provenanceauth.com/v1/mandate/runs/${env:RUN_ID}/record
    encoding: json
    headers:
      Authorization: Bearer ${env:PROVENANCE_KEY}
processors:
  batch:
    send_batch_max_size: 1000
service:
  pipelines:
    traces:
      processors: [batch]
      exporters: [otlphttp/provenance]

2. Sign each batch with the agent's key

A signed batch carries agent_id and signature: { kid, sig }: the agent's Ed25519 signature over the canonical JSON of { run_id, spans }. Provenance checks it against the agent's registered key and records signed_by. One agent can't submit spans as another: a key that isn't the agent's is record_signature_invalid.

RecordExporter in @provenanceauth/agent-adapters does this for you. It has the shape of OpenTelemetry's SpanExporter, so it plugs into a span processor without another dependency:

import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
import { RecordExporter, traceparentFor } from "@provenanceauth/agent-adapters";

const exporter = new RecordExporter({
  apiBase: process.env.PROVENANCE_API!,
  apiKey: process.env.PROVENANCE_KEY!,
  runId,
  signer: { agentId: "agt_01M69…", kid, privateJwk },
});
provider.addSpanProcessor(new BatchSpanProcessor(exporter));

Send traceparent: traceparentFor(span) on authorize, and Provenance's own entry for that decision links to the span that asked.

3. Read and verify the record

GET /v1/mandate/runs/{id}/record/verify recomputes the chain, each signature and the checkpoints in the decision ledger:

curl -s $PROVENANCE_API/v1/mandate/runs/$RUN_ID/record/verify \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{
  "object": "run_record_verification",
  "valid": true,
  "batches": 1
}

When a batch changed after it was received, valid is false and first_break names it. In the console, each run's page shows the record's timeline (signed or unsigned per batch) and the result under its Record tab, beside Team (the agents as a tree, each opening its grant's chain) and Bookings.

4. Check an export offline

GET /v1/mandate/runs/{id}/record with ?format=jsonl exports one batch per line with its spans, hashes and signature. Anyone holding it, and the agents' public keys, can check it without Provenance:

import { parseRunRecordJsonl, verifyRunRecord } from "@provenance/core";

const result = verifyRunRecord(parseRunRecordJsonl(jsonl), { keys: { [kid]: publicJwk } });
// { valid: true, batches: 12, signed: 9 }

A dispute between agents uses the same record: when a deal's buyer worked in a run, or a seller's spans carry provenance.deal_id, the dispute's findings say whether each side's record holds (when a deal goes wrong).

5. Know what it costs and how long it's kept

The record is on Pro and up, and storing it is included. Reading and verifying are free. Batches are kept 30 days on Pro and Growth and 365 days on Enterprise; retention is the only way a batch is removed.

Errors you might see

CodeWhat to do
record_signature_invalidSign with the agent's own registered key, over { run_id, spans }, or send the batch unsigned.
record_batch_too_largeSend at most 1,000 spans and 1 MB a batch.
run_record_not_configuredThis deployment keeps no run records yet.
plan_requiredThe record is on Pro and up.

See also