# touch_recent_model

> **Function** in `deepagents_code`

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

Promote `model_spec` to the front of the recent-models MRU list.

Existing entries for the same spec are moved (not duplicated); the list
is capped at `RECENT_MODELS_LIMIT`. Best-effort: returns `False` on I/O
error so callers can degrade silently — recents are a nice-to-have, not
a correctness requirement.

## Signature

```python
touch_recent_model(
    model_spec: str,
    state_dir: Path | None = None,
) -> bool
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model_spec` | `str` | Yes | The `provider:model` string just selected. |
| `state_dir` | `Path \| None` | No | Override for the state directory (test hook). (default: `None`) |

## Returns

`bool`

`True` on success, `False` on I/O error or invalid spec.

---

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