Shurem commited on
Commit
e171ea8
·
1 Parent(s): b0ff665

multi issues fixed

Browse files
Files changed (1) hide show
  1. app/services/agent_core.py +17 -1
app/services/agent_core.py CHANGED
@@ -599,11 +599,27 @@ def _try_groq(prompt: str, system_instruction: str, temperature: float) -> objec
599
  model=model_name,
600
  messages=messages,
601
  temperature=temperature,
 
 
 
 
 
 
 
602
  )
603
  text = (response.choices[0].message.content or "") if response.choices else ""
604
  data = extract_json_safe(text)
605
  if data is None:
606
- log.warning("groq %s returned no parseable JSON", model_name)
 
 
 
 
 
 
 
 
 
607
  else:
608
  log.info("groq %s succeeded", model_name)
609
  return data
 
599
  model=model_name,
600
  messages=messages,
601
  temperature=temperature,
602
+ # No cap here previously -- run_agent's prompt asks for up to 25
603
+ # full company profiles (name/email/phone/subject/full email
604
+ # body each) in one completion, and Groq's provider default is
605
+ # well short of what that needs. Confirmed live 2026-09-18: a
606
+ # 200 OK response that still failed to parse, with 120b
607
+ # (dropped the truncation this caused on the smaller 20b too).
608
+ max_tokens=8000,
609
  )
610
  text = (response.choices[0].message.content or "") if response.choices else ""
611
  data = extract_json_safe(text)
612
  if data is None:
613
+ # Logged truncated, not omitted -- the previous version left no
614
+ # way to tell a truncated/malformed JSON body apart from the
615
+ # model refusing outright or wrapping it in prose, so every past
616
+ # failure was an unexplained guess. Lead data isn't sensitive.
617
+ log.warning(
618
+ "groq %s returned no parseable JSON (finish_reason=%s, first 800 chars): %r",
619
+ model_name,
620
+ response.choices[0].finish_reason if response.choices else "?",
621
+ text[:800],
622
+ )
623
  else:
624
  log.info("groq %s succeeded", model_name)
625
  return data