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

# Classify Finish Reason • AI Agent SDK

> classify_finish_reason: Map a provider ``finish_reason``/refusal signal to a terminal reason.

# classify\_finish\_reason

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

> This function is defined in the [**run\_outcome**](../modules/run_outcome) module.

Map a provider `finish_reason`/refusal signal to a terminal reason.

Returns one of `content_filtered | refused | length_truncated` when the
provider blocked/refused/truncated the turn, or `None` for a normal stop
(`None`/`"stop"`) or any unrecognised value — so unknown finish reasons
behave exactly as today. Additive and zero-cost on the success path.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def classify_finish_reason(finish_reason: Any, refusal: Any) -> Any
```

## Parameters

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

<ParamField query="refusal" type="Any" required={false}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="Any">
  The result of the operation.
</ResponseField>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/run_outcome.py#L116">
  `praisonaiagents/agent/run_outcome.py` at line 116
</Card>
