Three failure modes show up over and over when teams try to build audit trails for an AI coding agent in Cursor. The trail is incomplete because the agent only logged what it decided to log. The trail is unattributed because everything ran under one shared service account. And the trail is untrustworthy because the agent's process could have changed it. Each one alone is enough to make the audit worthless.
Name the failures first, because the fix follows directly from them. You do not need a better logging library inside the agent. You need to capture the record somewhere the agent cannot touch, which means moving it onto the connection.
The failure modes behind broken audit trails
Incomplete: a self-reporting agent records intent, skips the commands it never narrated, and loses data on a retry or crash. Unattributed: when the agent connects as a single shared credential, every action looks identical and you cannot answer who did what. Untrustworthy: a log the agent can write is a log it can be steered into truncating or rewriting.
An audit trail has to defeat all three at once. Fixing completeness while leaving attribution broken still leaves you unable to answer the auditor's first question. The only place all three get solved together is the boundary the commands cross on their way to the database.
The fix: capture audit trails at the boundary
hoop.dev is an open-source Layer 7 access gateway. The Cursor agent reaches a database or internal service through it, and the audit trail is produced there:
- Capture is at the command level, recording the actual queries that crossed the connection, which closes the completeness gap.
- Each session is attributed to the authenticated identity, which closes the attribution gap.
- The record lives at the gateway, outside the agent, which closes the trust gap.
hoop.dev builds the trail from the infrastructure actions the agent takes. It does not log the model prompt or output, because the auditable event is the command, not the conversation that led to it. The gateway sees the query; the model's reasoning stays the agent's business. The broader approach is described on the hoop.dev site.
