fix(responses): use conversation items when no stored messages exist (#3819)

Handle a base case when no stored messages exist because no Response
call has been made.

## Test Plan

```
./scripts/integration-tests.sh --stack-config server:ci-tests \
   --suite responses   --inference-mode record-if-missing --pattern test_conversation_responses
```
This commit is contained in:
Ashwin Bharambe 2025-10-15 14:43:44 -07:00 committed by GitHub
parent 6ba9db3929
commit 8e7e0ddfec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1894 additions and 10 deletions

View file

@ -136,9 +136,21 @@ class OpenAIResponsesImpl:
# First turn - just convert the new input
messages = await convert_response_input_to_chat_messages(input)
else:
# Use stored messages directly and convert only new input
if not stored_messages:
all_input = conversation_items.data
if isinstance(input, str):
all_input.append(
OpenAIResponseMessage(
role="user", content=[OpenAIResponseInputMessageContentText(text=input)]
)
)
else:
all_input.extend(input)
else:
all_input = input
messages = stored_messages or []
new_messages = await convert_response_input_to_chat_messages(input, previous_messages=messages)
new_messages = await convert_response_input_to_chat_messages(all_input, previous_messages=messages)
messages.extend(new_messages)
else:
all_input = input