@@ -282,12 +282,12 @@ class OptimizationJudgeContext:
282282# the concrete types (AIAgentConfig / AIJudgeCallConfig) continue to work
283283# because those types structurally satisfy the Protocols.
284284HandleAgentCall = Union [
285- Callable [[str , LLMCallConfig , LLMCallContext ], OptimizationResponse ],
286- Callable [[str , LLMCallConfig , LLMCallContext ], Awaitable [OptimizationResponse ]],
285+ Callable [[str , LLMCallConfig , LLMCallContext , bool ], OptimizationResponse ],
286+ Callable [[str , LLMCallConfig , LLMCallContext , bool ], Awaitable [OptimizationResponse ]],
287287]
288288HandleJudgeCall = Union [
289- Callable [[str , LLMCallConfig , LLMCallContext ], OptimizationResponse ],
290- Callable [[str , LLMCallConfig , LLMCallContext ], Awaitable [OptimizationResponse ]],
289+ Callable [[str , LLMCallConfig , LLMCallContext , bool ], OptimizationResponse ],
290+ Callable [[str , LLMCallConfig , LLMCallContext , bool ], Awaitable [OptimizationResponse ]],
291291]
292292
293293_StatusLiteral = Literal [
@@ -315,7 +315,8 @@ class OptimizationOptions:
315315 ] # choices of interpolated variables to be chosen at random per turn, 1 min required
316316 # Actual agent/completion (judge) calls - Required
317317 handle_agent_call : HandleAgentCall
318- handle_judge_call : HandleJudgeCall
318+ # Optional; falls back to handle_agent_call when omitted (both share the same signature)
319+ handle_judge_call : Optional [HandleJudgeCall ] = None
319320 # Criteria for pass/fail - Optional
320321 user_input_options : Optional [List [str ]] = (
321322 None # optional list of user input messages to randomly select from
@@ -401,7 +402,8 @@ class GroundTruthOptimizationOptions:
401402 model_choices : List [str ]
402403 judge_model : str
403404 handle_agent_call : HandleAgentCall
404- handle_judge_call : HandleJudgeCall
405+ # Optional; falls back to handle_agent_call when omitted (both share the same signature)
406+ handle_judge_call : Optional [HandleJudgeCall ] = None
405407 judges : Optional [Dict [str , OptimizationJudge ]] = None
406408 on_turn : Optional [Callable [[OptimizationContext ], bool ]] = None
407409 on_sample_result : Optional [Callable [[OptimizationContext ], None ]] = None
@@ -461,7 +463,8 @@ class OptimizationFromConfigOptions:
461463
462464 project_key : str
463465 handle_agent_call : HandleAgentCall
464- handle_judge_call : HandleJudgeCall
466+ # Optional; falls back to handle_agent_call when omitted (both share the same signature)
467+ handle_judge_call : Optional [HandleJudgeCall ] = None
465468 on_turn : Optional [Callable [["OptimizationContext" ], bool ]] = None
466469 on_sample_result : Optional [Callable [["OptimizationContext" ], None ]] = None
467470 on_passing_result : Optional [Callable [["OptimizationContext" ], None ]] = None
0 commit comments