Tyr sits between a client and its LLM provider. For each request it decides, before the provider is called, whether the request runs now.
For each provider request, Tyr:
run() path in
the configured enforce or observe mode.Tyr does not translate between Anthropic and OpenAI request formats.
A pool's inFlightTokenBudget is an admission-time in-flight ceiling. An
admitted request reserves estimated input plus max_tokens or
max_completion_tokens, falling back to the pool's
defaultOutputReservation when the request does not provide an output limit.
Actual provider usage refunds unused capacity at completion, and streaming
usage can correct the active hold while the response is running.
Usage reported after admission can exceed the original estimate. In that case,
async-bulkhead-llm expands the active hold, so live inFlightTokens may
temporarily exceed the configured ceiling. Tyr blocks new admissions until
capacity is released. By default it does not abort an already-running request:
this is deliberate overrun accounting, not a post-admission kill switch. A
pool can opt in to stopping such a request.
Admission estimation uses the library request surfaces instead of folding the entire provider request into a synthetic user message:
system and provider messages remain first-class request fields.extraInputTokens.opaqueBlockTokens policy.The estimate is intended for load shedding and capacity protection. It is not a billing-grade tokenizer or a substitute for provider usage records.
For token-budgeted pools, adaptive estimation is enabled by default. Tyr records provider-reported input usage on release and applies the library's bounded per-model EWMA correction after the configured minimum sample count. Output reservations are never adapted. Calibration is local, in-memory, and reset when the process restarts.
enforce is the default and returns the normal 429/503 admission response.
observe runs the same reservation and capacity decision but proxies requests
that would have failed for budget, concurrency, queue, or admission timeout.
Those bypasses receive a synthetic shadow-... admission ID and are counted in
/stats. Shutdown and client-abort behavior are never shadowed. A pool in
observe mode cannot have a stop block.
Observe mode models the system that would exist under enforcement: requests that would be rejected do not consume simulated pool capacity. It is therefore appropriate for measuring prospective rejection rates before enabling policy, not for representing actual upstream load while bypasses are running.