Repository navigation
fix(openai): keep the system role for o3, o3-mini and o4-mini - #48732
Open
dhruvindave007 wants to merge 1 commit into
Open
dhruvindave007 wants to merge 1 commit into
dhruvindave007 wants to merge 1 commit into
Conversation
dhruvindave007
requested review from
joshua-berri,
kerry-berri,
mateo-berri and
ryan-crabbe-berri
as code owners
October 28, 2026 07:38
Contributor
Merging this PR will not alter performance1 warning
Comparing Footnotes |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
3 of 6 tasks
dhruvindave007
force-pushed
the
fix-o-series-system-messages
branch
from
October 29, 2026 15:28
cf2c095 to
d6f24c6
Compare
This was referenced Oct 30, 2026
Merged
11 of 17 tasks
The o-series transform rewrites a system message as a user message when the cost map does not flag the model with supports_system_messages. Only the o1 rows carried the flag, so every o3, o3-mini and o4-mini request (OpenAI and Azure) silently demoted its system prompt to user-level authority Flag those rows in the cost map and its bundled backup, and add a regression test that the system role survives for them on both the OpenAI and Azure configs
dhruvindave007
force-pushed
the
fix-o-series-system-messages
branch
from
November 2, 2026 14:16
d6f24c6 to
ea5f326
Compare
Author
|
Hi, this is ready for review. Could a maintainer approve the CI run for the latest commit? It fixes #48731, the o3/o4-mini system prompt bug |
This was referenced Nov 4, 2026
This was referenced Nov 16, 2026
This branch has not been deployed
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.
LiteLLM was quietly turning the system prompt into a user message for o3, o3-mini and o4-mini on OpenAI and Azure, so app instructions lost their priority and could be overridden by the user turn. This flags those models as supporting system messages in the model map, the same way o1 already is, so the system prompt goes out as a system message again
Details
TLDR
Problem this solves:
How it solves it:
supports_system_messages: trueon those model map rowsUser Flow
Before: a developer's system prompt reaches o3 as an ordinary user message
litellm.completion(model="o3", messages=[{"role": "system", ...}, {"role": "user", "content": "hi"}])messageswith roles["user", "user"]After: the same call keeps the system prompt as a system message
litellm.completion(model="o3", messages=[{"role": "system", ...}, {"role": "user", "content": "hi"}])messageswith roles["system", "user"], matching what o1 already getsRelevant issues
Fixes #48731
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup is a short script that calls
litellm.completionfor each model with a system and a user message, and prints the roles in the request body LiteLLM sends upstream. The upstream is mocked withrespxbecause I don't have an OpenAI or Azure key (see Caveats)Before (1046716)
LITELLM_LOCAL_MODEL_COST_MAP=True python o_series_system_to_user.pyAfter (ea5f326)
LITELLM_LOCAL_MODEL_COST_MAP=True python o_series_system_to_user.pyType
🐛 Bug Fix
Caveats (if any)
Low
o1rows still lack the flag, left out to keep scope tightosv-scanfails here and also onmaintoday, and this PR touches no lockfilesFinal Attestation