From a9251a0ee373f842c00fc401e2f56fbc2d9dd089 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Sat, 7 Mar 2026 01:42:45 -0500 Subject: [PATCH] fix: increase AI timeout to 120s and limit retries to 1 The 45s timeout was too short for generation tasks with full flow context in the system prompt. The Anthropic SDK's default 2 retries caused requests to hang for ~136s before failing. Now: 120s timeout with max 1 retry = faster failure if it does timeout. Co-Authored-By: Claude Opus 4.6 --- backend/app/core/ai_provider.py | 1 + backend/app/core/config.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/app/core/ai_provider.py b/backend/app/core/ai_provider.py index 10939843..4e38cceb 100644 --- a/backend/app/core/ai_provider.py +++ b/backend/app/core/ai_provider.py @@ -184,6 +184,7 @@ class AnthropicProvider(AIProvider): client = anthropic.AsyncAnthropic( api_key=self._api_key, timeout=self._timeout, + max_retries=1, ) response = await client.messages.create( diff --git a/backend/app/core/config.py b/backend/app/core/config.py index 972211d9..bdf02ce8 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -77,7 +77,7 @@ class Settings(BaseSettings): AI_MODEL: str = "claude-sonnet-4-6" AI_CONVERSATION_TTL_HOURS: int = 24 AI_MAX_CALLS_PER_FLOW: int = 10 - AI_REQUEST_TIMEOUT_SECONDS: int = 45 + AI_REQUEST_TIMEOUT_SECONDS: int = 120 # AI Provider selection AI_PROVIDER: str = "anthropic" # "gemini" or "anthropic" GOOGLE_AI_API_KEY: Optional[str] = None