The postmortem question that ends careers is simple: what did the agent actually do? A week after a bad migration, someone asks for the exact commands an AI agent ran against the customer database, and the only answer is a CloudWatch line that says a connection happened. That is not an audit trail. That is a timestamp.
This guide builds real audit logging for AI agents whose identity comes from Microsoft Entra, with the record produced at the connection level by hoop.dev. Set the roles straight first. Entra is the identity provider that authenticates the agent and asserts who it is. hoop.dev is the relying party that verifies the Entra token and then records the infrastructure session the agent opens. The log is of the database or service connection, attributed to the Entra identity. hoop.dev does not record activity inside Entra and does not front Entra's APIs.
What audit logging must capture for an agent
An agent log that an auditor or an incident responder can use needs more than connection events. Use this as a checklist of what to capture:
- The Entra identity that authenticated, including the group that authorized the connection.
- The exact commands or queries the agent ran, in order, not a summary.
- The target connection and the time window the session stayed open.
- Whether any result was masked, and whether any operation was routed for approval.
- An immutable record that the agent itself cannot edit.
That last point is the architectural one. The record has to live outside the process the agent controls. If the agent can write to the log, the log is a suggestion. hoop.dev captures the session at the gateway, on the path between the agent and the target, where the agent cannot reach to alter it.
How to wire it up
- Configure Entra as the OIDC provider in hoop.dev so every agent session carries a verified identity.
- Create the connection to the target database or service with its credential on the connection.
- Map the agent's Entra group to that connection and turn on session recording.
- Forward the session records to your SIEM for retention alongside human access logs.
connection: customer-db
type: postgres
access: group:billing-agents
record: full
export: siemVerify the log is complete
Have the agent run a sequence of queries, then pull the session record. Every query should be present, in order, attributed to the Entra identity, with the open and close times. Try to find a gap. If the command-level log shows each statement rather than a single "session opened" line, your audit logging is doing its job. The difference between command-level audit and connection-level logging is the difference between knowing what happened and knowing only that something did.
