Serverless metering and audit layer for AI agents — track token usage, cost, and activity per agent in real time.
AgentLedger is a serverless API that intercepts agent activity logs and token usage metrics, calculating exact USD costs based on model pricing (e.g., Claude 3 Opus vs Haiku). It stores an immutable ledger of all agent actions in DynamoDB and publishes custom metrics to CloudWatch.
For security and compliance, AgentLedger serves as the definitive audit trail of "who did what, when, and how much it cost" across a multi-agent swarm.
AI Agent (Completes task)
│
▼
POST /ledger (AgentID, TaskID, Tokens)
│
▼
API Gateway → Lambda (Cost Calculator)
│
├── Write immutable record → DynamoDB
│
└── Publish metrics → CloudWatch (Cost per Agent)
| Property | Implementation |
|---|---|
| Immutability | DynamoDB records are append-only; agents cannot delete their history |
| Authentication | API Gateway secured via IAM or API Keys |
| Encryption | DynamoDB tables encrypted at rest (KMS) |
| Cost Anomaly Detection | CloudWatch alarms trigger if an agent exceeds expected spend |
Deployment at Merkaba AI Risk Management:
AgentLedger is used to monitor the cost and activity of our internal Red Team agents. During an automated jailbreak campaign, AgentLedger detected an anomalous spike in token usage from the redteam-runner agent. CloudWatch triggered an alert, and the security team identified that the agent had entered an infinite loop due to a poorly formatted prompt injection target. The agent was paused, saving an estimated $400 in unnecessary token spend over the weekend.
ai-agent-orchestration-gateway— Audits tasks routed through the gatewayagent-security-scanner— Validates agent configs before they are allowed to log to the ledger
MIT License — see LICENSE for details.
Merkaba AI Risk Management security@merkabacreatives.org https://merkabacreatives.org/ai-risk