Skip to content

Repository files navigation

Agent Evidence Proxy (AEP)

DOI

A proxy that captures each non-streaming chat-completion call in a hash-chained JSONL evidence ledger and releases the response to the caller only after the entry has been written and fsync'd.

The product is Agent Evidence Proxy (AEP). The underlying ledger format is specified in SPEC.md.

What it does and does not do

  • Records each call to /v1/chat/completions, /v1/messages and /v1beta/models/* that goes through it under an explicit capture profile. metadata-only retains event state, hashes and normalized provider counts without response, reasoning or action payloads; redacted removes explicitly configured reason, think, act or usage_raw classes; pointer/hash stores the raw response in a separate protected-payload store and records only a digest/reference in the ledger; raw-opt-in preserves those payloads in the ledger. The request is not stored — only a SHA-256 hash of its canonicalized system, messages and tools (in) plus the model name.
  • If the ledger write fails, the response is withheld and the client gets a 500.
  • Streaming is refused: a request with "stream": true (or Gemini :streamGenerateContent) gets a 400, and an upstream text/event-stream answer gets a 502 with nothing forwarded, because a stream cannot be captured before it is released.
  • Entries are hash-chained, which detects accidental or partial edits. It does not stop an actor who can rewrite the whole file, and the ledger is only as independent as the account and host the proxy runs under. The agent being observed must not be able to write to the capture location.
  • Traffic that bypasses the proxy and tool executions on the client side are not captured.

Quickstart

1. Download the binary from the latest CI build:

  • agent-evidence-proxy-windows — Windows x86_64
  • agent-evidence-proxy-linux — Linux x86_64

2. Run the proxy:

AEP_ROOT=/path/to/evidence \
AEP_CAPTURE_PROFILE=metadata-only \
AEP_PRIVACY_POLICY_REVISION=privacy-v1 \
AEP_RETENTION_CLASS=30-days \
AEP_CAPTURE_SCOPE=project/example \
./agent-evidence-proxy

The proxy listens on 127.0.0.1:8474 by default (AEP_LISTEN to override). Ledger files are written to <AEP_ROOT>/<sid>.jsonl. The location, upstream URLs and capture policy are read from the proxy's own environment at start; requests cannot change them. AEP_ROOT and all four AEP_* policy variables below are required; the proxy does not start when they are missing or the profile is unsupported.

When used with ai-steward, start the proxy with AEP_ROOT set to the bound ACM scope's evidence/ folder.

The session id comes from the optional x-aep-session request header and groups the calls of one run into one ledger file. It must match ^[A-Za-z0-9_-]{1,64}$, otherwise the request is rejected with 400. Without the header a fresh ULID is used.

3. Point your LLM client at the proxy:

# OpenAI / Grok
client = OpenAI(base_url="http://127.0.0.1:8474/v1", api_key="...")

# Anthropic
client = Anthropic(base_url="http://127.0.0.1:8474", api_key="...")

4. Each call appends an entry to the session file:

// <AEP_ROOT>/<sid>.jsonl — one line per call
{
  "v": 1, "seq": 0, "sid": "01KRNDE2C2DBE9AWNYPXKGSD7M",
  "ts": "2026-05-15T08:53:17.241Z", "model": "claude-haiku-4-5",
  "in":   "sha256:faf7bc...",   // SHA-256 of the canonicalized {system, messages, tools}
  "prev": "sha256:000000...",   // genesis; subsequent turns chain here
  "think": null,                // extended reasoning tokens (if any)
  "reason": "",                 // model text output
  "act": {                      // tool call (if any)
    "name": "record_result",
    "input": { "status": "aep-act-verified" }
  },
  "usage": {                    // exact provider-reported counts; null if absent
    "input_tokens": 184,
    "output_tokens": 37,
    "raw": [{ "input_tokens": 184, "output_tokens": 37 }]
  },
  "capture": {
    "profile": "raw-opt-in",
    "policy_revision": "privacy-v1",
    "retention_class": "30-days",
    "scope": "project/example",
    "observed": {"reason": true, "think": false, "act": true, "usage": true},
    "omitted": []
  },
  "transparency": { "think": false, "act": true }
}

usage.raw is preserved under raw-opt-in; metadata-only keeps only normalized provider counts plus content digests and removes usage.raw. The normalized input_tokens and output_tokens fields use provider-reported values only; the proxy never estimates missing counts.

Every entry's capture.payload_bytes reports observed, retained and omitted payload bytes, so an operator can verify how the selected profile changes ledger payload cost without treating wall-clock timing as a portable conformance check.


Supported providers

Provider Endpoint Notes
OpenAI / Grok /v1/chat/completions UPSTREAM_BASE_URL to override (default: https://api.openai.com).
Anthropic /v1/messages ANTHROPIC_BASE_URL to override (default: https://api.anthropic.com).
Gemini /v1beta/models/* GEMINI_BASE_URL to override (default: https://generativelanguage.googleapis.com).

All request headers (including Authorization / x-api-key) are forwarded to the upstream except x-aep-*. No credentials are read or stored.


Environment variables

Read once at proxy start.

Variable Default Description
AEP_ROOT required; no default Folder the ledger files are written to (the ACM scope's evidence/ folder). Created if absent. The proxy does not start without it.
AEP_CAPTURE_PROFILE required; no default metadata-only, redacted, pointer/hash or explicit raw-opt-in. Missing or unsupported profiles stop startup.
AEP_PRIVACY_POLICY_REVISION required; no default Identifies the policy governing this capture session.
AEP_RETENTION_CLASS required; no default Retention classification carried by every accepted evidence entry.
AEP_CAPTURE_SCOPE required; no default Declared interaction or memory scope carried by every accepted evidence entry.
AEP_REDACT_FIELDS required only for redacted Comma-separated reason, think, act, and/or usage_raw. Unknown or empty policy stops startup.
AEP_PROTECTED_PAYLOAD_ROOT required only for pointer/hash Separate private store for raw upstream responses. It is not the ledger directory unless the operator deliberately configures it that way.
AEP_LISTEN 127.0.0.1:8474 Address to bind.
UPSTREAM_BASE_URL https://api.openai.com Upstream for /v1/chat/completions.
ANTHROPIC_BASE_URL https://api.anthropic.com Upstream for /v1/messages.
GEMINI_BASE_URL https://generativelanguage.googleapis.com Upstream for /v1beta/models/*.

How it works

Client → agent-evidence-proxy:8474 → LLM API
                ↓
         <AEP_ROOT>/<sid>.jsonl
         (fsync'd before response forwarded)

Each session is one JSONL file; each line is one call. Consecutive entries are linked by a SHA-256 hash chain over RFC 8785 canonicalized entries, so editing or reordering one entry in the middle breaks the chain.

The transparency object records whether think and act carried content.

See SPEC.md for the protocol definition (entry format, hash chain, failure semantics, conformance tiers).


Build from source

Requires Rust stable.

cd proxy-rust
cargo test    # 36 unit tests: handlers, ledger integrity, JCS canonicalization, ULID
cargo build --release

CI builds and uploads artifacts for Windows x86_64 and Linux x86_64 on every push to proxy-rust/.


Design principles

  • Fail-closed. If the ledger write fails, the response is withheld and the client sees an error.
  • Dumb pipe. The proxy does not interpret, filter, or modify content.
  • One base_url change on the client; no SDK wrapping.
  • Single binary. No configuration file.

Documentation

  • SPEC.md — protocol specification (entry format, hash chain, failure semantics)
  • docs/AAT-MAPPING.md — Field-by-field mapping to IETF Agent Audit Trail (draft-sharif-agent-audit-trail-00)

Cite this release

Use CITATION.cff for the current release metadata. The v0.1.0 Zenodo deposit is reserved as 10.5281/zenodo.24624043.


Author: Nils Wendelboe Holmager · Project context and connected work

Releases

Packages

Contributors

Languages