Skip to main content

Testimony Records from Pydantic AI

Packaged and tested; the first publish to PyPI is pending, so for now it is one file. Copy testimony_pydantic_ai.py and testimony_emit.py next to your agent. There is nothing else to install and nothing here depends on OMEM.

from pydantic_ai import Agent
from testimony_pydantic_ai import Recorder

def decide(req):
    # req.action, req.arguments, req.tool_call_id, req.risk_class.
    # Your approval UI, queue or ticket goes here. The identity has to come
    # from your authentication layer; this adapter has none to find.
    if req.action == "close_account":
        return req.refuse("a balance is outstanding")
    return req.approve(approver={"id": "r.okonkwo@example.com", "kind": "human"},
                       identity_source="auth-session")

rec = Recorder(
    agent={"id": "support-agent", "kind": "agent"},
    risk={"issue_refund": "high", "close_account": "high",
          "search_docs": "low"},
    decide=decide,
)
result = rec.run_sync(agent, "Refund order 8842")
rec.write("record.jsonl")
$ testimony-validate record.jsonl
Conformance: TR-4

Why this one exists, in a line of their own type signature

Pydantic AI already has the pause. DeferredToolRequests carries the calls waiting for a person and DeferredToolResults carries the answers. Those answers are typed:

approvals: dict[str, bool | DeferredToolApprovalResult]

A bare True approves. That is not a criticism of the design, which is cleaner than most: ToolApproved carries override_args, so the framework already understands that what was approved and what the model proposed can differ. But a boolean has nowhere to put a person, and an assessment of eight agent systems found that is where almost all of them stop. Of the six that take or gate actions, one could name the person who approved one. Four could not, because approval is stored as a boolean and the identity was never written down.

So this adapter never writes one. It requires an approver and a source for that approver's identity, or it refuses to record an approval at all.

What the approver allowed, not what the model asked for

pydantic-ai#6968 is the framework side of a defect that is also open in Haystack and named from the other direction in AutoGen: an approver shown one set of arguments while another set executes has not approved the action that happened.

req.approve(..., arguments=...) becomes the framework's override_args, and the record then carries both: arguments is what the person allowed and proposed_arguments is what the model asked for. A reader can see the difference instead of inferring it from which version was deployed.

What it will not do

It will not fail open. If your decide returns anything that is not a decision it issued, the run raises and no tool executes. openai-agents-python#4845 is that mistake in a shipped SDK: a callable predicate returned None from an unhandled branch, None read as "no approval needed", and the gate opened.

It will not classify risk from anything the model produced. Risk comes from a table you own, and a tool missing from it raises rather than defaulting.

It will not invent an approver, let the acting agent approve its own action, or accept an identity source the proposing model could have written.

It will not answer a deferred external call. Those are results only the caller can supply, and inventing one would put a fact in the record that never happened.

A refusal becomes a ToolDenied carrying your reason, so the model is told why rather than told nothing, and it is recorded with the same standing as a permission.

Tests

tests/tests_pydantic_ai_testimony.py, 35 checks, against a real Agent with the framework's own FunctionModel. No network and no API key: only the model is scripted. The tools, requires_approval, the pause and the resume are the real ones. CI installs the library and fails if the suite skips.

MIT. Copyright 2026 Garnet Taurus Ltd. The specification: https://datatracker.ietf.org/doc/draft-clifford-testimony-record/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

testimony_pydantic_ai-0.1.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

testimony_pydantic_ai-0.1.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file testimony_pydantic_ai-0.1.0.tar.gz.

File metadata

  • Download URL: testimony_pydantic_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for testimony_pydantic_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3fa5cf40aee6357cd9968034cfd4bcaac3c61f4ccca37d3fb65cc0d724039582
MD5 1f14d0194e5fc23f9d938f7658e30ee8
BLAKE2b-256 3d3d76003304e53bde01e64b59f2f525a2c0801f3016126591f5e5d2ff56ef1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for testimony_pydantic_ai-0.1.0.tar.gz:

Publisher: release-adapter.yml on troybrandonc-bit/machine-testimony

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file testimony_pydantic_ai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for testimony_pydantic_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9115ef1a1a4169eca09ad3eb441cdb3a3ac727a3ea85d9fbb48fa8824de84d20
MD5 1bacf6e34d004c9481f167bf4b749d8b
BLAKE2b-256 2271022f3492ef0d5ad3f31413c05a913ed9a607c20fd47adb3f2ef062e323f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for testimony_pydantic_ai-0.1.0-py3-none-any.whl:

Publisher: release-adapter.yml on troybrandonc-bit/machine-testimony

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page