# coerce_model_spec

> **Function** in `deepagents_code`

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

Narrow a persisted model-spec channel to a usable value.

Shared by `_rubric_model_spec` and `_model_spec`. `INHERIT_RUBRIC_MODEL`
passes through unchanged; callers compare the result against it themselves.
Every reader of these channels must go through this, so the TUI display and
the grader cannot disagree about a malformed checkpoint value.

## Signature

```python
coerce_model_spec(
    value: object,
) -> str | None
```

## Parameters

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

## Returns

`str | None`

The stripped spec or sentinel, otherwise `None` when the channel is

---

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