VibecoderMcSwaggins commited on
Commit
2588375
·
1 Parent(s): 5e761eb

refactor: add session reset + document magic number (senior review feedback)

Browse files
Files changed (1) hide show
  1. src/agent_factory/judges.py +9 -1
src/agent_factory/judges.py CHANGED
@@ -195,7 +195,9 @@ class HFInferenceJudgeHandler:
195
  "HuggingFaceH4/zephyr-7b-beta", # Fallback (Ungated)
196
  ]
197
 
198
- MAX_CONSECUTIVE_FAILURES: ClassVar[int] = 3 # Force synthesis after N failures
 
 
199
 
200
  def __init__(self, model_id: str | None = None) -> None:
201
  """
@@ -224,6 +226,12 @@ class HFInferenceJudgeHandler:
224
  After MAX_CONSECUTIVE_FAILURES, forces synthesis to prevent infinite loops.
225
  """
226
  self.call_count += 1
 
 
 
 
 
 
227
  self.last_question = question
228
  self.last_evidence = evidence
229
 
 
195
  "HuggingFaceH4/zephyr-7b-beta", # Fallback (Ungated)
196
  ]
197
 
198
+ # Force synthesis after N consecutive failures to prevent infinite loops
199
+ # Rationale: 3 models x 3 retries each = 9 total API attempts before circuit break
200
+ MAX_CONSECUTIVE_FAILURES: ClassVar[int] = 3
201
 
202
  def __init__(self, model_id: str | None = None) -> None:
203
  """
 
226
  After MAX_CONSECUTIVE_FAILURES, forces synthesis to prevent infinite loops.
227
  """
228
  self.call_count += 1
229
+
230
+ # Session-based reset: new question = new research session = reset failures
231
+ # Prevents failure state from leaking across different user queries
232
+ if question != self.last_question and self.last_question is not None:
233
+ self.consecutive_failures = 0
234
+
235
  self.last_question = question
236
  self.last_evidence = evidence
237