coerce • AI Agent SDK

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

coerce

Method

</div>

This is a method of the StopScope class in the protocols 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
def coerce(value: Any, default: 'StopScope') -> 'StopScope'

Parameters

ParamField Any

No description available.

ParamField StopScope

No description available.

Returns

ResponseField 'StopScope'

The result of the operation.

Uses

  • cls

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 8186