# probe_writable

> **Function** in `deepagents_code`

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

Create *directory* and prove the process can write files inside it.

`mkdir(exist_ok=True)` only proves the directory exists; it succeeds on a
pre-existing root-owned directory. Creating a file is the only check that
distinguishes "present" from "usable".

The probe uses `tempfile.mkstemp`, not a PID-named file. These directories
are shared across processes, and in the installation-scoped case across
profiles too. PIDs are not unique across containers or PID namespaces: a
colliding name would make a writable directory look unusable and would
delete a peer's live probe. Removal failures are suppressed separately, so
a directory that accepts files but refuses unlinks is still reported as
writable.

## Signature

```python
probe_writable(
    directory: Path,
    *,
    mode: int = 511,
) -> None
```

## Description

**Note:**

`OSError` propagates from `mkdir` or `mkstemp` when the directory
cannot be created or cannot accept a file. Callers select a fallback
location on that error.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `directory` | `Path` | Yes | Directory to create and probe. |
| `mode` | `int` | No | Permission bits for directories this call creates. The default `0o777` defers to the process umask, which is what an ordinary tool directory wants. The state directory is the one that must not, so `harden_state_dir` passes `0o700` and chmods afterwards. (default: `511`) |

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/caaa7e7c12d214afa5cf0a1afed8eb6232aa6f7b/libs/code/deepagents_code/_paths.py#L431)