跳到正文
Hacker News · AI· roandejager·· 2 小时前AI 评分61

AI Circuit Breaker:拦截智能体无限循环的反向代理

Show HN: AI Circuit Breaker – Reverse proxy to stop agent infinite loops

AI 导读

开发者 Roan de Jager 发布 AI Circuit Breaker,一个可直接替换 base URL 的反向代理,用于拦截智能体无限工具循环并强制执行花费上限。

正文

AI Circuit Breaker

[ GATEWAY SPECIFICATION // REV-2026 ]

Stop runaway agents before they drain your API budget.

A drop-in reverse proxy that catches infinite tool loops and enforces hard spend caps in volatile RAM. Sub-35ms overhead. Zero payload retention.

TRY LIVE IN YOUR TERMINALcurl -I https://circuit-breaker-api.onrender.com/health

Frankfurt (eu-central-1) — 32ms proxy latency — HTTP/2 SSE active

gateway // request traceeu-central-1

12:08:41.018 POST /v1/chat/completions

12:08:41.021 window scan: prompt hash match 1/3

12:08:41.024 spend check: within configured cap

HTTP/2 200 · upstream response passed

Simulated trace · example values

CLIENT CONFIGURATION

Change the base URL. Keep the SDK.

ARCHITECTURE // REQUEST PATH

Data path and enforcement points

01 / REQUEST FLOW

Volatile-memory request inspection

HTTP/2 · SSE

02 / BLOCK RESPONSE

HTTP 400 payload

{
  "error": {
    "message": "Request blocked by Circuit Breaker",
    "type": "circuit_breaker_loop_detected",
    "code": "infinite_loop_killed"
  }
}

03 / VOLATILE MEMORY

RAM hash benchmark

<15ms

memory execution target

FingerprintSHA-256

Prompt disk writes0

Payload storageNone

04 / MICRO-DOLLAR ACCOUNTING

Rolling spend ceilings and backpressure

429 BUDGET_LIMIT_BREACHED

Requests are checked against hourly and daily account caps before they are sent upstream. The bars below illustrate cap windows, not live account utilization.

Hourly ceiling$2.00 / hour

CAP THRESHOLD · USAGE NOT SHOWN

Daily ceiling$10.00 / day

CAP THRESHOLD · USAGE NOT SHOWN

Performance figures are engineering targets and depend on deployment, network conditions, and request profile.

FAILURE ANALYSIS // ILLUSTRATIVE SCENARIO

Autopsy of an Overrun

SQL RETRY LOOP

An unhandled SQL error leaves an agent retrying the same tool call at 120 attempts per minute. In this example, the sliding deque recognizes the repeat at attempt three and interrupts the cycle before the remaining requests are sent.

The $680+ / 45-minute cost is a modeled scenario, not measured customer spend. Estimated avoided spend assumes $35 per intercepted incident.

  1. 01 · 00:00

    SQL write fails

    Agent receives retryable error.

  2. 02 · 00:01

    Retry cadence begins

    Unchanged tool plan repeats at 120/min.

  3. 03 · 00:02

    Attempt #3 detected

    Prompt fingerprint crosses repeat threshold.

  4. 04 · 00:02+

    Loop halted

    $680+ illustrative exposure avoided.

Roan de Jager

Built by an Engineer

Built by Roan de Jager (@roandejager) in Norway.

I built Circuit Breaker after an autonomous agent got trapped in a recursive tool retry loop and burned through hundreds of dollars in API credits overnight. It's built in Python and FastAPI for sub-35ms raw performance with strict zero-payload retention.

来源:Hacker News · AI · circuit-breaker-sage.vercel.app