環境変数

API_FORCE_IDLE_TIMEOUT

ストリーミングレスポンスでデータが届かない場合に、5分で処理を中断するアイドルタイムアウト設定を上書きします。

使い方・用途

  • ゲートウェイの遅延やローカルモデルの推論が非常に遅く、レスポンスの合間が5分を超えてしまう場合に、タイムアウトを無効化(0を設定)してセッションが切れるのを防ぎます。
  • ネットワークの不調でストリームが停止したままフリーズするのを防ぐため、標準でタイムアウトが有効でないプロバイダーに対しても強制的に有効化(1を設定)できます。
  • Vertex AIやBedrockなどの環境で、応答が途絶えた際に適切にエラーとして中断・復帰させることで、レジリエンスを向上させます。
英語原文(公式ドキュメントより)

Override the 5-minute idle timeout that aborts a streaming model response when no bytes arrive. Set to 0 to disable the timeout, for example when a slow gateway or local model pauses longer than 5 minutes between chunks. Set to 1 to keep the timeout on every provider. When unset, the timeout is inactive on direct Anthropic API and Claude Platform on AWS connections, where Claude Code's own byte-level stream watchdog runs, and active on every other provider, including Vertex AI, Foundry, Mantle, Bedrock, and gateway connections, so a stalled stream aborts instead of hanging. As of v2.1.169

関連する変更履歴

v2.1.169(1件)

Changed
Google Vertex AI および Microsoft Foundry において、5 分間のアイドルタイムアウトを復活させました。応答が停止したストリームを無限に待ち続けることを防ぎます。
英語原文を表示
Restored a default 5-minute idle timeout on Vertex/Foundry so a stalled stream aborts instead of hanging indefinitely; set API_FORCE_IDLE_TIMEOUT=0 to opt out

変更前

ネットワークやプロバイダー側の問題で応答が途絶えた際、Claude Code が固まったままになり、手動で強制終了する必要がありました。

変更後

応答がない場合は 5 分で自動的に切断・エラー復帰するため、ハングアップ状態を回避できます。必要に応じて API_FORCE_IDLE_TIMEOUT=0 で無効化も可能です。

ユーザーへの恩恵

クラウドプロバイダー経由での利用時に、接続の不安定さによる作業の中断時間を最小限に抑えられます。

関連ドキュメント