On this page

0120: Deterministic provider and tool limits

Status: Proposed — design default, pending the maintainer's confirmation

Context

Many agents can overwhelm a provider or tool, and admission order must not depend on worker races or reserve budget for work still waiting.

Decision

Define [policy.limits] entries provider.<name> = n and tool.<name> = n. The step-22 brief overrides the proposed zero sentinel: values must be positive; omit a name for unlimited. Zero, negatives, non-integers, duplicate names and unknown provider/tool key shapes are E0842. Each limit is a runner counting semaphore. Queue waiters FIFO in deterministic merge order (tick, agent id, action index) and reserve the M12 budget at admission, not enqueue. Record queue time as a statistic, not a journal entry; leave the journal schema unchanged.

Consequences

Admission is reproducible and waiting work does not consume a reservation. Implementations must handle cancellation of queued work and release permits correctly; queue duration itself is not deterministic journal content.

Alternatives

Race-based semaphore acquisition makes admission nondeterministic. Reserving at enqueue can hold budget indefinitely for queued work.

M13.3 step 22 implementation (Proposed, pending maintainer)

Batch interaction (M13.1/step 22): drain FIFO admission before the D1 snapshot, not between its transitions; enqueue limited actions in (tick, agent id, action index) order for the next boundary. Reservation-at-admission and journal-failure permit/refund handling are unchanged. Empty policies bypass FIFO/key construction; singletons avoid batch storage/pool dispatch.

Supported TOML forms are [policy.limits.provider] name = 1 and [policy.limits.tool] name = 1, inline provider = { default = 1 } / tool = { echo = 1 }, or quoted dotted keys "tool.echo" = 1 in [policy.limits]. The small TOML reader does not support bare dotted assignments. Names contain ASCII letters, digits, _ or -. Tools are dynamic: unknown names cannot be checked against a static inventory; unknown key shapes are rejected, while an unused well-shaped name is inert. Owner confirmation of this interpretation and the zero change remains open.

limits.hn owns counting semaphores; run.hn owns the FIFO. The driver binds agent_platform::limits.policy_limits' string literal to the selected platform's validated sorted table before type checking, so C and interpreter use identical ordinary code, not a new native. start installs it. A run has one ModelPort; RunState.provider identifies it (empty resolves to default at admission). Host code may install explicit new_limits tables, like explicit budgets; this is not a security boundary.

The current ports are synchronous, so dispatch uses at most one slot even when a configured limit is larger. Requests enqueue in D1 transition merge order; the FIFO drains before the next ready-agent snapshot. This deliberately does not claim parallel external IO or speedup. Each admitted call acquires its key, reserves budget, dispatches/retries, settles actual usage and releases. Budget refusal releases the permit without an intent. Cancellation removes queued calls without reservation or external IO; cancelling a child also removes its queued work. Finish waits for earlier queued calls before returning child grants. Journal failures release permits; failures before port invocation refund the reservation. Queue wait ticks saturate and never enter the journal.

Alternatives: adding asynchronous ports changes the runner contract and is deferred; backend-only native semaphores break interpreter parity. Holding a permit until result delivery would incorrectly throttle already-settled IO.

Unlimited runs skip policy parsing and provider-key construction; the empty provider sentinel preserves provider: str host assignments and removes copied provider bytes, but agent-arena retains +1,600,032 allocated bytes / +0 copied / +32 peak because C transition promotion still allocates an empty string (changing the public field to an option is deferred).