> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Concurrency Limit Policy • AI Agent SDK

> ConcurrencyLimitPolicy: Config-driven inbound admission policy for a bounded gateway.

# ConcurrencyLimitPolicy

> Defined in the [**protocols**](../modules/protocols) module.

<Badge color="blue">AI Agent</Badge>

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:

* `ADMIT` while `in_flight &lt; max_concurrent_runs`.
* At the ceiling, `QUEUE` while `queued &lt; queue_depth` and the
  `overflow_policy` permits waiting.
* Otherwise the `overflow_policy` decides 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.

A `max_concurrent_runs` of `0` disables admission control entirely
(today's behaviour: every inbound turn is admitted immediately).

Example::

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
ConcurrencyLimitPolicy(max_concurrent_runs=32, queue_depth=128,
                       overflow_policy="reject")
```

## Constructor

<ParamField query="max_concurrent_runs" type="int" required={false} default="0">
  No description available.
</ParamField>

<ParamField query="queue_depth" type="int" required={false} default="0">
  No description available.
</ParamField>

<ParamField query="overflow_policy" type="str" required={false} default="'reject'">
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="enabled()" icon="function" href="../functions/ConcurrencyLimitPolicy-enabled">
    Whether admission control is active (a positive ceiling is set).
  </Card>

  <Card title="decide()" icon="function" href="../functions/ConcurrencyLimitPolicy-decide">
    Instance method.
  </Card>
</CardGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L3224">
  `praisonaiagents/gateway/protocols.py` at line 3224
</Card>
