judge: clamp max_tokens to the model's output cap (gpt-4o-mini 400s on 32768) - #13
Open
saikrishnarallabandi wants to merge 1 commit into
Open
Conversation
The judge hard-codes max_tokens=32768 at two call sites, above gpt-4o-mini's 16384 completion limit. ollama silently ignores an oversized max_tokens; OpenAI returns 400, the 20x retry loop then hangs grading until the batch drops the result with no error surfaced. Presents exactly like an invalid API key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LLMJudgehard-codesmax_tokens=32768at two call sites:llm_judge.py#L142—_call(...)llm_judge.py#L337—evaluate(...)gpt-4o-mini— the default inconfig.example.yaml— accepts at most 16,384 completion tokens. OpenAI rejects the request:Because the 400 is inside the
max_retries=20loop, the judge retries it 20 times with ~8s backoff (~160s per judge call). Grading then exceeds the batch's patience and the trial is dropped with no error surfaced — the trace ends up with nograding_resultat all.Why it isn't caught with a local judge
An ollama-backed judge silently ignores an oversized
max_tokens, so this only appears when the judge is an actual OpenAI endpoint. We hit it the moment we pointedjudge.base_urlatapi.openai.comto match the published evaluation setup.It presents exactly like an invalid API key — no grading output, no traceback. It cost us a while to find, since the key was fine.
Reproduce
The trace file ends with
trace_endand nograding_result. Runclaw-anything gradeon it in the foreground and the cause is visible:Minimal confirmation of the underlying limit:
Fix
Clamp both call sites to
min(max_tokens, 16384). No behaviour change for backends that accept larger values, since judge responses are far below either cap.Environment
--trial-in-container)openaiSDKgpt-4o-miniviahttps://api.openai.com/v1f9a0f63and currentmain(e19dce2)After the fix: 0 retries, grading completes, and a task that previously produced no
grading_resultscores normally.