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

# coerce • AI Agent SDK

> coerce: Best-effort parse of an external ``scope`` value.

# coerce

Method

> This is a method of the [**StopScope**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/StopScope.md) class in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) module.

Best-effort parse of an external `scope` value.

Accepts a `StopScope`, its string value (case-insensitively), or a
boolean/None `stop_cancels_pending` style flag. Unknown values fall
back to `default` (`TURN` when unset) so a malformed scope never
escalates a stop beyond the caller's intent.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def coerce(value: Any, default: 'StopScope') -> 'StopScope'
```

## Parameters

**value** `Any` *required*

No description available.

**default** `StopScope`

No description available.

### Returns

**Returns** `'StopScope'`

The result of the operation.

## Uses

* `cls`

## Source

> **[View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L8047)**
>
> `praisonaiagents/gateway/protocols.py` at line 8047


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.