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 invoicesunder 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
DELETEor 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
- The agent declares a purpose. Before calling a source, an MCP-connected
agent calls
start_sessionwith 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 withPOST /api/v1/sessions. - 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. - 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. - External steps stay visible — and clearly labeled. Agents can call
record_activityto 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
- Connect your databases, MCP servers, and APIs as sources in swarmvia.
- Connect your team's agents to
https://swarmvia.com/mcpwith OAuth (Agents). swarmvia's MCP instructions automatically prompt agents to start a session with a purpose before touching sources and callend_sessionwhen finished. - For CI jobs or autonomous scripts, mint keys with a Control API token and
pass
session_idon 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.