Pramiti Docs

Agent FinOps

Per-agent cost caps, attribution, and warehouse budget enforcement

pramiti-agent-finops provides per-agent daily warehouse cost caps and attribution. It prevents runaway AI agents from burning through cloud compute budgets by enforcing configurable spending limits.

Install

pip install pramiti-agent-finops

Quick Start

from pramiti_agent_finops import CapChecker, CapExceededError
from pramiti_agent_finops.backends import InMemoryBackend
 
# Set up a backend and configure caps
backend = InMemoryBackend()
backend.set_cap("ws-1", "my-agent", max_usd=10.0, action="block")
backend.add_cost("ws-1", "my-agent", 11.0)
 
# Check if the agent has exceeded its cap
checker = CapChecker(backend)
try:
    checker.check("ws-1", "my-agent")
except CapExceededError as e:
    print(f"Blocked: {e}")  # Agent exceeded $10.00 daily cap

API Reference

CapChecker

The core enforcement engine. Zero external dependencies — inject any ICostBackend-compatible storage adapter.

class CapChecker:
    def __init__(self, backend: ICostBackend): ...
    def check(self, workspace_id: str, agent_id: str) -> None: ...
  • check() raises CapExceededError if the agent has exceeded its daily cap with action="block"
  • check() issues a CapWarning if the agent has exceeded its daily cap with action="warn"
  • check() is a no-op if no cap is configured for the agent

ICostBackend (Interface)

Storage adapter interface. Implement this for custom storage:

class ICostBackend(ABC):
    def get_cap(self, workspace_id: str, agent_id: str) -> Optional[dict]: ...
    def get_current_cost(self, workspace_id: str, agent_id: str) -> float: ...
    def add_cost(self, workspace_id: str, agent_id: str, amount_usd: float) -> None: ...
    def set_cap(self, workspace_id: str, agent_id: str, max_usd: float, action: str) -> None: ...

InMemoryBackend

Built-in in-memory backend for testing and evaluation:

backend = InMemoryBackend()
backend.set_cap("ws-1", "agent-1", max_usd=5.0, action="block")
backend.add_cost("ws-1", "agent-1", 3.50)

Exceptions

  • CapExceededError — Raised when an agent exceeds its cap and action is "block"
  • CapWarning — Warning issued when an agent exceeds its cap and action is "warn"

Platform Integration

When used inside the Pramiti platform, use the PostgreSQL backend:

from pramiti_agent_finops import CapChecker
from epistom.services.finops import PostgreSQLCostBackend
 
backend = PostgreSQLCostBackend(session)
checker = CapChecker(backend)
checker.check(str(workspace_id), agent_id)

On this page