この章の要点
Key point of this chapter
プログラムの基本的な流れには、順序、条件分岐、反復があります。エージェント・システムは、この反復を使って、観察し、判断し、行動する流れを何度も続けられます。そのため強力ですが、止まらないことや、目的からずれることもあります。
A program's basic flow includes sequence, conditionals, and iteration. Agentic systems use iteration to continue observing, deciding, and acting repeatedly. This makes them powerful, but they can also fail to stop or move away from their goal.
1. ループを理解する三つの部品
1. The three parts needed to understand loops
話者は、エージェント・ループを理解する前に、通常のプログラムにもある三つの制御構造を挙げます。制御構造とは、処理をどの順番で進めるかを決める仕組みです。
Before explaining agent loops, the speaker names three control structures that also appear in ordinary programs. A control structure is a mechanism that determines the order in which processing proceeds.
- 順序(sequence):命令を上から順番に実行します。
- 条件分岐(conditional):条件を調べ、その結果に応じて別の道を選びます。たとえば、入力が正しければ次へ進み、正しくなければエラーを返します。
- 反復(iteration):同じ種類の処理を繰り返します。処理を続ける条件がある間、観察や計算をもう一度行います。
- Sequence: Execute instructions from top to bottom in order.
- Conditional: Check a condition and choose a different path based on the result. For example, proceed if the input is correct and return an error if it is not.
- Iteration: Repeat a kind of processing. While the condition for continuing holds, observe or calculate again.
エージェントは、ただ一度だけ答えを生成するのではありません。順序に沿って状況を読み、条件を確認し、必要なら次の反復へ進みます。この構造によって、エージェントは一回の返答では終わらない仕事を扱えます。
An agent does not only generate an answer once. It reads the situation in sequence, checks conditions, and moves to the next iteration when needed. This structure lets an agent handle work that does not end with one reply.
2. チューリング完全性が意味すること
2. What Turing completeness means
話者は、ベーム=ヤコピーニの結果をこの三つの部品と結び付けます。話者の高いレベルでの説明では、順序、条件分岐、反復がそろうと、言語は**チューリング完全(Turing complete)**になります。これは、計算機が実行できる種類の計算を、その言語で表せるという意味です。
The speaker connects these three parts to the Bohm–Jacopini result. At the high level of the speaker's explanation, when sequence, conditionals, and iteration are all present, a language is Turing complete. This means that the language can express the kinds of computations that a computer can perform.
ここで注意が必要です。チューリング完全であることは、プログラムが正しい、安全、または役に立つことを意味しません。それは、十分に表現力のある計算を組み立てられる、という性質です。間違った条件や終わらない反復も、同じ仕組みで書けます。
This point needs a qualification. Being Turing complete does not mean that a program is correct, safe, or useful. It means that sufficiently expressive computations can be constructed. Incorrect conditions and non-terminating repetitions can be written with the same mechanisms.
3. エージェント・ループが加える力
3. What agent loops add
エージェント・システムでは、反復が「観察する、判断する、行動する」という能力を何度も使えるようにします。たとえば、エージェントが最初の情報だけでは答えられないとします。その場合、ツールを使って情報を取り、結果を見て、次の行動を決められます。これを必要な回数だけ続けられる点が、ループの強みです。
In an agentic system, iteration allows the system to use the ability to observe, decide, and act again and again. Suppose an agent cannot answer using only its initial information. It can then use a tool to obtain information, examine the result, and decide what to do next. The strength of a loop is that this can continue as many times as needed.
補足の例:問い合わせに答えるエージェント
Supplementary example: An agent answering an inquiry
これは説明のための例です。顧客の問い合わせに答えるエージェントがあるとします。エージェントは問い合わせを読み、注文情報を調べ、結果を確認し、必要なら別の情報を調べます。最後に、十分な情報が集まったら返答します。この流れでは、ループがなければ一回の検索で止まります。ループがあれば、観察と行動を交互に続けられます。
This is an example for explanation. Suppose there is an agent that answers customer inquiries. The agent reads the inquiry, looks up order information, checks the result, and looks up other information if necessary. It replies when it has gathered enough information. Without a loop, this flow would stop after one search. With a loop, it can continue alternating between observation and action.
4. 強力さと同じ仕組みから生まれる危険
4. Risks that arise from the same mechanism as the power
しかし、反復は自動的に「必要な回数」を知りません。エージェントが次の観察や行動を要求し続ければ、ループも続きます。話者は、特に次の危険を挙げます。
However, iteration does not automatically know how many repetitions are necessary. If an agent keeps requesting another observation or action, the loop also continues. The speaker highlights the following risks in particular.
- 無限ループ:終了条件に到達しないため、処理が止まりません。エージェントが毎回「もう一度調べる」と判断すれば、同じ種類の処理を永遠に繰り返す可能性があります。
- 会話のドリフト(drift):複数のエージェントが互いに話す場合、会話の方向が少しずつ変わることがあります。最初の目的から離れ、別の話題や行動へ進む状態です。
- トークン数と費用の増加:反復するたびに、質問、返答、ツールの結果などが処理対象になります。その結果、使うトークン数が増え、費用も増える可能性があります。
- Infinite loop: The process does not stop because it never reaches its termination condition. If an agent decides to “look one more time” each time, it may repeat the same kind of processing forever.
- Conversational drift: When multiple agents talk to one another, the direction of the conversation can gradually change. The system moves away from its original goal toward another topic or action.
- Increasing token count and cost: Each iteration adds items such as questions, replies, and tool results to what must be processed. As a result, the number of tokens used and the cost may increase.
これらは同じ問題ではありません。無限ループは終了しない問題です。ドリフトは、終了するかどうかとは別に、目的や方向が変わる問題です。トークンの増加は、長く続く処理を運用する費用の問題です。実際の停止条件や安全策の詳しい設計は、この章の後に出てくるコード例で扱われます。ここでは、話者が危険を示し、まだ完全な対策を示していない点を押さえてください。
These are not the same problem. An infinite loop is a failure to terminate. Drift is a change in the goal or direction, whether or not the process eventually ends. Increasing token use is an operating-cost problem for a process that continues for a long time. The detailed design of actual stop conditions and safety measures appears in the code example that follows this chapter. Here, keep in mind that the speaker points out the risks but has not yet presented a complete solution.
5. 記号的AIへの回帰という見方
5. Viewing this as a return to symbolic AI
話者は、現在のエージェント・ループを、過去の記号的AIやエキスパート・システムとのつながりでも見ています。記号的なシステムは、明示的な手順や規則を使って処理を制御します。現在のシステムにはニューラル言語モデルがありますが、ループによって、規則に沿って処理を進める構造も取り入れています。
The speaker also views today's agent loops as connected to earlier symbolic AI and expert systems. Symbolic systems use explicit procedures and rules to control processing. Today's systems have neural language models, but loops also introduce a structure that advances processing according to control rules.
これは、現在のエージェントが過去のエキスパート・システムとまったく同じだ、という意味ではありません。話者が示すのは、柔軟な言語モデルに、反復や制御の構造が組み合わさることで、記号的AIの考え方をもう一度使う場面が生まれている、という見方です。
This does not mean that current agents are exactly the same as earlier expert systems. The speaker's view is that combining a flexible language model with repetition and control structures creates a new situation in which ideas from symbolic AI are used again.
エージェント・ループの強みは、観察、判断、行動を繰り返して、一度の生成を超える仕事ができることです。その基礎には、順序、条件分岐、反復という制御構造があります。一方で、ループは無限に続いたり、会話を目的からずらしたり、トークン数と費用を増やしたりします。したがって、チューリング完全性という表現力と、実際に正しく安全に動くことは分けて考える必要があります。次の章では、このループがClaudeエージェントのツール呼び出しとしてどのように書かれるかを見ます。
The strength of an agent loop is that it can repeat observation, decision, and action to do more than a single generation can do. Its foundation is the control structures of sequence, conditionals, and iteration. At the same time, a loop can continue forever, move a conversation away from its goal, or increase token use and cost. Therefore, computational expressiveness described by Turing completeness must be considered separately from actually operating correctly and safely. The next chapter looks at how this loop is written as Claude-agent tool use.