# save_recent_agent

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/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/0412009c5441bef8d75a427e1da8909e33ab5b56/libs/code/deepagents_code/model_config.py#L3321)