Resolve the idle-timeout from ``CLAUDE_STREAM_IDLE_TIMEOUT_MS`` env var. Falls back to ``DEFAULT_STREAM_IDLE_TIMEOUT_S`` (90s) when the env var is unset or malformed. Mirrors TS ``claude.ts:1922``.
()
| 44 | |
| 45 | |
| 46 | def stream_idle_timeout_seconds() -> float: |
| 47 | """Resolve the idle-timeout from ``CLAUDE_STREAM_IDLE_TIMEOUT_MS`` env var. |
| 48 | |
| 49 | Falls back to ``DEFAULT_STREAM_IDLE_TIMEOUT_S`` (90s) when the env var |
| 50 | is unset or malformed. Mirrors TS ``claude.ts:1922``. |
| 51 | """ |
| 52 | raw = os.environ.get("CLAUDE_STREAM_IDLE_TIMEOUT_MS", "").strip() |
| 53 | if not raw: |
| 54 | return DEFAULT_STREAM_IDLE_TIMEOUT_S |
| 55 | try: |
| 56 | ms = int(raw) |
| 57 | except (TypeError, ValueError): |
| 58 | return DEFAULT_STREAM_IDLE_TIMEOUT_S |
| 59 | if ms <= 0: |
| 60 | return DEFAULT_STREAM_IDLE_TIMEOUT_S |
| 61 | return ms / 1000.0 |
| 62 | |
| 63 | |
| 64 | class StreamIdleTimeout(Exception): |