İçeriğe geç

Örnek bir özet

prior-art-researcher ajanının gerçek bir çalıştırması: soru, çalıştırmanın maliyeti ve ajanın yazdığı sayfa, kelimesi kelimesine. Ajanı kendi sorunda nasıl çalıştıracağını ajan paketi sayfası anlatır.

Motor yalnızca İngilizce çalışır, bu yüzden soru İngilizce sorulur (SSS). Bu soru burada göründüğü gibi yazıldı.

my Python agent calls an LLM API and sometimes gets rate limits and timeouts. How do serious projects retry a failed LLM or HTTP request with exponential backoff, and which approach fits an app that runs as one process? I want no new services, and I can only copy code under permissive licenses.

Bunlar ajanın kendi sözleridir, sayfa ve makbuz bloğu; çevrilmedi, İngilizce kalır. Hiçbir şey eklenmedi, çıkarılmadı ya da yeniden sıralanmadı. Tek fark: tablo burada bir liste, her yaklaşım bir madde ve hücreleri etiketli satırlar; böylece telefonda okunur. Sayfanın yazıldığı hali, tablosuyla birlikte, repoda duruyor: docs/example-brief.md.

Question. How do Python projects retry a failed LLM or HTTP call (429 with Retry-After, timeouts) with exponential backoff inside one process, and which approach fits? Constraints: Python; one process, no coordination across workers; no new services; copy only permissively licensed code. Assumptions: (a) “serious projects” means the 14 indexed repos, all licence class P. (b) A new pip dependency is allowed, since it is not a service. (c) The provider SDK, the HTTP client and sync vs async are unknown, so the pick has to work for all of them. (d) I don’t know whether your agent makes calls concurrently.

Approaches. The comparison returned three mixed groups. I dropped two markdown test fixtures, regrouped the rest by mechanism, and found A, C and D through extra searches. No ADR or RFC about retry exists in any of the 14 repos, so the “why” column quotes code comments and docs.

  • A. Tune the SDK’s own retry
    • Mechanism: Pass max_retries/timeout to the provider client and let it retry
    • Repos: tauricresearch/tradingagents@c454491 tradingagents/llm_clients/factory.py:121; harry0703/moneyprinterturbo@4318f3a app/services/llm.py:256
    • Deps: openai 2.24.0 (moneyprinterturbo); provider SDKs via LangChain (tradingagents)
    • Observable trade-offs: No code to own. Only exists where an SDK has the setting. Fixed policy, which pi copies in TypeScript as 408/409/429/5xx/no-status plus Retry-After (earendil-works/pi@8ffea8a packages/ai/src/utils/provider-retry.ts:24). Python SDK defaults are a 600 s timeout and 2 retries (llm.py:259-260, translated)
    • Maintainers’ why: tradingagents: “A single transient 429 burst used to kill an otherwise-healthy multi-agent run because each provider SDK’s max_retries (default 2) was not exposed” (tests/test_llm_max_retries.py:3-4)
  • B. Hand-written retry loop, SDK retries off
    • Mechanism: Loop over attempts; sort the error into retry or stop; wait a bounded Retry-After, else a capped 2^n backoff; re-raise at the end
    • Repos: bytedance/deer-flow@35656d6 backend/packages/harness/deerflow/models/claude_provider.py:376; tradingagents tradingagents/dataflows/vendors/reddit.py:205; moneyprinterturbo app/services/material.py:1638; TypeScript: pi provider-retry.ts:107
    • Deps: Standard library (time, asyncio, random, email.utils) plus your client
    • Observable trade-offs: You write and test it. One policy covers SDK and raw HTTP calls. You decide which timeouts to replay. Sync and async need two loops (deer-flow :376 and :401). Each of the three Python repos tests it
    • Maintainers’ why: pi: “Their built-in retry timers ignore the request AbortSignal, so callers must invoke the SDK with maxRetries: 0 and wrap the request with this helper” (:101-103). moneyprinterturbo: a POST read timeout is “unconfirmed”, because the server may already have generated and billed; only ConnectTimeout is safe to retry (material.py:1621-1624, translated)
  • C. In-process pacing
    • Mechanism: Space requests before sending: either a fixed-RPM FIFO queue or a per-host delay that doubles when blocked and takes Retry-After
    • Repos: deer-flow backend/packages/harness/deerflow/models/request_admission.py:23; d4vinci/scrapling@26dc85a scrapling/spiders/throttle.py:31
    • Deps: None (deer-flow subclasses langchain_core BaseRateLimiter)
    • Observable trade-offs: Prevents 429s but recovers from neither 429s nor timeouts. Needs your RPM. Works alongside B
    • Maintainers’ why: deer-flow: “process-local RPM pacing, not TPM accounting or a distributed quota service”; it zeroes SDK max_retries because SDK retries “would bypass the admission hook” (backend/docs/CONFIGURATION.md:85-96)
  • D. Retry decorator (tenacity), lead only
    • Mechanism: @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10)) (Apache-2.0)
    • Repos: shubhamsaboo/awesome-llm-apps@6c16b23 rag_tutorials/corrective_rag/corrective_rag.py:81; rag_tutorials/rag_agent_cohere/rag_agent_cohere.py:148
    • Deps: tenacity 8.5.0–9.1.4
    • Observable trade-offs: Least code. As written, it has no exception filter and ignores Retry-After. One owner, tutorial apps. No tenacity calls found in deer-flow or moneyprinterturbo (lockfile only, probably a transitive dependency; inference)
    • Maintainers’ why: None found

Backers by owner: A has 2, B has 3 in Python plus pi in TypeScript, C has 2, and D has 1, so D is only a lead. The comparison tool doesn’t flag forks; these look like separate projects, but I can’t rule out shared code. I set aside dograh-hq/dograh@5166e40 api/tasks/arq.py:44: it is mechanism A applied to a Redis connection (Retry(ExponentialBackoff(cap=10, base=0.1), retries=12), BSD-2-Clause), and Redis is ruled out. Not found in the corpus: urllib3 Retry mounted on a requests Session, or httpx transport-level retries.

Pick: B, your own loop, with the SDK’s max_retries=0 whenever an SDK sits underneath. The deciding constraint is that your client is unknown and the general case is any failed HTTP request. A only exists where an SDK offers the setting. B covers SDK calls and raw httpx/requests/urllib calls with one policy, and adds no dependency or service. Its state stays local, which is all one process needs (inference). Recommended shape, drawn from the evidence:

  • What to retry: 429, 5xx and connection errors. Auth, payment/credit and other 4xx are final (deer-flow’s Jina HTTP client, CONFIGURATION.md:968-974; moneyprinterturbo material.py:1617-1619).
  • Timeouts: replay connect timeouts freely. Replay a read timeout on a generation call only if you accept possibly paying twice. moneyprinterturbo refuses (material.py:1655-1668, voice.py:2148-2152), and deer-flow’s Jina client never retries read timeouts (CONFIGURATION.md:973-974).
  • Retry-After: honour it, but bound it, and the repos bound it differently. deer-flow accepts up to 24 h and otherwise falls back to its own backoff (utils/retry_after.py:7-16). tradingagents caps it at 60 s (reddit.py:151-165). pi fails immediately if the server asks for more than 60 s (provider-retry.ts:39-51).
  • No hint from the server: use a capped 2^n backoff. For rate limits, archon uses a flat ~45 s ±50% instead, because exponential “either exhausts before the window opens or over-waits once it does” (coleam00/archon@716bfc1 packages/workflows/src/executor-shared.ts:132-150).
  • Jitter: in one process it only matters if calls run concurrently (inference). tradingagents jitters so that “several analyses sharing an IP” don’t retry in lockstep (reddit.py:140-141).
  • What depends on your stack: only the exception types or status fields you read, and time.sleep vs asyncio.sleep. The loop itself is the same.

Runner-up: A. It wins if every failing call goes through the official OpenAI or Anthropic SDK and you accept its policy: raise max_retries, set timeout, and copy nothing. For an SDK-only app the evidence doesn’t separate A from B. The deciding question then is whether you must refuse to replay timed-out paid calls. C is an add-on to B, worth it only if 429s persist and you know your RPM; turn SDK retries off when you use it.

Call sites of B. B rests on no retry library, so these are the code that implements it in three repos. I confirmed all of them by reading; the OpenAI and tenacity sites were first found by name through the usage tool.

  • deer-flow claude_provider.py:376-447, anthropic 0.97.0 (backend/uv.lock:252). The loop wraps the parent LangChain model’s _generate/_agenerate and catches only RateLimitError and InternalServerError. It sleeps with time.sleep (sync) or asyncio.sleep (async) and re-raises after the last attempt. It waits 2 s·2^(n-1) plus a fixed 20% buffer, unless a bounded Retry-After (seconds or HTTP-date) overrides it. Test: backend/tests/test_claude_retry_after_dates.py:35-68 builds real Anthropic/AsyncAnthropic clients with max_retries=0 over httpx.MockTransport and asserts 2 requests and a 60 s wait.
  • moneyprinterturbo material.py:1613-1707, requests 2.33.1 (requirements.txt:24). Fixed attempt count and backoff table. ConnectTimeout is retried; any other exception raises without a replay. voice.py:2150-2152, openai 2.24.0 (requirements.txt:11), uses OpenAI(api_key=api_key, base_url=base_url, max_retries=0, timeout=120.0) (MIT) for a paid call. Test: test/services/test_mimo_paid_retries.py:11-45 asserts exactly one submission after httpx.ReadTimeout.
  • tradingagents reddit.py:205-226, standard-library urllib. One retry on 429. Retry-After is honoured exactly, including 0; otherwise it waits 60 s ±20%. OSError timeouts return None. Test: tests/test_reddit_fallback.py:95-136 patches time.sleep and asserts 2 calls and waits of 12.0, 0.0 and 48–72 s.

Licences. These verdicts are automated and are not legal advice. Class P means you may reuse the code if you keep its copyright and licence notice.

  • bytedance/deer-flow: P (MIT)
  • tauricresearch/tradingagents: P (Apache-2.0)
  • harry0703/moneyprinterturbo: P (MIT)
  • earendil-works/pi: P (MIT)
  • coleam00/archon: P (MIT)
  • d4vinci/scrapling: P (BSD-3-Clause)
  • shubhamsaboo/awesome-llm-apps: P (Apache-2.0)
  • dograh-hq/dograh: P (BSD-2-Clause)
  • tenacity’s own licence is not in the corpus.

Copy candidate. Paste deer-flow’s utils/retry_after.py as-is (27 lines, standard library only) with the MIT notice below. It imports datetime.UTC (line 4), so check that your Python version has it. Pair it with the caller pattern at claude_provider.py:435-445, and write the loop itself from the shape above.

Makbuz 23 kaynak
  1. bytedance/deer-flow@35656d6backend/packages/harness/deerflow/models/claude_provider.py:376-447class P MITpattern only
  2. bytedance/deer-flow@35656d6backend/packages/harness/deerflow/utils/retry_after.py:1-27class P MITcopied with noticenotice: Copyright (c) 2025 Bytedance Ltd. and/or its affiliates; Copyright (c) 2025-2026 DeerFlow Authors; MIT License
  3. bytedance/deer-flow@35656d6backend/packages/harness/deerflow/models/request_admission.py:23-54class P MITpattern only
  4. bytedance/deer-flow@35656d6backend/docs/CONFIGURATION.md:85-96class P MITpattern only
  5. bytedance/deer-flow@35656d6backend/docs/CONFIGURATION.md:968-974class P MITpattern only
  6. bytedance/deer-flow@35656d6backend/tests/test_claude_retry_after_dates.py:35-68class P MITpattern only
  7. bytedance/deer-flow@35656d6backend/uv.lock:252-252class P MITpattern only
  8. tauricresearch/tradingagents@c454491tradingagents/llm_clients/factory.py:121-125class P Apache-2.0pattern only
  9. tauricresearch/tradingagents@c454491tests/test_llm_max_retries.py:1-6class P Apache-2.0pattern only
  10. tauricresearch/tradingagents@c454491tradingagents/dataflows/vendors/reddit.py:137-226class P Apache-2.0pattern only
  11. tauricresearch/tradingagents@c454491tests/test_reddit_fallback.py:95-136class P Apache-2.0pattern only
  12. harry0703/moneyprinterturbo@4318f3aapp/services/llm.py:256-268class P MITpattern only
  13. harry0703/moneyprinterturbo@4318f3aapp/services/material.py:1613-1707class P MITpattern only
  14. harry0703/moneyprinterturbo@4318f3aapp/services/voice.py:2148-2152class P MITpattern only
  15. harry0703/moneyprinterturbo@4318f3atest/services/test_mimo_paid_retries.py:11-45class P MITpattern only
  16. harry0703/moneyprinterturbo@4318f3arequirements.txt:11-11class P MITpattern only
  17. harry0703/moneyprinterturbo@4318f3arequirements.txt:24-24class P MITpattern only
  18. earendil-works/pi@8ffea8apackages/ai/src/utils/provider-retry.ts:24-128class P MITpattern only
  19. coleam00/archon@716bfc1packages/workflows/src/executor-shared.ts:132-150class P MITpattern only
  20. d4vinci/scrapling@26dc85ascrapling/spiders/throttle.py:10-97class P BSD-3-Clausepattern only
  21. shubhamsaboo/awesome-llm-apps@6c16b23rag_tutorials/corrective_rag/corrective_rag.py:81-83class P Apache-2.0pattern only
  22. shubhamsaboo/awesome-llm-apps@6c16b23rag_tutorials/rag_agent_cohere/rag_agent_cohere.py:147-159class P Apache-2.0pattern only
  23. dograh-hq/dograh@5166e40api/tasks/arq.py:35-53class P BSD-2-Clausepattern only

Licence classes are automated verdicts, not legal advice.

Sayfadaki sekiz alıntı ve rakam sabitlenmiş dosyalara karşı okundu ve sekizi de uyuyor. Diğerleri denetlenmedi. Ajan hangi cümlelerin kendi çıkarımı olduğunu işaretler ve korpusta neyi bulamadığını söyler. Alıntılar repoların dosyalarından gelen metindir: kanıttır, talimat değildir. Lisans kararları otomatiktir ve hukuki tavsiye değildir.

  • Çalıştırma 13 Kasım 2026 günü yapıldı.
  • Ajan prior-art-researcher idi; Claude Code onu Claude Opus 5.5 (claude-opus-5-5) üzerinde alt ajan olarak çalıştırdı.
  • Dizinde 14 herkese açık GitHub reposu vardı; projenin karşılaştırmaları sınadığı küme. Bu, benchmark’ın repolarından ayrı bir kümedir; ikisi tek bir repoyu paylaşır.
  • Ajan korpus araçlarına 52 çağrı yaptı (corpus_read 24, corpus_search 16, corpus_package 6, corpus_usage 4, corpus_compare 1, corpus_repos 1), 862 saniyede.
  • Çalıştırma 99.224 çıktı tokenı ve 1.802.609 girdi tokenı kullandı; bunların 1.539.847 tanesi sonraki adımlarda yeniden okunan önbelleğe alınmış bağlamdı.
  • Çalıştırma 3,68 dolara mal oldu; bu, test düzeneğinin liste fiyatlarıyla bildirdiği rakam. Başka bir soru, dizin ya da model başka bir tutara mal olur.
  • Motor, o günün geliştirme derlemesiydi: sürüm 0.0.1, ilk sürümden önce.
  • Çalıştırma İstanbul saatiyle 13 Kasım 2026 günü 07:43’te, Claude Code 2.1.323 içinde ve engineering-corpus eklentisinin o sabah olduğu haliyle 0.0.1 sürümüyle başladı.
  • Paket o günden beri değişti. Şimdiki paket her atfı tam yazar, owner/repo@commit path:line biçiminde. Bu sayfa buna uydurulmak için yeniden yazılmadı: gövdesi 44 atfı kısa biçimde tutar (önünde repo adı olmayan bir yol ve satır), makbuz bloğu ise tam biçimdedir ve 23 satırdır.

Sorunda danışacağın repoları dizinle, ajanını bağla (Başlarken, Ajanını bağla) ve ona prior-art-researcher ajanını çalıştırmasını söyle. Her ajanın aldığı argüman ajan paketi sayfasında listelenir. Aynı sayfa repoda da var: docs/example-brief.md.