Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Multi-Tenant Agent Quota Accounting

Design a quota platform that reserves, meters, and reconciles agent work across tenants without overspending shared limits.

Problem statement

The source asks for an agent quota-calculation system. For this exercise, assume a platform runs long-lived AI agent tasks for many organizations. Each organization receives monthly token and tool-call allowances, may divide limits among projects, and may run concurrent agents.

Before an agent step starts, the platform must reserve an enforceable upper bound; the runtime stops the step at that bound, then records actual metered usage and releases only proven-unused capacity.

A retry, timeout, or duplicated meter event must not charge twice, and accepted reservations must not let a tenant exceed its hard quota. Administrators can inspect usage, change future limits, and reconcile disputed totals. Model-provider billing and the internals of the agent runtime are outside scope.

What to build

  1. An agent runtime can idempotently reserve a hard token and tool-call ceiling before starting a step.
  2. The platform can settle usage within that ceiling, release only proven-unused reservation, and deduplicate repeated meter events.
  3. Tenant and project administrators can inspect available, reserved, consumed, and reconciled quota.
  4. Authorized administrators can version future quota allocations without rewriting historical usage.

At scale

  • For this exercise, assume 100,000 tenants, 10 million active agents, and peaks of 200,000 reservation or settlement commands per second.
  • For this exercise, target 100 milliseconds p95 for a reservation decision in a healthy region and make settled usage visible within one minute.
  • For this exercise, quota is a hard safety boundary: retries may be rejected conservatively, but the system must not knowingly overspend a tenant limit.
  • For this exercise, retain an auditable usage ledger for 13 months and survive a single-zone failure without losing acknowledged reservations.