> ## 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.

# Configure runtime behavior

> Change polling, session duration, snapshot retention, and logging.

The generated application calls `Worker.from_env()`, so you can set runtime policy
with `MODAL_DEVIN_*` environment variables through your preferred Modal configuration
mechanism.

## Common settings

| Goal                                 | Environment variable                     |   Default |
| ------------------------------------ | ---------------------------------------- | --------: |
| Check the outpost more or less often | `MODAL_DEVIN_SCHEDULER_INTERVAL_SECONDS` |      `30` |
| Allow longer or shorter sessions     | `MODAL_DEVIN_SESSION_TIMEOUT_SECONDS`    |   `43200` |
| Change resumable-workspace retention | `MODAL_DEVIN_SNAPSHOT_TTL_SECONDS`       | `2592000` |
| Increase log detail                  | `MODAL_DEVIN_LOG_LEVEL`                  |    `INFO` |

For example:

```text theme={null}
MODAL_DEVIN_SCHEDULER_INTERVAL_SECONDS=60
MODAL_DEVIN_SESSION_TIMEOUT_SECONDS=3600
MODAL_DEVIN_SNAPSHOT_TTL_SECONDS=none
MODAL_DEVIN_LOG_LEVEL=DEBUG
```

`none` and `null`, in any letter case, both mean indefinite snapshot retention.

## Trace sessions with OpenTelemetry

The scheduler and session runtimes include Pydantic Logfire instrumentation. Every
scheduler poll creates a trace, and each dispatched session continues that trace
through claim acquisition, Sandbox startup, the Devin worker process,
final status handling, and claim release. The handoff uses a W3C OpenTelemetry trace
carrier stored with the short-lived dispatch lease, so it crosses the remote Modal
function boundary without changing the generated function signature.

To send traces to Pydantic Logfire, add `LOGFIRE_TOKEN` to the Modal Secret attached
to both generated functions. The existing generated Secret reference can contain both
credentials:

```text theme={null}
DEVIN_OUTPOSTS_TOKEN=...
LOGFIRE_TOKEN=...
LOGFIRE_ENVIRONMENT=production
```

Logfire only sends to its hosted service when a token is present. To use another
OpenTelemetry-compatible backend, omit `LOGFIRE_TOKEN` and configure its OTLP/HTTP
endpoint instead:

```text theme={null}
OTEL_EXPORTER_OTLP_ENDPOINT=https://otel-collector.example.com
```

The service name is the worker's generated Modal app name. Useful span attributes
include `devin.session.id`, `modal_devin.outpost.id`, `modal_devin.worker.name`, and
`modal.function.name`.

## Configure in Python

Use `WorkerSettings` when configuration belongs in version control:

```python theme={null}
from modal_devin import Worker, WorkerSettings

settings = WorkerSettings(
    scheduler_interval_seconds=60,
    session_timeout_seconds=3600,
    snapshot_ttl_seconds=None,
    log_level="INFO",
)

worker = Worker(
    "my-outpost",
    outpost_id="outpost_env-...",
    settings=settings,
)
```

Use the constructor directly when settings are explicit in code, as above. Use
`Worker.from_env()` instead when settings should come from `MODAL_DEVIN_*`
environment variables; it has no `settings` parameter, so the two approaches apply to
separate `Worker` instances rather than combining on one.

## Preserve the generated timeout

Keep the session function decorator tied to the generated property:

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

The property leaves enough time for startup, recovery, and cleanup when the session
duration changes.

## Choose snapshot retention

Modal's [Sandbox snapshot guide](https://modal.com/docs/guide/sandbox-snapshots)
documents filesystem snapshot retention and expiration behavior.

* Use the default 30 days for bounded recovery storage.
* Set a positive number of seconds for another finite duration.
* Use `None` in Python or `none` in the environment for indefinite retention.

Keep the deployment active while relying on resumability, and remove persistent
resources when an outpost is retired.

<Note>
  Additional readiness, API, retry, and snapshot timing controls exist for unusual
  deployments and support-guided troubleshooting. See the
  [settings reference](/reference/settings) before changing them.
</Note>
