環境変数
MAX_STRUCTURED_OUTPUT_RETRIES
-p フラグによる非対話モードで、モデルのレスポンスが --json-schema に対する検証に失敗した場合に Claude Code が許容する試行回数。有効な出力なしにその回数失敗すると、実行は失敗する。ワークフローサブエージェントの構造化出力が検証に失敗した場合にも同じ上限が適用される。デフォルトは5で、最初の試行に4回の再試行を加えた回数。
使い方・用途
- p フラグ付きの非対話モードで --json-schema に対するモデル出力の検証失敗が繰り返される場合に、再試行回数を調整して実行を安定させたいとき
- workflow サブエージェントの構造化出力が検証を通らず呼び出しが失敗する場合に、許容する試行回数を変更したいとき
英語原文(公式ドキュメントより)
Number of attempts Claude Code allows when the model's response fails validation against the --json-schema in non-interactive mode with the -p flag; after that many failed attempts with no valid output, the run fails. The same cap applies when a workflow subagent's structured output fails validation. Defaults to 5, a first attempt plus four retries