You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG][Medium]- Reachable run endpoint can spend provider quota without caller limits #96
The CLI defaults to loopback, but an operator can bind the HTTP server to a reachable address or forward it. Its /run route has no caller authentication or admission limit, and accepted requests execute with an unlimited interpreter budget. Repeated requests can consume the operator's model provider quota and reduce availability.
serve passes Budget::unlimited() in both run_handler and run_traced, but Budget already has max_lm_calls, max_tokens and deadline, so most of this issue can be fixed without a new dependency. One thing to watch with the deadline: if serve builds the Budget once at startup, the absolute Instant expires a minute after boot and every later request fails. Keep the limits in App as plain values (say --max-lm-calls, --max-tokens, --timeout, with the timeout as a Duration) and build the Budget per request in both call sites, with deadline: Some(Instant::now() + timeout). Then map RunError::Budget to a 429 (or 503) in run_error, since right now everything except RunError::Input comes back as a 500, and the issue asks for a controlled error when limits are hit. With that, calls and the deadline are hard limits. max_tokens stays soft, because interp.rs checks it against tokens already spent before the next call, so a single call can go past it.
For who can call /run and how often, a --token flag (or env var) checked against the bearer header handles auth. A tokio::sync::Semaphore in App caps runs in flight (503 when try_acquire fails), and if you want per-caller limits, a small HashMap counter keyed by the token is enough. The interpreter, router, /schema, /program and /healthz stay as they are. I wrote tokio-prompt-orchestrator, which has a rate limiter and bulkhead for this, but it pulls in far more than a CLI needs and the above covers the issue. Happy to open a PR with whatever flag names and defaults you prefer.
Activity
fix: authenticate and bound HTTP serving (krypticmouse#96 krypticmous…
Mattbusel commentedon Nov 15, 2026
servepassesBudget::unlimited()in bothrun_handlerandrun_traced, butBudgetalready hasmax_lm_calls,max_tokensanddeadline, so most of this issue can be fixed without a new dependency. One thing to watch with the deadline: ifservebuilds theBudgetonce at startup, the absoluteInstantexpires a minute after boot and every later request fails. Keep the limits inAppas plain values (say--max-lm-calls,--max-tokens,--timeout, with the timeout as aDuration) and build theBudgetper request in both call sites, withdeadline: Some(Instant::now() + timeout). Then mapRunError::Budgetto a 429 (or 503) inrun_error, since right now everything exceptRunError::Inputcomes back as a 500, and the issue asks for a controlled error when limits are hit. With that, calls and the deadline are hard limits.max_tokensstays soft, because interp.rs checks it against tokens already spent before the next call, so a single call can go past it.For who can call
/runand how often, a--tokenflag (or env var) checked against the bearer header handles auth. Atokio::sync::SemaphoreinAppcaps runs in flight (503 whentry_acquirefails), and if you want per-caller limits, a smallHashMapcounter keyed by the token is enough. The interpreter, router,/schema,/programand/healthzstay as they are. I wrote tokio-prompt-orchestrator, which has a rate limiter and bulkhead for this, but it pulls in far more than a CLI needs and the above covers the issue. Happy to open a PR with whatever flag names and defaults you prefer.