Repository navigation
feat(scoring): configurable judge timeout and retries before withholding #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { callJudge, type JudgeCallOptions } from "./judge.js"; | ||
| import { ScoringError } from "./errors.js"; | ||
| import type { RunResult } from "../types/output.js"; | ||
|
|
||
| /** | ||
| * Call the judge and parse its reply, retrying up to `options.limits.retries` | ||
| * times when the score would otherwise be withheld: the invocation failed or | ||
| * `parse` rejected the reply (both surface as {@link ScoringError}). Any other | ||
| * error is a bug and propagates immediately. The final failure keeps its | ||
| * message, with the attempt count appended when retries were made. | ||
| */ | ||
| export async function callJudgeAndParse<T>( | ||
| runResult: RunResult, | ||
| prompt: string, | ||
| options: JudgeCallOptions, | ||
| parse: (responseText: string) => T, | ||
| ): Promise<T> { | ||
| const attempts = 1 + Math.max(0, Math.floor(options.limits?.retries ?? 0)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Reject non-finite retry counts before starting judge calls. A programmatic 🤖 Prompt for AI Agents |
||
| for (let attempt = 1; ; attempt++) { | ||
| try { | ||
| return parse(await callJudge(runResult, prompt, options)); | ||
| } catch (err) { | ||
| if (!(err instanceof ScoringError)) throw err; | ||
| if (attempt >= attempts) { | ||
| throw attempts > 1 ? new ScoringError(`${err.message} (after ${attempts} attempts)`) : err; | ||
| } | ||
| options.logger?.verbose?.( | ||
| `Retrying ${options.scenarioName} for ${runResult.scenarioKey} (${runResult.agentName}), ` + | ||
| `attempt ${attempt + 1}/${attempts}: ${err.message}`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: netlify/axis
Length of output: 8827
🏁 Script executed:
Repository: netlify/axis
Length of output: 20134
Reject timeout values outside Node.js timer limits.
judgeLimitsFromConfigconvertsjudging.timeout_minutesto milliseconds, and the adapters pass that value directly tosetTimeout. PositiveInfinityand values above2,147,483,647ms can therefore become 1 ms timers. Reject non-finite values and values above the supported limit.Suggested fix
🤖 Prompt for AI Agents