# format_path

> **Function** in `deepagents_code`

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

Format a filesystem path for display.

Paths under the user's home directory are shown relative to `~`.
All other paths are returned as-is.

## Signature

```python
format_path(
    path: str | None,
) -> str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `path` | `str \| None` | Yes | Absolute filesystem path, or `None`. |

## Returns

`str`

Formatted path string, or empty string if path is falsy.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/0412009c5441bef8d75a427e1da8909e33ab5b56/libs/code/deepagents_code/sessions.py#L238)