I am trying to reuse responses between agents runs, like in
result = await Runner.run(agent, "What is the largest country in South America?")
print(result.final_output)
# Brazil
result = await Runner.run(
agent,
"What is the capital of that country?",
previous_response_id=result.last_response_id,
)
found in documentation
However, I get this error when running the pipeline trying to reuse the last response reasoning
Error getting response: Error code: 400 - {'error': {'message': 'Duplicate item found with id rs_<ID>. Remove duplicate items from your input and try again.', 'type': 'invalid_request_error', 'param': 'input', 'code': None}}. (request_id: <RID>)
Any clues to what I am doing wrong?
1 Like
Works fine for me. Make sure you have the latest updates by running:
`pip install --upgrade openai openai-agents`
You can also add that and other specific parameters like this:
agent = Agent(name="Assistant",
model='gpt-5-mini',
model_settings = ModelSettings(
reasoning={"effort":"minimal"},
extra_body={"previous_response_id":"resp_12345"}
),
)
3 Likes
Hmm, are you sure? You are setting a fixed response ID in the Agent initializer, while I am trying to use the response from the previous agent run.
The run method has a previous_response_id parameter, string type.
1 Like
I tried your code too, no errors. That agent code was an extra alternative. Have you tried updating the packages?
2 Likes
Ok thanks for testing. Yes I have upgraded packages. Weird thing is that it is the same duplicate rs_ prefixed ID supposedly being duplicate, while the response IDs are prefixed resp_ it seems. I might have hit a snag.
Here, I tried this way and it worked too:
from agents import RunConfig
agent = Agent(name="Assistant previous_id",
model='gpt-5-mini',
model_settings = ModelSettings(reasoning={"effort":"minimal"},),
)
result = await Runner.run(agent, "What is the largest country in latam?",)
print(result.final_output)
result2 = await Runner.run(agent, "What is the capital of that country?",
run_config=RunConfig(model_settings = ModelSettings(
extra_body={"previous_response_id":result.last_response_id}
),
))
print(result2.final_output)
If by area, the largest country in Latin America is Brazil (about 8.5 million km²). If you meant by population, it's also Brazil (about 215 million people as of the mid-2020s).
The capital of Brazil is BrasĂlia.
ps: check if the agent doesnât have conflicting parameters
1 Like
Thanks, I would never have guessed the latest parameter example 
Still getting the error though, need to investigate more. BTW the agent that I want to feed the previous response is a handoff from the previous agent. That could mess things up perhaps.
You mentioned getting a ârs_xxxxâ id, it seems strange.
Does this also give the same id?
result.raw_responses[-1].response_id
2 Likes
Yes, same ID. I suspect the problems come from the agent being a handoff of the previous, if not I can live without it. They do work together nicely, without passing previous response explicitly.
1 Like