S4 Firewall - LLM Token Budget and Runaway Loop Control for Amazon VPC
S4 Firewall is an in-VPC forwarding proxy that puts a pre-emptive spend firewall in front of your LLM traffic. Point your application's base_url at it (OpenAI-compatible, Anthropic Messages-compatible, or Bedrock-compatible); every request runs a synchronous attribute -> reserve -> budget/anomaly -> forward -> reconcile pipeline. Its headline job is the runaway-loop circuit breaker: a deterministic hard cap that blocks a request before it is relayed once a tenant, feature, or customer budget would be exceeded, plus best-effort detection of agent loops and near-duplicate call chains to contain a runaway agent before it burns the budget. Token spend is attributed per feature/tenant/customer and emitted to CloudWatch and an optional counts-only audit ledger. Ships as an Amazon Linux 2023 arm64 AMI with a least-privilege IAM role and one-click CloudFormation - no control plane, no database. Billed per instance per hour, with an annual option.

