# 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 goal-state notice path does not use this helper: `project_goal_state`
normalizes separately, to keep `goal_state_notice` off this module's heavy
import chain. It fails closed the same way, degrading an unrecognized status
to `paused` so the notice cannot present a corrupt status as an actionable
goal, and logging the discard. Both read the vocabulary from
`GOAL_STATUS_VALUES` in `goal_state_limits`, so adding a member cannot make it
actionable in one place and unknown in the other.

## 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/6a8d452d70f9bcb978e6bd44831dda093ecbe928/libs/code/deepagents_code/resume_state.py#L173)