# coerce_goal_status

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/resume_state/coerce_goal_status)

Narrow a persisted goal-status value to a known `GoalStatus`.

A corrupt or forward-version checkpoint can carry an unexpected status
string (or a non-string). Coercing to `None` rather than passing the raw
value through keeps the `GoalStatus` `Literal` load-bearing on the read
path, so an unknown status is treated as "no goal status" instead of a
silently active goal. Resume/restore callers should log the discard
separately so it is surfaced rather than dropped; the model-read path
(`_goal_snapshot`) intentionally treats an unknown status as `active`
without logging.

## Signature

```python
coerce_goal_status(
    value: object,
) -> GoalStatus | None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `value` | `object` | Yes | Raw value read from checkpoint state. |

## Returns

`GoalStatus | None`

The value when it is a recognized `GoalStatus`, otherwise `None`.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/7794b61a6e76230e8c7a49bdce808b3728305914/libs/code/deepagents_code/resume_state.py#L132)