Skip to content
Moku
@moku-labs/ai pages

limits

Per-lane token bucket, concurrency gate and circuit breaker for all provider traffic. Injected as ctx.limits.

On this page

What it does

Core plugin. A lane is a name for one stream of provider traffic. The runner uses {task}/{provider}/default, such as video/fal/default. Each lane has a rate limit, a concurrency limit and a circuit breaker. Lanes are global: two runs in one process share them.

Config

pluginConfigs.limits.

OptionTypeDefaultDescription
defaults.rpmnumber60Requests per minute. Also the bucket capacity.
defaults.concurrencynumber4Calls in flight.
defaults.breakerThresholdnumber5Retryable failures in a row that open the breaker.
defaults.breakerCooldownMsnumber30000How long the breaker stays open before a probe.
lanesRecord<string, Partial<LaneConfig>>{}Overrides by exact lane or by task/provider prefix.

An exact lane wins over a prefix, and a prefix wins over defaults. Config merges shallowly, so a defaults object must be complete.

API

Mounted at app.limits and ctx.limits.

MethodSignatureDescription
acquire(lane: string, opts?: { signal? }) => Promise<{ release }>Waits for a token and a slot. Rejects at once with reason: "breaker-open" when the breaker is open.
reportOutcome(lane: string, outcome: "ok" | "retryable-error") => voidFeeds the breaker.
laneConfig(lane: string) => LaneConfigThe effective settings.
snapshot(lane: string) => LaneSnapshot{ lane, tokens, inFlight, waiting, breaker }.
lanes() => string[]Every lane seen so far.

Events

Emits

None.

Listens to

None.

Depends on

Nothing.