You will see that the tree of input items in the API reference for “input” splits between “input message” and merely “context item”.
Despite that the assistant produces something like reasoning or tool calls at the same time that it can produce a response to a user, it is being delivered in another list item, another event.
You have to pass these back in the same format they were delivered to you by the API.
Capture and observe closely the list of output items in a non-stream response. You will see an array (list) of items is delivered to you in parallel hierarchy sequentially. This is what you amend the input list with. Not strictly input message objects with “role”.
Basically, you take the reasoning element in the response.output and pass it as a json to the already existing conversation.
In this example I just tossed the entire output as the python SDK can handle it, but if you need to do a REST request you must use an equivalent JSON.
Here is a short example.
inputs = [{ "role": "user", "content": "Explain why is the sky blue." } ]
response_1 = client.responses.create(
model="o4-mini",
reasoning= {"effort":"low"},
input=inputs,
include=['reasoning.encrypted_content'],
store=False,
)
print('#1 First output')
for o in response_1.output:
print(o.type,o.to_dict())
#follow up
inputs.extend(response_1.output)
inputs.append({ "role": "user", "content": "Can you summarize it in one sentence?" })
response_2 = client.responses.create(
model="o4-mini",
reasoning= {"effort":"low"},
input=inputs,
include=['reasoning.encrypted_content'],
store=False,
)
print('#2 Second output')
for o in response_2.output:
print(o.type,o.to_dict())
Thank you! This is really helpful! I was thinking that the encrypted reasoning would include some representation of the state so that you wouldn’t need to add the previous agent response, but it looks like you need to include both.