vn6295337 Claude Opus 4.5 commited on
Commit
efcfc92
·
1 Parent(s): de66f3b

Fix: Increase rate limit delays and fix revision detection

Browse files

1. Increase pre-call delays: 2s → 5s
2. Increase backoff times: 2s,4s,8s → 3s,6s,12s
3. Fix revision mode detection: check critique_details.status
instead of revision_count (which was still 0 on first loop)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

src/llm_client.py CHANGED
@@ -11,7 +11,7 @@ from typing import Optional, Tuple
11
 
12
  # Retry configuration for rate limits
13
  MAX_RETRIES = 3
14
- INITIAL_BACKOFF = 2 # seconds
15
 
16
 
17
  class LLMClient:
 
11
 
12
  # Retry configuration for rate limits
13
  MAX_RETRIES = 3
14
+ INITIAL_BACKOFF = 3 # seconds (backoffs: 3s, 6s, 12s)
15
 
16
 
17
  class LLMClient:
src/nodes/analyzer.py CHANGED
@@ -989,9 +989,10 @@ def analyzer_node(state, workflow_id=None, progress_store=None):
989
  # Generate detailed data report (shown before SWOT)
990
  data_report = _generate_data_report(raw, is_financial=is_financial)
991
 
992
- # Detect revision mode: if revision_count > 0 and critique_details exist
993
- is_revision = state.get("revision_count", 0) > 0
994
  critique_details = state.get("critique_details", {})
 
995
 
996
  if is_revision and critique_details:
997
  # REVISION MODE: Use enhanced revision prompt with Critic feedback
@@ -1022,8 +1023,8 @@ def analyzer_node(state, workflow_id=None, progress_store=None):
1022
  # In revision mode, add delay before LLM call to avoid rate limits
1023
  # (Critic just called LLM, so we need to wait)
1024
  if is_revision:
1025
- print("Waiting 2s before revision LLM call (rate limit buffer)...")
1026
- time.sleep(2)
1027
 
1028
  start_time = time.time()
1029
  response, provider, error, providers_failed = llm.query(prompt, temperature=0)
 
989
  # Generate detailed data report (shown before SWOT)
990
  data_report = _generate_data_report(raw, is_financial=is_financial)
991
 
992
+ # Detect revision mode: if we have critique_details with REJECTED status
993
+ # (revision_count may still be 0 on first revision loop)
994
  critique_details = state.get("critique_details", {})
995
+ is_revision = bool(critique_details) and critique_details.get("status") == "REJECTED"
996
 
997
  if is_revision and critique_details:
998
  # REVISION MODE: Use enhanced revision prompt with Critic feedback
 
1023
  # In revision mode, add delay before LLM call to avoid rate limits
1024
  # (Critic just called LLM, so we need to wait)
1025
  if is_revision:
1026
+ print("Waiting 5s before revision LLM call (rate limit buffer)...")
1027
+ time.sleep(5)
1028
 
1029
  start_time = time.time()
1030
  response, provider, error, providers_failed = llm.query(prompt, temperature=0)
src/nodes/critic.py CHANGED
@@ -322,8 +322,8 @@ def critic_node(state, workflow_id=None, progress_store=None):
322
  llm = get_llm_client()
323
 
324
  # Add delay before LLM call to avoid rate limits (Analyzer just called LLM)
325
- print("Waiting 2s before Critic LLM call (rate limit buffer)...")
326
- time.sleep(2)
327
 
328
  _add_activity_log(workflow_id, progress_store, "critic", "Calling LLM for quality evaluation...")
329
  start_time = time.time()
 
322
  llm = get_llm_client()
323
 
324
  # Add delay before LLM call to avoid rate limits (Analyzer just called LLM)
325
+ print("Waiting 5s before Critic LLM call (rate limit buffer)...")
326
+ time.sleep(5)
327
 
328
  _add_activity_log(workflow_id, progress_store, "critic", "Calling LLM for quality evaluation...")
329
  start_time = time.time()