This commit is contained in:
Daniel Ibáñez 2026-10-27 02:25:20 +00:00 • committed by GitHub
commit 4c201fbd45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -113,6 +113,13 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
request["instructions"] = f"{base_instructions}\n\n{existing_instructions}"
else:
request["instructions"] = base_instructions
# The Codex backend rejects role=system input items ("System messages are not allowed")
# but accepts role=developer, which is what an in-sequence system message means there.
if isinstance(request.get("input"), list):
request["input"] = [
{**item, "role": "developer"} if isinstance(item, dict) and item.get("role") == "system" else item
for item in request["input"]
]
request["store"] = False
request["stream"] = True
include: Final = list(request.get("include") or [])

View file

@ -74,6 +74,18 @@ class TestChatGPTResponsesAPITransformation:
assert "service_tier" not in request
def test_system_input_items_become_developer(self):
system_item = {"type": "message", "role": "system", "content": [{"type": "input_text", "text": "be brief"}]}
user_item = {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "hi"}]}
request = ChatGPTResponsesAPIConfig().transform_responses_api_request(
model="gpt-6.1-sol",
input=[user_item, system_item],
response_api_optional_request_params={},
litellm_params=GenericLiteLLMParams(),
headers={},
)
assert request["input"] == [user_item, {**system_item, "role": "developer"}]
@pytest.mark.parametrize(
"model_name",
[