> ## 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.

# Plan Pressure Evictions • AI Agent SDK

> plan_pressure_evictions: Return the ``session_id``s to soft-evict, coldest (LRU) first.

# plan\_pressure\_evictions

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**protocols**](../modules/protocols) module.

Return the `session_id`s to soft-evict, coldest (LRU) first.

A pure planner: it takes the container memory *budget* (typically the
cgroup limit), the current anonymous `rss_mb` and the warm-cache
registry, and names the coldest rebuildable caches to shed until RSS is
back within `headroom_ratio` of the budget. It never touches the event
loop or the caches themselves — the gateway enacts the returned plan.

Guards (a victim is *skipped*, never evicted, when):

* `in_flight` is `True` — an executing turn must not be aborted, or
* `flushed` is `False` — an unflushed transcript is not yet rebuildable
  from the store, so evicting it would lose data.

Returns an empty list when RSS is within budget, the budget is unknown
(`None`/`&lt;= 0`), or nothing evictable remains — so a host that can't
report a cgroup limit simply never soft-evicts (legacy behaviour).

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def plan_pressure_evictions(budget_mb: Optional[float], rss_mb: float, warm_sessions: Sequence[WarmSession]) -> List[str]
```

## Parameters

<ParamField query="budget_mb" type="Optional[float]" required={true}>
  No description available.
</ParamField>

<ParamField query="rss_mb" type="float" required={true}>
  No description available.
</ParamField>

<ParamField query="warm_sessions" type="Sequence[WarmSession]" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="List[str]">
  The result of the operation.
</ResponseField>

## Uses

* `math.isfinite`
* `evictable.sort`

## Source

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