演習 › 全問
問題 Q1-04
4 / 120分野1・エージェントループの設計
まだ解いていません。
配送追跡のエージェントで、あるツールがタイムアウトした。ループの実装として最も適切なものはどれか。
正解は B
- A呼び出しに対応する結果が無い履歴は、形式として不正になります。失敗でも結果は必ず返します。
- B正解です。失敗は、失敗の印を付けて返します。モデルが同じ呼び出しを繰り返す恐れがあるので、再試行の回数には上限を置きます。
- C1回の失敗で全体を止めるのは過剰です。失敗の中身をモデルに見せれば、別の方法を選べることがあります。
- D空の成功は、失敗を隠すことになります。モデルは「該当なし」と誤解して、誤った結論を出しかねません。
考え方:失敗も結果として返す(失敗の印つき)。再試行は上限つき。
出典:Handle tool calls
When a client tool fails or a call is invalid, send a tool_result block with is_error set to true.https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-t…(取得 2026-11-20)
出典:Handle tool calls
Claude might then call the tool again with a new tool_use block, so limit how many retries your loop allows.https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-t…(取得 2026-11-20)
出典:Handle tool calls
Add a user message with one tool_result block for each tool_use block in that content, even if the tool failed.https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-t…(取得 2026-11-20)