İçeriğe geç
Tüm roadmap'e dön
topiccore

ReAct Loop'u Derin İnceleme

Thought → Action → Observation döngüsünün her satırı. Tüm modern agent'ların atası.

4 saat2 kaynak1 önkoşul

ReAct (Yao et al., 2022) = Reasoning + Acting. Her turn'de model:

  1. Thought: — durumu analiz et, ne yapılması gerek?
  2. Action: — hangi tool, hangi parametrelerle?
  3. Observation: — tool sonucu (model'in input'una eklenir)
  4. Hedef tamamlandı mı? Hayır → 1'e dön.

Modern API'lerde: thought/action/observation explicit etiketle yazılmıyor — function calling native. Ama kavramsal model aynı: model bir tool çağırır, sen execute edersin, result'u dönersin, model tekrar düşünür.

Implementation iskelet (Python):

while not done and i < MAX_ITER:
    response = llm.create(messages, tools=tools)
    if response.stop_reason == "end_turn":
        done = True
    elif response.stop_reason == "tool_use":
        results = [execute(call) for call in response.tool_calls]
        messages.append(assistant_msg)
        messages.append(tool_results_msg)
    i += 1

Best practices: her tool call'dan ÖNCE model'i bir cümle thinking yapmaya zorla ("Açıklamadan tool çağırma"). Bu trajectory readability'sini ve debug'ı kolaylaştırır.

Ne kazanırsın?

Sıfırdan, 50 satır kodla çalışan bir ReAct agent yazabilirsin.

Önce bunları bil

Kaynaklar(2)