Skip to content

Conversation

@Cody-learns
Copy link

@Cody-learns Cody-learns commented Nov 19, 2025

Fixes #3369

Summary

This PR fixes an issue when switching from OpenAIChatModel to OpenAIResponseModel, where the OpenAI Responses API rejects requests with no input and no previous_response_id.

Per maintainer guidance, we detect when both openai_messages and previous_response_id are empty and automatically inject a blank user message.

Changes

  • In openai.py, insert a minimal blank EasyInputMessageParam when no input messages exist.
  • Add test: test_openai_responses_runs_with_deps_only_and_sends_input, verifying that deps-only runs provide a non-empty input or text field.

Comment on lines +1226 to +1228
# When there are no input messages and we're not reusing a previous response,
# the OpenAI API will reject a request without any input. To avoid this provide
# an explicit empty user message.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should clarify that there are instructions, because if not, the request would really be empty and we should error.

Suggested change
# When there are no input messages and we're not reusing a previous response,
# the OpenAI API will reject a request without any input. To avoid this provide
# an explicit empty user message.
# When there are no input messages and we're not reusing a previous response,
# the OpenAI API will reject a request without any input,
# even if there are instructions.
# To avoid this provide an explicit empty user message.

)


async def test_openai_responses_runs_with_deps_only_and_sends_input(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think we can remove the deps stuff, just having instructions should be enough.
  • We should do a real model request and verify the API accepts this payload and behaves correctly; we shouldn't mock the request. If you remove the mock stuff, you can run the test with pytest <path> --record-mode=rewrite and it'll automatically store a pyvcr cassette with the recorded request/response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mandatory input parameter after switching to the OpenAI Responses API

2 participants