---
type: email
from: Wen-Tien Chang <notifications@github.com>
subject: [openai/openai-agents-python] Fix multi-turn handling for

 conversation_id and previous_response_id: only send new items (PR #1827)
received: 2026-03-06 07:46:17
date_header: Sun, 28 Sep 2025 08:51:20 -0700
priority: normal
status: awaiting_approval
uid: 31523
---

## Email Content

**From:** Wen-Tien Chang <notifications@github.com>
**Subject:** [openai/openai-agents-python] Fix multi-turn handling for

 conversation_id and previous_response_id: only send new items (PR #1827)
**Date:** Sun, 28 Sep 2025 08:51:20 -0700

### Body (preview)

This PR fixes incorrect behavior when using `conversation_id` or `previous_response_id` during internal multi-turn calls, i.e. when function calling is involved.



It provides better support for the OpenAI Conversation state feature, as described in the https://platform.openai.com/docs/guides/conversation-state?api-mode=responses, aligning with the intended API design.



Resolved: https://github.com/openai/openai-agents-python/issues/1789



### Problem



- When using **conversation_id**, the runner resent all items on every turn, which caused server-side duplicate item error. 

- When using **previous_response_id**, the SDK also resent all items because the `previous_response_id` was not updated across internal loops. This led to duplicated items and wasted bandwidth, even though it did not trigger errors currently.

    



### Minimal repro code:



```

from agents import Agent, function_tool, Runner

from openai import OpenAI

client = OpenAI()



conversation = client.conversations.create()

conv_id = conversation.id



@function_tool

async def foobar() -&gt; str:

    return &quot;41&quot;



agent = Agent(

    name=&quot;Assistant&quot;,

    instructions=&quot;just call foobar and answer me only the number&quot;,

    model=&quot;gpt-4.1-mini&quot;,

    tools=[foobar]

)



Runner.run_sync(agent, &quot;hi&quot;, conversation_id=conv_id)

```





This produces the following error:



```

openai.BadRequestError: Error code: 400 - {&#39;error&#39;: {&#39;message&#39;: &#39;Duplicate item found with id fc_68d281ab76108195ac719f9b7c48eac103032f3a88a761f2. Remove duplicate items from your input and try again.&#39;, &#39;type&#39;: &#39;invalid_request_error&#39;, &#39;param&#39;: &#39;input&#39;, &#39;code&#39;: None}}

```





### Solution



- Added a _ServerConversationTracker to track items that should not be sent:

    - **conversation_id**: only send  new items on each turn.

    - **previous_response_id**: only send new items and update `previous_

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
