
The moment I realized nobody is watching the agents#
I was testing a LangChain agent that could read my Gmail, send messages, and manage my calendar. A standard productivity assistant. I followed the tutorial, set up the API keys, and everything worked.
Then I paused and asked myself: what can this agent actually do right now?
It could read every email in my inbox. It could send emails to anyone, from my address, with any content. It could delete emails. It could forward sensitive threads to an external API endpoint. It could archive years of history. All of this was within the scope I had granted when I set up the Gmail API.
I had not approved any of that. I had approved “set up Gmail access for the agent.” The rest was implied.
So I went looking for a way to scope this down. LangChain has no permission model. There’s no concept of “this tool can read but not write,” or “this tool can send emails but only to specific recipients,” or “ask me before doing anything irreversible.”
LlamaIndex is the same. OpenAI function calling is the same. Anthropic tool use is the same. Every major agent framework treats tool access as binary: the agent either has a tool or it doesn’t.
There’s no middle ground. No conditional access. No approval flow. No audit trail. And that’s when it clicked. This wasn’t just a missing feature. It was a systemic gap. One that’s going to get worse as agents become more autonomous. So I built a fix.
What I built#


Vettra is a real-time authorization layer for AI agents. It sits between the agent and the outside world, intercepting every action before it executes.
The core idea is simple. Instead of giving an agent unconditional access to a tool, you give it conditional access. The agent can request any action, but Vettra classifies the risk, enforces policy, and decides what happens next before anything runs.
In practice, it looks like this.
You have a LangChain agent with a gmail_send_messagetool. Normally, when the agent calls that function, it just runs.
With Vettra, you add a single decorator:
@protect(framework="langchain") async def gmail_send_message(to, subject, body): return send_email(to, subject, body)

Now when the agent calls gmail_send_message, Vettra intercepts the call. It parses the function name and parameters into a structured Action Bundle, then scores the risk. Sending an email is a write action, irreversible, and tied to a user account, which places it at a score of 45, a MEDIUM-risk action. It then checks the action against a signed policy bundle and pushes an approval request to a real-time dashboard where a human can see exactly what the agent wants to do and approve or deny it with a single click.
If the human approves, Vettra calls Auth0 Token Vault to issue a scoped, time-limited credential for exactly the permission the action needs. The agent gets gmail.send, not gmail.modify. The token expires in five minutes, and the action executes. If the human denies, nothing happens. The agent gets a rejection and can decide what to do next. Every step in this process is recorded in a hash-chained audit trail that cannot be silently tampered with.
Why Token Vault is the right foundation#



Before Token Vault, if an AI agent needed to call the Gmail API, you had two options. You could give it your API key, which is terrible for security. One compromised agent means every connected service is compromised. Or you could build a custom OAuth flow to manage tokens, handle refresh, and scope permissions, which is months of engineering work that most teams skip.
Token Vault eliminates both problems. The user authenticates once with Google through Auth0’s social connection, and Auth0 stores the access and refresh tokens securely. When the agent needs to act, it doesn’t use a stored key. Instead, Vettra performs an OAuth 2.0 Token Exchange (RFC 8693), exchanging the Auth0 refresh token for a fresh, scoped Google access token from the vault. The agent never touches the refresh token and never stores credentials. The access token it receives is scoped to exactly what the approved action requires and expires in minutes. If the user revokes consent, subsequent exchange requests fail, and the agent loses access immediately without any key rotation.
This separation of concerns is the entire point. Vettra decides if a credential should be issued through policy enforcement and human approval, while Token Vault determines how the credential is issued, ensuring it is scoped, time-limited, and secure. Neither component needs to understand the other’s internals; they communicate through a standard token exchange protocol. One implementation detail matters here: Vettra uses two Auth0 applications. The frontend runs as a Single Page Application (SPA) for user login, while the backend runs as a Regular Web Application, a confidential client with a client secret. This is required because Token Vault’s token exchange grant type is only available to confidential clients. The SPA authenticates the user, and the backend performs the RFC 8693 exchange on the user’s behalf. This dual-application pattern is not documented in current Auth0 guides, but it is the correct architecture for systems that separate frontend and backend services.
Five layers of defense, not one#
Most agent security tools focus on a single problem: preventing unauthorized access to the agent itself. They are perimeter defenses.
Vettra takes a different approach. It assumes the agent is already running, and focuses on controlling what it can do.

Layer 1: The interceptor. A @protectdecorator wraps every agent tool function and converts raw tool calls into a structured Action Bundle. Each action is enriched with semantic metadata: action type (read, write, delete, financial, auth), target resource (Gmail, GitHub, Stripe), required scopes, reversibility, blast radius, and sensitivity. This is the context that most agent frameworks simply do not provide.
Layer 2: The risk classification engine. Every action is scored from 0 to 100 across four weighted factors. Action type contributes up to 40 points. Reversibility contributes up to 25, distinguishing between reversible actions like archiving and irreversible ones like deleting a repository. Blast radius contributes up to 20, based on how many resources are affected. Sensitivity contributes up to 15, depending on whether the data is public, internal, or regulated. The score maps to three tiers: LOW (0–19, auto-approved), MEDIUM (20–54, human approval), and HIGH (55–100, step-up authentication plus approval). Financial and authorization-escalation actions are always treated as HIGH.
Layer 3: The WASM policy verifier. Before any action is evaluated, a Rust WebAssembly module verifies the integrity of the policy bundle against a signed hash. If the policy has been modified, even by a single byte, the entire pipeline rejects the request. This verification runs inside a WASM sandbox via wasmtime, isolated from the Python runtime, which means a compromised backend cannot bypass it. When Rust is not available, an identical Python fallback produces deterministic results, verified by the test suite.
Layer 4: The real-time approval dashboard. A React dashboard, built with React 18 and Vite and deployed on Vercel, gives users full visibility and control. It includes five core views: an overview of system state, a real-time approval queue with risk scores and countdown timers, a hash-chain audit log, a permission scope visualizer, and a built-in threat simulation environment. Medium and high-risk actions are streamed via WebSocket. OAuth scopes are translated into plain language so non-technical users can make informed decisions.
Layer 5: The hash-chained audit log. Every decision is recorded as a SHA-256 hash-chained entry. Each entry includes the hash of the previous one, creating a chain where any modification invalidates everything that follows. Entries are also HMAC-signed with a deployment key. The WASM module continuously verifies integrity, and the dashboard surfaces the result in real time. If the log is ever tampered with, it is immediately visible.
How it runs: Vercel + Google Cloud Run#


The frontend is a React single-page application deployed on Vercel’s edge network. Every push to main triggers an automatic deployment. API requests are proxied to the backend through vercel.json rewrites, so the browser never communicates with the backend directly.
The backend is a FastAPI application running on Google Cloud Run in the asia-southeast2 region (Jakarta). It is packaged as a Docker container with Python 3.12, wasmtime for executing the Rust WASM verifier, SQLAlchemy for asynchronous database access, and the Auth0 SDK for Token Vault integration. Cloud Run handles auto-scaling from zero to three instances, provides managed HTTPS with automatic TLS, and supports long-lived WebSocket connections for real-time approval events.


The system uses SQLite for the demo environment and PostgreSQL 16 in production. The database stores action records, hash-chained audit entries, session state, and the permission inventory.
CI/CD is handled through GitHub Actions. A test suite of 14 cases runs on every push, covering risk classification, audit chain integrity, policy verification, and action parsing. The tests also ensure that the Rust WASM module and the Python fallback produce identical outputs for identical inputs.
Four things I did not expect to find#
The architecture came together quickly. Most of the time went into discovering what is broken in the current agent ecosystem, things that nobody seems to be talking about yet. I documented all four in FINDINGS.md, but here is the short version.
Finding 1: there is no standard format for agent action bundles When Vettra intercepts a tool call, it needs to answer a basic set of questions. What type of action is this? What resource does it target? What scope does it require? Is it reversible? What is the blast radius?
None of the major frameworks provide this. LangChain gives you a function name and a dictionary of arguments. That is it. No semantic metadata, no scope declaration, no risk context.
Vettra had to define its own Action Bundle schema and maintain per-framework adapters to translate raw tool calls into it. The adapters are simple, but they represent mapping logic that should not need to exist.
Auth0 is in the best position to define a standard here. If Token Vault required a structured action bundle as part of the token exchange request, every framework would adopt it. The required fields are straightforward: action category (read, write, delete, financial, auth), reversibility (reversible, irreversible, unknown), resource identifier, and required scopes.
Finding 2: step-up authentication was not built for agent latency Agent pipelines typically time out tool calls in 5 to 15 seconds. Step-up authentication often takes 5 to 30 seconds. If a user has to open an authenticator app, find a code, and submit it, the request will often time out before approval is complete.
Vettra works around this with WebSocket-delivered challenges, so the approval prompt appears instantly, and with session pre-authorization, allowing users to approve all MEDIUM-risk actions for a limited window with a single MFA check.
These are workarounds. The real fix is for identity providers to support latency-aware step-up flows with configurable timeouts.
Finding 3: audit log integrity is unsolved everywhere I reviewed seven agent frameworks. All of them log to a database. None of them provide tamper evidence.
A compromised process can modify or delete its own log entries without detection. For an authorization system, that is not acceptable.
Vettra implements hash-chained, WASM-signed audit entries. A stronger model would be for Token Vault to return a signed receipt for every token issuance, allowing audit trails to be verified independently of the application.
Finding 4: the authorization UX problem is harder than the security problem The cryptographic pipeline was the easy part. The hard part was building an approval interface that non-technical users could understand under time pressure.
OAuth scope strings are unreadable. There is no standard way to explain what an action will actually do. Time pressure makes decision quality worse.
The first version of the approval UI had all the information, but it was unusable. Too much text, too many fields, no hierarchy.
What worked was a three-layer model: a plain-language headline (“Agent wants to send an email to john@example.com”), a color-coded risk badge, and expandable details for the full scope breakdown.
The scope visualizer ended up being the single most impactful feature in the system.
The threat simulation: five scenarios that show everything#
The dashboard includes a built-in Threat Simulation page with five scenarios. Each one represents a different risk tier and authorization flow.
Scenario 1: Read user profile. Risk score 10, LOW tier. Automatically approved by the system. No human intervention required.
Scenario 2: Send email. Risk score 45, MEDIUM tier. Queued for human approval on the dashboard. The user sees the recipient, subject, and body before deciding.
Scenario 3: Delete a GitHub repository. Risk score 75, HIGH tier. Step-up authentication is required before the approval action is even available.
Scenario 4: Charge $500 via Stripe. Always treated as HIGH because it is a financial action. Step-up authentication is required.
Scenario 5: Grant admin permissions. Denied outright by policy. The agent cannot escalate its own permissions.
This is where prompt injection stops mattering. Even if a malicious prompt tricks the agent into requesting admin access, the policy engine rejects it before a human ever sees it.
These scenarios are not just test cases. They are the system in miniature.
Safe actions are handled automatically. Risky actions require human oversight. Dangerous actions are blocked by policy. Every decision is recorded in an auditable trail.
What I would do differently#
Start with the UX, not the cryptography. I began with the WASM verifier and the hash-chained audit log. They work as intended, but the approval interface turned out to be the component that actually determines whether the system is usable.
Push for Token Vault integration from day one. Having a live Token Vault flow in the demo makes the value immediately tangible in a way that architecture diagrams never can.
Formalize the action bundle standard as a standalone RFC. Finding #1 is the most important outcome of this project. It applies to every agent authorization system, not just Vettra.
The bigger picture#
AI agents are becoming the primary way software acts on behalf of users. Not in five years. Now. And the authorization infrastructure for that shift does not exist yet.
What exists today is a patchwork of API keys in environment variables, broad OAuth scopes granted once and never revisited, and audit logs that can be silently modified.
Vettra is one attempt to close that gap. A middleware layer that gives humans real-time control over what their agents do, with cryptographic integrity guarantees and a clear path to production through Auth0 Token Vault.
Every LangChain or LlamaIndex agent in your stack can gain real-time authorization with a single decorator, without changing existing agent code.
If you have questions or want to follow updates, feel free to reach out on X. You can explore the full source code on GitHub, try the live demo, check the backend service, or watch a quick 3-minute walkthrough on YouTube.
I publish every article on Medium too. Follow me there to get new posts in your feed, or leave a clap if this one helped.
