ConcurrencyLimitPolicy
Defined in the protocols module.AI Agent Config-driven inbound admission policy for a bounded gateway. The default referenced by
gateway.max_concurrent_runs /
gateway.queue_depth / gateway.overflow_policy in gateway.yaml
and the BotOS(..., max_concurrent_runs=...) Python surface. It is
intentionally minimal and dependency-free so the decision lives in core and
is provable in isolation; the wrapper owns the side effects (acquire a
semaphore slot, enqueue/dequeue, return a busy ack).
The decision is:
ADMITwhilein_flight < max_concurrent_runs.- At the ceiling,
QUEUEwhilequeued < queue_depthand theoverflow_policypermits waiting. - Otherwise the
overflow_policydecides the shed behaviour:"reject"→ :attr:AdmissionDecision.REJECT(busy ack)."queue"→ :attr:AdmissionDecision.QUEUE(block beyond the declared depth — for callers that prefer unbounded waiting to shedding; the wrapper still bounds the actual queue object)."shed_oldest"→ :attr:AdmissionDecision.QUEUE; the wrapper drops the oldest waiter to make room rather than rejecting the new arrival.
max_concurrent_runs of 0 disables admission control entirely
(today’s behaviour: every inbound turn is admitted immediately).
Example::
Constructor
int
default:"0"
No description available.
int
default:"0"
No description available.
str
default:"'reject'"
No description available.
Methods
enabled()
Whether admission control is active (a positive ceiling is set).
decide()
Instance method.
Source
View on GitHub
praisonaiagents/gateway/protocols.py at line 3224
