# save_recent_agent

> **Function** in `deepagents_cli`

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

Update the recently used agent in config file.

Writes to `[agents].recent` so a later bare `deepagents` launch (no
`-a`) can bring the user back to their last agent instead of the
default.

## Signature

```python
save_recent_agent(
    agent_name: str,
    config_path: Path | None = None,
) -> bool
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent_name` | `str` | Yes | The agent directory name (e.g., `'coder'`). |
| `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/64d45f67c86edb4df2ced0e7b82f1a8fd158ec8c/libs/cli/deepagents_cli/model_config.py#L2213)