Fired after a request is admitted (slot + budget acquired).
Admission timing fields are present for normal admission decisions and
absent for lifecycle events that are not admission decisions. Both values
are integer nanoseconds measured with Node's monotonic
process.hrtime.bigint() clock.
queueWaitNs is the complete span spent awaiting the underlying
concurrency acquire. decisionDurationNs excludes that await and measures
synchronous admission work, including acquire-option normalization,
precheck, postcheck, revision capture, admission id creation, and token
wrapping.
OptionaladmissionClass?: stringOptionaldecisionDurationNs?: numberSynchronous admission-decision time, excluding queueWaitNs.
OptionalqueueWaitNs?: numberTime spent awaiting the underlying concurrency acquire.
Exact protected/shared resource attribution at admission time.
Fired when a borrowed local concurrency slot is deliberately returned before the admitted work reaches final settlement.
This event does not mean the provider stopped work. heldTokens remain
charged until the eventual release event so upstream capacity is never
presented as reclaimed based only on client-side abandonment.
OptionaladmissionClass?: stringWhether an explicit call or a lease expiry returned the slot.
Fired when observe mode executes a callback without holding capacity.
This is separate from admit: bypassed work does not affect concurrency
or token-budget accounting.
OptionaladmissionClass?: stringOptionaldetail?: LLMRejectDetailTrue when an advisory positive decision raced with a real rejection.
Fired when bypassed work settles, whether successfully or by throwing.
Fired after an effective cumulative usage update for bypassed work.
Fired when a request joins an existing in-flight call via dedup.
OptionaladmissionClass?: stringDeduplication is automatically partitioned by class when configured.
Fired after a higher-revision admission-limit snapshot is applied.
Fired when a request is rejected at any stage.
Timing is attached only when the event represents an admission decision. Deduplication-follower failures and observe-mode bypasses are deliberately left uninstrumented because they are not admission decisions.
Boundaries for instrumented rejection paths:
queueWaitNs === 0; decision time is the precheck spanOptionaladmissionClass?: stringOptionaldecisionDurationNs?: numberSynchronous admission-decision time, excluding queueWaitNs.
Optionaldetail?: LLMRejectDetailCapacity snapshot; absent for dedup-wait rejections.
Limit revision captured with the rejection decision.
OptionalqueueWaitNs?: numberTime spent awaiting the underlying concurrency acquire.
Fired when a slot is released.
reservedTokens is the pre-admission reservation (input estimate +
max_tokens reservation). refundedTokens is what was returned to
the budget — non-zero only when usage was reported and
usage.input + usage.output < reservedTokens.
Per-request actual consumption: usage ? usage.input + usage.output : null.
The library does not pre-derive this onto the event payload — null
(no usage reported) and 0 (genuinely zero usage) are different
states that observers should distinguish.
For cumulative consumption across all releases, prefer
stats().tokenBudget.totalConsumed over aggregating these events.
OptionaladmissionClass?: stringTokens held immediately before release returned them.
Exact protected/shared resource attribution captured at admission.
Optionalusage?: TokenUsageLast emitted usage-event sequence for this admission.
Fired after an effective cumulative reportUsage() update.
Stale or duplicate reports that do not increase either cumulative
usage field are ignored and do not emit an event. sequence starts at
1 per admission and increases monotonically, allowing external
coordinators to reject duplicate or out-of-order updates.
async-bulkhead-llm — public API surface.
This entry point re-exports everything the package supports; the implementation lives in focused modules:
types.ts— request/result/options/stats/event typeserrors.ts—LLMBulkheadRejectedErrorprofiles.ts—PROFILESpresetsestimators.ts— naive + model-aware estimators,extractTextLengthadaptive.ts—createAdaptiveTokenEstimator(v3.8)dedup.ts— deduplication internals (keying, share safety)validation.ts— internal numeric/estimate/usage guardsbulkhead.ts—createLLMBulkhead(admission, budget, events)Deep-importing the internal modules is not supported; the package
exportsmap exposes only this entry point.