DEV Community

Cover image for One Decorator to Audit Every AI Agent Call
João André Gomes Marques
João André Gomes Marques

Posted on Edited on Originally published at dev.to

One Decorator to Audit Every AI Agent Call

Your AI agent makes hundreds of API calls a day. Can you prove what it did last Tuesday at 3pm?

asqav signs every function call with quantum-safe cryptography. One decorator.

Setup

pip install asqav
Enter fullscreen mode Exit fullscreen mode

Sign any function

import asqav

asqav.init(api_key="sk_...")

@asqav.sign
def call_model(prompt: str):
    return openai.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": prompt}]
    )

result = call_model("Summarize this document")
# Function runs normally. A signed audit record is created automatically.
Enter fullscreen mode Exit fullscreen mode

The decorator detects async functions too. No changes needed.

@asqav.sign
async def async_call(prompt: str):
    return await client.chat.completions.create(...)
Enter fullscreen mode Exit fullscreen mode

Custom action types

Default action type is function:call. Override it:

@asqav.sign(action_type="deploy:production")
def deploy(version: str):
    ...
Enter fullscreen mode Exit fullscreen mode

Group signs with sessions

with asqav.session() as s:
    s.sign("step:fetch", {"source": "api"})
    s.sign("step:process", {"records": 150})
    s.sign("step:store", {"table": "results"})
# All three signs grouped under one session ID
Enter fullscreen mode Exit fullscreen mode

Every sign gets an ML-DSA-65 signature and an RFC 3161 timestamp. Quantum-safe, independently verifiable, tamper-proof.

SDK docs | GitHub

Top comments (0)