> ## Documentation Index
> Fetch the complete documentation index at: https://modal-devin.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Timeouts

> Set session duration without interrupting startup, recovery, or cleanup.

The main timeout users normally choose is the maximum Devin worker duration:

```text theme={null}
MODAL_DEVIN_SESSION_TIMEOUT_SECONDS=3600
```

The default is 12 hours. Set a shorter value when cost containment matters more than
allowing long-running Devin sessions to remain connected.

## Why the Modal timeout is longer

Stopping the worker begins the final phase of the session lifecycle. The Sandbox may still
need time to start, confirm the final Devin state, preserve a filesystem, and clean up.

The generated application therefore uses a derived function timeout:

```python theme={null}
@app.function(timeout=worker.session_function_timeout_seconds, ...)
```

Keep this property in the decorator. It automatically stays aligned when session or
recovery timing changes.

## Tune safely

1. Set `session_timeout_seconds` for the longest worker run you want to allow, then
   keep the generated function timeout property unchanged.
2. Change readiness or snapshot timing only when logs identify that specific phase
   as the bottleneck.
3. Change API retry timing only for a known network or upstream reliability need.

<Warning>
  Omit `timeout=` from `run_session()`. An independent Sandbox timeout can interrupt
  recovery or cleanup.
</Warning>

For every available advanced control and its default, see the
[settings reference](/reference/settings).
