Skip to content

Agent + tool + conversationId throws invalid request error - Duplicate item found with id rs_xxx. Remove duplicate items from your input and try again. #425

@orenkl

Description

@orenkl

Debug information

  • Agents SDK version: v0.1.0
  • Runtime environment: Node v22.19.0

Repro steps

When running the following code from the command line:

import { Agent, run, tool } from '@openai/agents';
import { z } from 'zod';

import OpenAI from 'openai';

const getWeatherTool = tool({
    name: 'get_weather',
    description: 'Get the weather for a given city',
    parameters: z.object({ city: z.string() }),
    strict: true,
    async execute({ city }) {
        return `The weather in ${city} is sunny.`;
    },
});

async function main() {
    const client = new OpenAI();
    const conversation = await client.conversations.create({});
    const agent = new Agent({
        name: 'Assistant',
        instructions: 'You are a helpful assistant. be VERY concise.',
        model: "gpt-5",
        tools: [getWeatherTool],
    });
    const runOptions = { conversationId: conversation.id };
    const result = await run(agent, "What is the weather in NYC?", runOptions);
    console.log(`Output: ${result.finalOutput}`);
}
if (require.main === module) {
    main().catch(console.error);
}

I am getting this exception:

BadRequestError: 400 Duplicate item found with id rs_68b8366ad2848195beb3348e5860cc81029faaa0843e7ce0. Remove duplicate items from your input and try again.
    at APIError.generate (/Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-openai/node_modules/openai/core/error.js:45:20)
    at OpenAI.makeStatusError (/Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-openai/node_modules/openai/client.js:163:32)
    at OpenAI.makeRequest (/Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-openai/node_modules/openai/client.js:308:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async #fetchResponse (/Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-openai/dist/openaiResponsesModel.js:733:26)
    at async /Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-openai/dist/openaiResponsesModel.js:752:30
    at async /Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-core/dist/tracing/createSpans.js:25:24
    at async OpenAIResponsesModel.getResponse (/Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-openai/dist/openaiResponsesModel.js:751:26)
    at async /Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-core/dist/run.js:167:51
    at async /Users/oren/Documents/dev/opstream/opstream-frontend/packages/functions/node_modules/@openai/agents-core/dist/tracing/context.js:56:24 {
  status: 400,
  headers: Headers {
    date: 'Wed, 03 Sep 2025 12:37:03 GMT',
    'content-type': 'application/json',
    'content-length': '250',
    connection: 'keep-alive',
    'openai-version': '2020-10-01',
    'openai-organization': 'xxx',
    'openai-project': 'xxx',
    'x-request-id': 'req_a0f9dd423f05226476a6b9b0a2e95386',
    'openai-processing-ms': '721',
    'x-envoy-upstream-service-time': '725',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'cf-cache-status': 'DYNAMIC',
    'set-cookie': 'xxx',
    'x-content-type-options': 'nosniff',
    server: 'cloudflare',
    'cf-ray': '97954bce8d345bd4-LIS',
    'alt-svc': 'h3=":443"; ma=86400'
  },
  requestID: 'req_a0f9dd423f05226476a6b9b0a2e95386',
  error: {
    message: 'Duplicate item found with id rs_68b8366ad2848195beb3348e5860cc81029faaa0843e7ce0. Remove duplicate items from your input and try again.',
    type: 'invalid_request_error',
    param: 'input',
    code: null
  },
  code: null,
  param: 'input',
  type: 'invalid_request_error'
}

In the Dashboard traces, it looks like it's coming from the 2nd call to the Model after the tool returns a response:

Image

Expected behavior

Agent should load the previous inputs from the conversation and log new data to it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions