diff --git a/src/claw_anything/graders/llm_judge.py b/src/claw_anything/graders/llm_judge.py index 3f96958..d9a036f 100644 --- a/src/claw_anything/graders/llm_judge.py +++ b/src/claw_anything/graders/llm_judge.py @@ -152,7 +152,11 @@ def _chat_with_retries( {"role": "user", "content": user}, ], "temperature": 0.0, - "max_tokens": max_tokens, + # Clamp to the model's real output cap. The default 32768 is + # above gpt-4o-mini's 16384 limit; ollama silently ignores an + # oversized max_tokens but OpenAI 400s, and the 20x retry loop + # then hangs grading until the batch drops the result. + "max_tokens": min(max_tokens, 16384), } resp = self.client.chat.completions.create(**kwargs) log_llm_call( @@ -334,7 +338,7 @@ def evaluate( {"role": "user", "content": user_msg}, ], "temperature": 0.0, - "max_tokens": 32768, + "max_tokens": 16384, # gpt-4o-mini output cap; see the note above } resp = self.client.chat.completions.create(**_judge_kwargs) log_llm_call(