Fix structured output format and temperature handling for OpenAI evaluator models#16
Open
JunYeopLee wants to merge 2 commits intoscaleapi:mainfrom
Conversation
The evaluator's `response_format` used `response_schema` (Gemini-specific), which causes `BadRequestError: Unknown parameter 'response_format.response_schema'` when using OpenAI models (e.g. gpt-5.1) as the evaluator. Changes: - Use OpenAI's `json_schema` structured output format when the evaluator model is an OpenAI model, and keep the existing `json_object` + `response_schema` format for Gemini and other providers. - Omit the `temperature` parameter entirely for OpenAI reasoning models (o1, o3, o4, gpt-5 families) instead of hard-coding it to 1, since these models reject any explicit temperature value. - Enable `litellm.drop_params = True` as a safety net so unsupported parameters are silently dropped rather than causing request failures. Made-with: Cursor
| response_format={ | ||
| # Build response_format based on provider | ||
| model_name = self.config.evaluator_model.lower() | ||
| is_openai = model_name.startswith("openai/") or model_name.startswith("gpt-") |
There was a problem hiding this comment.
is_openai misses unprefixed OpenAI reasoning models
LiteLLM routes bare model names like o1, o3, o4-mini to OpenAI automatically, but this check only looks for "openai/" or "gpt-" prefixes. If a user passes --evaluator-model o3, is_openai will be False, causing the Gemini-style response_format to be sent to OpenAI — triggering the same BadRequestError this PR aims to fix.
Consider also matching the reasoning prefixes in the is_openai check:
Suggested change
| is_openai = model_name.startswith("openai/") or model_name.startswith("gpt-") | |
| is_openai = model_name.startswith("openai/") or model_name.startswith("gpt-") or model_name.startswith(("o1", "o3", "o4")) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: services/mcp_eval/mcp_evals_scores.py
Line: 366
Comment:
**`is_openai` misses unprefixed OpenAI reasoning models**
LiteLLM routes bare model names like `o1`, `o3`, `o4-mini` to OpenAI automatically, but this check only looks for `"openai/"` or `"gpt-"` prefixes. If a user passes `--evaluator-model o3`, `is_openai` will be `False`, causing the Gemini-style `response_format` to be sent to OpenAI — triggering the same `BadRequestError` this PR aims to fix.
Consider also matching the reasoning prefixes in the `is_openai` check:
```suggestion
is_openai = model_name.startswith("openai/") or model_name.startswith("gpt-") or model_name.startswith(("o1", "o3", "o4"))
```
How can I resolve this? If you propose a fix, please make it concise.LiteLLM routes unprefixed names like o1, o3, o4-mini to OpenAI automatically, so is_openai must match them to avoid sending the Gemini-style response_format to OpenAI. Made-with: Cursor
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.
Summary
When using an OpenAI model (e.g.
openai/gpt-5.1) as the evaluator via--evaluator-model, the scoring script fails with:This happens because
response_schemainsideresponse_formatis a Gemini-specific parameter that the OpenAI API does not recognize.This PR fixes the issue by:
response_format: Uses OpenAI's nativejson_schemastructured output format (withstrict: true) for OpenAI models, and preserves the existingjson_object+response_schemaformat for Gemini and other providers.temperature=1only forgpt-5, thetemperatureparameter is now omitted entirely for all OpenAI reasoning model families (o1,o3,o4,gpt-5*), since these models reject any explicit temperature value.litellm.drop_params = True: Acts as a safety net so that any unsupported parameters are silently dropped rather than causing request failures.Reproduction
Before this fix, every scoring request fails immediately. After this fix, OpenAI models work correctly as evaluators.
Test plan
openai/gpt-5.1as evaluator no longer producesBadRequestErrorgemini/gemini-2.5-pro) still work as before (no behavior change)litellm.drop_params = Trueis set as a fallback safety net