# save_recent_model

> **Function** in `deepagents_cli`

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

Update the recently used model in config file.

Writes to `[models].recent` instead of `[models].default`, so that `/model`
switches do not overwrite the user's intentional default.

## Signature

```python
save_recent_model(
    model_spec: str,
    config_path: Path | None = None,
) -> bool
```

## Description

**Note:**

This function does not preserve comments in the config file.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model_spec` | `str` | Yes | The model to save in `provider:model` format. |
| `config_path` | `Path \| None` | No | Path to config file.  Defaults to `~/.deepagents/config.toml`. (default: `None`) |

## Returns

`bool`

True if save succeeded, False if it failed due to I/O errors.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/b710a69b12e49479045eaa54dfb709326473500b/libs/cli/deepagents_cli/model_config.py#L1685)