Skip to content
Maliyet ve Performans Basit

Güvenlik İçin Tur Sınırlama

Otomasyondaki kontrolsüz döngüleri önlemek için --max-turns ile ajanlı konuşma turlarını sınırlayın

Komut

$ "color:#7C5CFC">claude -p "Refactor auth.py to use JWT" \
    "color:#d97757">--max-turns 10 \
    "color:#d97757">--max-budget-usd 2.00 \
    "color:#d97757">--output-format json

Yanıt

{
  "type": "result",
  "subtype": "error_max_turns",
  "is_error": false,
  "result": "Partial progress: extracted token validation...",
  "total_cost_usd": 1.42,
  "num_turns": 10
}

Ayrıştırma Kodu

059669">">const data = JSON.parse(output);
059669">">if (data.subtype === 059669059669">">'error_max_turns') {
  059669">">console.warn(059669">`Hit turn cap after ${data.num_turns} turns ($${data.total_cost_usd})`);
  059669">">// Resume with --continue to pick up where it left off
} 059669">">else {
  console.log(data.result);
}

Tuzaklar

! --max-turns konuşma turlarını sınırlar, bir tur İÇİNDEKİ araç çağrılarını DEĞİL — tek bir tur birden fazla araç çağırabilir
! Yalnızca --print modunda çalışır — etkileşimli oturumlarda yok sayılır
! Çifte güvenlik için --max-budget-usd ile birleştirin: hem turlar HEM DE maliyet

İlgili Tarifler