By default Tyr never touches a request once it has admitted it. A request that
uses more tokens than it reserved only widens its hold, a lowered limit waits
for running requests to finish, and a bounded shutdown closes connections at
its deadline. Since 0.35.0 a deployment can opt in to stopping admitted
requests in those three situations. Stops are made by
async-bulkhead-llm@3.19.1.
shutdown:
drainTimeoutMs: 30000
stopOnDrainTimeout: true # stop what outlives the drain deadline
pools:
- name: interactive-claude
inFlightTokenBudget: 400000
stop:
overrunAllowanceTokens: 2000 # how far a hold may pass its reservation
takeBackGraceMs: 5000 # then work above lowered limits is stopped
A stop means the same thing whatever caused it:
503 with
error.type: "admission_stopped", x-admission-reason: stopped and
x-admission-stop-cause. That includes a streamed request whose first
chunk has not been written. Once part of a reply has been written, the
reply is cut: its connection closes with no further event. Neither gets a
retry hint.stopped, with its cause. It is not
an admission rejection and not an upstream failure.maxQueue above 0), the returned slot goes to the
request at the head of the queue at once, while the stopped request's
tokens are still charged. A waiter whose reservation does not fit beside
them is rejected with 429 budget_limit instead of waiting.| Cause | Turned on by | A request is stopped when |
|---|---|---|
overrun |
pools[].stop.overrunAllowanceTokens |
A usage report raises its hold more than the allowance above its reservation. Also, when a report leaves the pool above inFlightTokenBudget, or a class above maxInFlightTokens, requests are stopped until the rest fit. |
limits |
pools[].stop.takeBackGraceMs |
A limits update left running requests above the new limits, and the grace period has ended. |
drain_deadline |
shutdown.stopOnDrainTimeout |
It is still running when shutdown.drainTimeoutMs elapses. |
When Tyr has to choose, it stops requests on borrowed class capacity first, then normal priority before high priority, then the request admitted last. Queued requests and observe-mode bypasses hold no capacity and are never stopped.
The allowance is measured on the request's hold: the tokens it has charged to the pool. It is not measured on the request's usage.
progressiveReconciliation.enabled: false, a hold is the reported
input plus the larger of the output reservation and the reported output.
The request is stopped once its input above the estimate plus its output
above the reservation exceeds the allowance. An input estimate that was too
low counts here, so leave room for estimation error.message_delta that carries a stop reason, a
Chat Completions usage chunk with no choices or with a finish reason, and a
Responses event that shows a finished response.tyr.progressiveReconciliation, and an overrun that only
the closing usage shows is not added to tyr_pool_tokens_overrun_total.
The consumed-token counters include it.0 stops on the next timer tick.maxConcurrent, its token budget,
a class's own ceilings, and a class floor that was restored while other
classes were using that capacity.shutdown.stopOnDrainTimeout requires shutdown.drainTimeoutMs. It applies
to every pool, including observe pools and pools without a stop block. At
the deadline Tyr stops each request still running, answers or cuts it, and
then closes the remaining connections as before. shutdown() reports
stopped, the number of admissions the deadline stopped, and the process logs
it as stopped=<n>. The result is taken at the deadline, before the dropped
calls have ended, so drained is false and inFlight still counts them.
The library accepts a stop policy only as part of a limits snapshot and does
not carry it from one revision to the next. Tyr therefore states the pool's
configured policy on every limits update it applies, whether the update comes
from the embedded control surface or from
Latchflo. A stop field on an update is ignored: a control plane does not
choose the policy.
max(limitsRevision, 1). Revision 0 cannot carry a policy, so a pool whose
limitsRevision is 0 or omitted starts at revision 1, and its first runtime
update must be revision 2 or higher.maxConcurrent: 0), as every Latchflo-managed
pool does, keeps its configured revision and gets the policy with its first
update.stop block cannot be combined with admissionMode: observe.createGateway. Legacy environment mode has no variables for them.GET /stats: limits.stop is the applied policy. tyr.stop holds the
configured policy, stopped, and stoppedByCause with every cause
listed. It is present on a pool with a stop block, and on any pool once
one of its requests has been stopped. llm.stopped and
llm.stoppedByCause are the library's own counters and are absent until
the first stop.GET /metrics: tyr_pool_stopped_total{pool,cause},
tyr_pool_admission_class_stopped_total{pool,admission_class},
tyr_pool_stop_overrun_allowance_tokens{pool} and
tyr_pool_stop_take_back_grace_seconds{pool}. They exist only for a pool
that reports tyr.stop. tyr_requests_total and
tyr_upstream_duration_seconds gain the outcome value stopped.tyr_pool_work_in_flight and in
tyr.restoration.upstreamCapacity.activeAccountingHolds, not in
tyr_pool_in_flight.settlement: "stopped" and a stopCause.A stop is a local decision. It returns Tyr's slot and tokens and closes Tyr's connection to the provider. It does not prove that a provider account, a model-side queue or an accelerator stopped work, and Tyr lends the returned capacity again without that proof. If the constrained resource is upstream, keep an unlent floor or use a provider-side partition.