Project 10  ·  FinOps  ·  AI Agent Infrastructure

AgentLedger

Multi-Agent Cost Engine

An AWS-native metering layer that tracks token usage per AI agent in real time — giving engineering teams the granular cost visibility needed to scale from 1 to 50+ agents without losing financial control.

50+
Agents Tracked
100%
Token Visibility
<5ms
Metering Latency
$0
Idle Cost
The Challenge

AI agents are a black box
for finance teams.

As organizations scale AI agent fleets, the question shifts from "does it work?" to "what does it cost?" Without per-agent metering, cloud bills become opaque — and scaling becomes a financial gamble.

The Problem

Untrackable Cloud Spend

Organizations running multi-agent AI systems lack visibility into which specific agents or tasks are consuming the most tokens. Token costs aggregate into a single line item — making it impossible to identify waste, optimize performance, or prove ROI to stakeholders.

The Solution

Granular Metering Layer

AgentLedger intercepts every agent invocation through API Gateway, records token usage per agent ID in DynamoDB, and emits real-time cost metrics to CloudWatch — giving teams a live financial dashboard for their entire AI fleet with zero code changes to existing agents.

System Design

How AgentLedger Works

A fully serverless metering pipeline built on AWS-native services. Every agent call flows through the ledger — tracked, stored, and surfaced as actionable cost intelligence.

🤖
AI Agent
Invokes LLM with agent_id header
🔗
API Gateway
Routes & authenticates requests
Lambda
Extracts & normalizes token data
🗄️
DynamoDB
Persists per-agent usage records
📊
CloudWatch
Real-time cost metrics & alerts
agentledger/lambda_handler.py
# AgentLedger — Token metering interceptor
import boto3, json, time

dynamodb = boto3.resource('dynamodb')
cloudwatch = boto3.client('cloudwatch')
table = dynamodb.Table('AgentLedger')

def lambda_handler(event, context):
  agent_id = event['headers']['x-agent-id']
  tokens = event['body']['usage']['total_tokens']
  cost_usd = tokens * 0.000002

  # Write to DynamoDB ledger
  table.put_item(Item={
    'agent_id': agent_id,
    'timestamp': int(time.time()),
    'tokens': tokens,
    'cost_usd': str(cost_usd)
  })

  # Emit CloudWatch metric
  cloudwatch.put_metric_data(
    Namespace='AgentLedger',
    MetricData=[{'MetricName': 'TokenCost',
      'Dimensions': [{'Name': 'AgentId', 'Value': agent_id}],
      'Value': cost_usd, 'Unit': 'None'}]
  )
  return {'statusCode': 200, 'body': json.dumps({'metered': True})}
Technology

Built on AWS-Native Services

Every component is serverless, managed, and scales to zero — meaning the metering layer itself costs nothing at idle and pennies at scale.

API Gateway
Request routing & auth layer
AWS Lambda
Token extraction & normalization
Amazon DynamoDB
Per-agent usage ledger
CloudWatch Metrics
Real-time cost dashboards
Terraform
Infrastructure as Code
Python / Boto3
Lambda runtime & AWS SDK
Business Impact

Granular ROI tracking
at any scale.

AgentLedger transforms AI infrastructure from a cost center into a measurable, optimizable system — enabling confident scaling from 1 to 50+ agents.

💰
Per-Agent Cost Visibility
Know exactly which agent is spending what — down to the individual task and token. Eliminate the guesswork from AI infrastructure budgeting.
📈
Safe Scaling to 50+ Agents
Prove ROI before scaling. AgentLedger gives finance and engineering a shared source of truth, making the case for expanding AI fleets with hard data.
🔍
Waste Identification
Surface underperforming agents consuming disproportionate tokens. Optimize prompt engineering and model selection with real usage data, not estimates.