Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion python/packages/openai/agent_framework_openai/_chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,16 @@ async def _get_response() -> ChatResponse:
response = await client.responses.retrieve(continuation_token["response_id"])
except Exception as ex:
self._handle_request_error(ex)
return self._parse_response_from_openai(response, options=validated_options)
chat_response = self._parse_response_from_openai(response, options=validated_options)
# Once the background response completes, drop the continuation_token from
# the caller's options dict. FunctionInvocationLayer reuses the same dict
# across tool-loop iterations, so leaving it in place makes the next iteration
# retrieve the same completed response again instead of POSTing tool results
# (issue #5394). Keep `background` so subsequent iterations still create
# background responses.
if chat_response.continuation_token is None and isinstance(options, dict):
options.pop("continuation_token", None)
return chat_response
client, run_options, validated_options = await self._prepare_request(messages, options)
try:
if "text_format" in run_options:
Expand Down