How to audit what an AI agent did across your systems

Short answer: require every agent run to declare its purpose in a swarmvia session. Every SQL query, MCP tool call, HTTPS API call, write, and refused attempt across all sources lands on one chronological timeline attributed to a person and agent — and clicking Revoke session invalidates every live key for that run across every system at once.

When an agent works across a database, a CRM, and a vendor API, per-service logs do not answer the question a security lead actually asks: "What was this agent trying to do, what did it touch, what was refused, and did it change anything?"

Raw access logs show isolated requests. Agent sessions group every call an agent makes for one task under a human-readable purpose, so you can review a run in seconds instead of stitching timestamps together across four dashboards.

Why are per-service logs not enough for AI agents?

  • No stated intent. A database log shows SELECT ... FROM invoices under a shared service user. It never tells you whether that ran for a finance reconciliation or a stray prompt.
  • Fragmented across systems. One task might query PostgreSQL, look up an issue in Sentry, and call NetSuite. Reviewing what happened means chasing three separate log formats.
  • Refusals disappear. When an agent tries a DELETE or calls an unapproved tool, you want to see that refusal right next to the rest of its run.
  • Slow containment. If an automated run starts misbehaving, rotating static keys across three systems takes too long.

How purpose-labeled sessions work

  1. The agent declares a purpose. Before calling a source, an MCP-connected agent calls start_session with a one-sentence purpose (for example, "Brief me on Acme before my 2pm call" or "Reconcile November invoices against the CRM"), and optionally the Work issue it is working on. Scripts and CI do the same with POST /api/v1/sessions.
  2. Every source key binds to that session. Each short-lived key the agent mints belongs to the session, so every database query, MCP tool call, and HTTP call carries the session ID (ses_…) and the person who authorized the agent.
  3. One timeline across every source. Open Sessions in the dashboard to filter by purpose, agent, member, source, or status (Open, Idle, Ended, Revoked). Click any session to see every source it touched, counts of calls, writes, errors, and refusals, and the chronological timeline.
  4. External steps stay visible — and clearly labeled. Agents can call record_activity to note actions taken outside swarmvia (such as opening a GitHub PR or running tests). Those lines appear in the timeline marked Reported, separate from calls swarmvia directly observed and enforced.

Stop a misbehaving run in one click

If an active session should not be running, open it and click Revoke session. Every live key minted inside that session stops working across every source immediately, and the session cannot mint new keys.

To permanently cut off an assistant or script, disconnect it under Settings → Connected agents or revoke its token under Organization settings → API tokens. Nobody else on your team has to rotate a database password or vendor token.

Set it up

  1. Connect your databases, MCP servers, and APIs as sources in swarmvia.
  2. Connect your team's agents to https://swarmvia.com/mcp with OAuth (Agents). swarmvia's MCP instructions automatically prompt agents to start a session with a purpose before touching sources and call end_session when finished.
  3. For CI jobs or autonomous scripts, mint keys with a Control API token and pass session_id on each task run (Sessions).

What sessions record — and what they do not

  • Recorded: purpose, member, connected agent or API token, sources touched, SQL statements (truncated), row counts, MCP tool names, HTTP methods and paths, policy decisions (allowed, denied), status codes, timing, and optional agent-reported milestones.
  • Never recorded: query result rows, HTTP request or response bodies, upstream credentials, or raw access keys.
  • Visibility: owners and admins see every session in the organization; members see sessions that acted for them and only the sources their groups allow.

See Sessions for the full reference, or Find everything an agent did for an incident walkthrough.

Try it on your own data

Free to start, no credit card. Connect an agent in a few minutes.

Frequently asked questions

How do I know why an AI agent queried production?
Before touching a source, the agent starts a session with a one-sentence purpose (such as "Reconcile November invoices against the CRM"). Every key minted for that task belongs to the session, so every query, tool call, API request, write, and refusal is grouped under that purpose.
Can I stop a running agent across multiple systems at once?
Yes. Open the session in swarmvia and click Revoke session. Every live key that session holds is invalidated across every database, MCP server, and API at once, and it cannot mint new keys under that session.
What about actions the agent takes outside swarmvia?
Agents can log external milestones (like opening a GitHub pull request or posting to Slack) into the same session timeline via record_activity or the Control API. Those entries are marked Reported so reviewers can distinguish self-reported steps from calls swarmvia enforced and observed.
How long are agent sessions and audit logs retained?
Sessions and their call logs follow your plan's log retention window: 7 days on Free, 30 days on Starter, 90 days on Team, and 1 year on Business, with longer retention available on custom plans.

In the docs

More solutions

Last updated