Skip to content
Roadmap0/111
domain M55h

AI Denial-of-Service & Economic Abuse

Defend against denial-of-wallet, context stuffing, recursive tool loops, and retry storms using strict input/output token caps, `max_steps` agent limits, wall-clock timeouts, retry jitter, circuit breakers, and per-tenant cost quotas.

Module detail

Best time to learn: Immediately after implementing token budgets, truncation, retries, tool-call limits, queues, and rate limiting.

Prerequisites - Token counting and context budgets. - API rate limiting. - Async concurrency and queue basics. - Agent step and tool-call budgets.

### Threat model

AI workloads have variable and sometimes multiplicative costs. One user action may trigger retrieval, reranking, several model calls, tools, retries, and media processing.

Study: - Denial of wallet and cost amplification. - Context stuffing and oversized input. - Repeated tool invocation and recursive agent loops. - Retry storms and provider failure amplification. - Expensive retrieval/reranking patterns. - Per-user, per-tenant, and per-model quotas. - Concurrency limits, queue backpressure, and circuit breakers. - Abuse signals and anomaly detection.

### Labs

  • Cost model (1h): Estimate cost per request across input/output tokens, retrieval, reranking, tools, and media.
  • Adversarial load (1h): Simulate oversized prompts, repeated requests, and tool loops against your own local test system.
  • Budget enforcement (2h): Add request, token, tool-call, wall-clock, and concurrency budgets with deterministic rejection behavior.
  • Recovery test (1h): Simulate provider timeouts and retries; verify retry caps, jitter, circuit breaking, and queue recovery.

### Project integration

  • Project 1: Token and conversation budgets, maximum response tokens, request timeout, and per-session limits.
  • Project 3: Maximum steps, tool calls, parallel tasks, execution time, and approval waits.
  • Production API: Per-user and per-tenant quotas, backpressure, and cost alerts.

### Measurable completion criteria

  • Each request has a bounded token, time, and cost budget.
  • Agent loops terminate at a deterministic limit.
  • Retries cannot amplify an outage indefinitely.
  • Load tests show controlled degradation and recovery.
  • Cost and abuse metrics are available without logging sensitive prompt contents.

------------------------------------------------------------------------