Skip to main content
Logfire for agent governance

Govern what your agents spend, send and reach

Spend policies and data protection run on the request path: when a limit is met, the call simply does not go out. Every allowed call lands in the same trace as the queries and tools around it, so the audit log is the agent's actual trajectory, queryable with SQL.

The half a gateway cannot answer
-- Spend by agent and model, last 7 days.
select
  attributes->>'gen_ai.agent.name'    as agent,
  attributes->>'gen_ai.request.model' as model,
  sum(cast(
    attributes->>'operation.cost' as double
  )) as usd
from records
where start_timestamp > now() - interval '7 days'
  and attributes->>'gen_ai.operation.name'='chat'
group by agent, model
order by usd desc;
Definition

Two products share this name

One is a control point: something on the request path that can refuse. A budget is met, so the call does not go out. A prompt carries a card number, so it is redacted or blocked. A model is not on the allow list, so it is unreachable. The decision happens before the provider sees the request.

The other is a register: a system of record for which agents exist, who owns them, what risk they carry and what evidence you can produce when someone asks. It does not sit on the request path at all.

Both are sold as AI governance and only one of them can stop anything. This page is the first kind, plus the part most control points leave out: the record of what an allowed call went on to do. If your deliverable is an attestation binder, you want the second kind as well, and the two are usually bought separately.

What it covers

Four things worth enforcing

An audit log that is the trajectory

Every step an agent takes is an OpenTelemetry span: the model call, the tools it invoked, the queries it ran, in order, with the key and organization member behind them. There is no parallel audit record to reconcile against what actually happened; the run itself is the record, and it outlives the conversation.

Spend and data protection, enforced

A spend policy is checked as each request arrives, and once a limit is met the call is refused: a daily ceiling to catch the runaway loop, a monthly one to hold the budget. Guardrails inspect the prompt before it leaves your boundary, with regex for structured secrets and third-party DLP solutions like Presidio, hosted by you, for personal data with no fixed shape.

Optimization at every level

The same telemetry that governs also improves. At the gateway, routing weights and price overrides let you move traffic toward the provider winning on cost and latency, under spend ceilings that make the experiment safe. At the prompt, the optimizer reads production runs and proposes changes with the evidence attached.

Impact traced across the enterprise

An agent's action does not end at the model response. The trace follows it into the services it called, the rows it wrote and the jobs it kicked off, so 'what did this agent change' is answered from the same store as 'what did it cost', across everything you instrument. Attach your own attribute for the person an agent acts for and it groups by that too.

Enforcement lives in Pydantic AI Gateway, which has the detail on how each policy is configured and how it compares to the other enforcement points, and the prompt half of the optimization loop is the agent optimizer. The trajectory and the enterprise trace are what the rest of this page is about.

The difference

Enforcement and evidence in the same trace

Gateways enforce and observability platforms explain, and the usual arrangement is one of each with a correlation ID between them. That works until the question spans the boundary. A finance owner asks why last month cost what it did; the gateway can say which key spent it and the traces can say what the agent was doing, and joining those two answers is a project.

Here the enforcement decision and the work that followed it are records in the same store. Blocks, spend and the agent's database queries, retries and tool calls are all queryable with PostgreSQL-compatible SQL, so attribution is a group by. The same interface is available to coding agents through Logfire's MCP server.

Scope

What this does not do

There is no risk questionnaire, no policy pack and no attestation workflow, and there is no approval step that routes a high-risk action to a person before it runs. Those are real parts of this category and naming them is cheaper than letting you find out during an evaluation.

What is here is the enforcement point and the evidence: a policy that refuses, a guardrail that inspects, an allow list that holds, and a trace of everything that got through. Governance registries consume that evidence well, and pairing one with this is a reasonable end state.

Decision guide

Is this the right shape for you?

Choose Logfire if

  • You want the limit enforced at the moment the call is made
  • You want prompts inspected before they cross your network boundary, by a detector you run
  • You want spend and blocks attributable to an agent and the person it acted for
  • You want the enforcement decision and the trace of what followed in one product

Choose a governance registry if

  • Your deliverable is a filled-in risk framework, an AI registry and an attestation trail
  • You need approval workflows that route a high-risk action to a human before it runs
FAQ

Common questions

What is agent governance?

Controlling what an agent may do at runtime: which models it can call, how much it can spend, and what data may leave with its prompts. It also means being able to show afterwards which agent did what. The category contains two different products: a control point on the request path that can refuse, and a register that records which agents exist and what risk they carry. Most enterprises end up with one of each.

Is an AI gateway the same thing as agent governance?

A gateway is where most enforcement happens, because it is the one point every request passes through. It is not the whole of governance. Registration, risk assessment and attestation live in a different kind of product, and a gateway does not produce an evidence binder for a regulator.

What is the difference between cost tracking and a spend policy?

Cost tracking reports what you spent. A spend policy refuses the request once a limit is met. Both are useful and only one of them helps while the incident is still happening, which is why the limits here are checked on the request path as each call arrives.

Does this include human approval workflows?

No. Routing a high-risk action to a person before it executes is a real part of this category and Logfire does not do it today. What is here is enforcement that is automatic, meaning a policy either allows the call or refuses it, plus the trace that shows what an allowed call went on to do.

What does optimization at multiple levels mean?

Two loops over the same telemetry. At the gateway level, routing groups carry a priority and a weight, so you can shift traffic toward the provider that is winning on cost and latency and override catalog prices to match your negotiated rates, with spend ceilings holding the floor under any experiment. At the prompt level, the optimizer reads production runs and proposes prompt changes with the runs cited as evidence. Governance provides the data both loops need.

Can I use the guardrails without sending data to another vendor?

Yes, and that is the point of the design. Regex protections run in the gateway, and detection for unstructured personal data calls out to a service you run, so classification happens inside your boundary. You also choose what happens if that detector is unreachable: fail open and let the request through, or fail closed and block it.

How does this relate to compliance frameworks like the EU AI Act?

Indirectly. Logfire produces the runtime evidence: what ran, what it cost, and what was blocked. That is evidence an assessment consumes; the assessment itself lives elsewhere. If your deliverable is a filled-in framework and an attestation workflow, a dedicated AI governance registry is the right tool, and it can consume this evidence.

Enforce it, then prove it

Get started with 10 million free spans, logs, and metrics per month, and 0% markup on your own provider keys. No credit card required.