-
Notifications
You must be signed in to change notification settings - Fork 3k
Duplicated function_call entries when using openai responses api #5136
Copy link
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
When using the OpenAI Responses API, function_call items from a previous response are duplicated in subsequent requests.
This results in the same tool call appearing multiple times in the OpenAI logs for a single turn.
Expected Behavior
- Each tool call should appear only once in OpenAI logs
Reproduction Steps
1. Configure the agent LLM to use openai response api:
llm = openai.responses.LLM(
model="gpt-5.4",
temperature=0.4,
)
2. Ask the agent anything that triggers a tool call.
3. Inspect the OpenAI logs for the request.Operating System
macOS Tahoe
Models Used
GPT 5.4
Package Versions
livekit-agents[openai]==1.4.6Session/Room/Call IDs
No response
Proposed Solution
Filter out previously emitted function_call items when previous_response_id is present:
async def _run_impl(self) -> None:
self._response_completed = False
chat_ctx, _ = self._chat_ctx.to_provider_format(format="openai.responses")
if "previous_response_id" in self._extra_kwargs and self._llm._pending_tool_calls:
chat_ctx = [
item for item in chat_ctx
if not (
isinstance(item, dict)
and item.get("type") == "function_call"
and item.get("call_id") in self._llm._pending_tool_calls
)
]Additional Context
No response
Screenshots and Recordings
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working