Skip to content

Commit 16c19c7

Browse files
committed
update conditional check
1 parent 5d9a846 commit 16c19c7

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

pydantic_ai_slim/pydantic_ai/models/openai.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,18 +1022,15 @@ def _get_response_id_and_trim(self, messages: list[ModelMessage]) -> tuple[list[
10221022
for m in messages:
10231023
# Openai may return a dated model_name that differs from self.model_name
10241024
# (e.g., "gpt-5" vs "gpt-5-2025-08-07").
1025-
if isinstance(m, ModelResponse) and m.model_name:
1026-
if self.model_name in m.model_name:
1027-
response_id = m.provider_response_id
1028-
else:
1029-
# Mixed model responses invalidate response_id,
1030-
# so the history is kept intact.
1031-
response_id = None
1032-
break
1025+
if isinstance(m, ModelResponse) and m.model_name and (self.model_name in m.model_name):
1026+
response_id = m.provider_response_id
10331027
elif isinstance(m, ModelRequest):
10341028
latest_model_request = m
10351029
else:
1036-
pass
1030+
# Mixed model responses invalidate response_id,
1031+
# so the history is kept intact.
1032+
response_id = None
1033+
break
10371034
if response_id and latest_model_request:
10381035
messages = [latest_model_request]
10391036
return messages, response_id

0 commit comments

Comments
 (0)