環境変数

CLAUDE_AUTO_BACKGROUND_TASKS

1 に設定すると、長時間実行されるエージェントタスクの自動バックグラウンド化を強制的に有効にする。有効にすると、サブエージェントは約 2 分実行した後にバックグラウンドへ移る。サブエージェントの後ろにファイル編集などのツール呼び出しがキューイングされていた場合、その呼び出しが開始される前にサブエージェントはフォアグラウンドで完了する。Claude Code v2.1.212 以降では、非インタラクティブモードにおける長時間の MCP ツール呼び出しの自動バックグラウンド化も有効になる。

使い方・用途

  • 対話中にセッションをブロックせず長時間実行のサブエージェントを強制的にバックグラウンドへ移したい場合に設定する。
  • 非対話モードで長時間かかる MCP ツール呼び出しを自動的にバックグラウンド化したい場合に設定する (Claude Code v2.1.212 以降)。
英語原文(公式ドキュメントより)

Set to 1 to force-enable automatic backgrounding of long-running agent tasks. When enabled, a subagent moves to the background after running for approximately two minutes. If Claude queued a tool call such as a file edit behind the subagent, the subagent finishes in the foreground before that call starts. Also enables automatic backgrounding of long MCP tool calls in non-interactive mode on Claude Code v2.1.212 or later

関連ドキュメント

関連する変更履歴

v2.1.295(1件)

Fixed
CLAUDE_AUTO_BACKGROUND_TASKS が、サブエージェントの後ろで編集やシェルコマンドが待っている間にそのサブエージェントをバックグラウンドに移動し、その呼び出しがサブエージェントの完了前に開始される問題を修正
英語原文を表示
Fixed CLAUDE_AUTO_BACKGROUND_TASKS moving a subagent to the background while an edit or shell command waited behind it, which started that call before the subagent finished

関連ドキュメント

v2.1.273(1件)

Fixed
SDK および --output-format stream-json の出力で、サブエージェントが実行中にバックグラウンドへ移行された場合(例: CLAUDE_AUTO_BACKGROUND_TASKS による移行)、その残りのメッセージと最終レポートが欠落する問題を修正する
英語原文を表示
Fixed SDK and --output-format stream-json output dropping a subagent's remaining messages and final report after it is moved to the background mid-run (e.g. by CLAUDE_AUTO_BACKGROUND_TASKS)

関連ドキュメント