# list_threads

> **Function** in `deepagents_cli`

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

List threads from checkpoints table.

## Signature

```python
list_threads(
    agent_name: str | None = None,
    limit: int = 20,
    include_message_count: bool = False,
    sort_by: str = 'updated',
    branch: str | None = None,
) -> list[ThreadInfo]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent_name` | `str \| None` | No | Optional filter by agent name. (default: `None`) |
| `limit` | `int` | No | Maximum number of threads to return. (default: `20`) |
| `include_message_count` | `bool` | No | Whether to include message counts. (default: `False`) |
| `sort_by` | `str` | No | Sort field — `"updated"` or `"created"`. (default: `'updated'`) |
| `branch` | `str \| None` | No | Optional filter by git branch name. (default: `None`) |

## Returns

`list[ThreadInfo]`

List of `ThreadInfo` dicts with `thread_id`, `agent_name`,
`updated_at`, `created_at`, `latest_checkpoint_id`, `git_branch`,
`cwd`, and optionally `message_count`.

---

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