Skip to content

Commit 79696b6

Browse files
committed
Replace referencable_id with response_id
1 parent e8f14da commit 79696b6

9 files changed

+38
-38
lines changed

src/agents/items.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class ModelResponse:
166166
usage: Usage
167167
"""The usage information for the response."""
168168

169-
referenceable_id: str | None
169+
response_id: str | None
170170
"""An ID for the response which can be used to refer to the response in subsequent calls to the
171171
model. Not supported by all model providers.
172172
"""

src/agents/models/openai_chatcompletions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async def get_response(
156156
return ModelResponse(
157157
output=items,
158158
usage=usage,
159-
referenceable_id=None,
159+
response_id=None,
160160
)
161161

162162
async def stream_response(

src/agents/models/openai_responses.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async def get_response(
120120
return ModelResponse(
121121
output=response.output,
122122
usage=usage,
123-
referenceable_id=response.id,
123+
response_id=response.id,
124124
)
125125

126126
async def stream_response(

src/agents/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ async def _run_single_turn_streamed(
677677
final_response = ModelResponse(
678678
output=event.response.output,
679679
usage=usage,
680-
referenceable_id=event.response.id,
680+
response_id=event.response.id,
681681
)
682682

683683
streamed_result._event_queue.put_nowait(RawResponsesStreamEvent(data=event))

tests/fake_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async def get_response(
8181
return ModelResponse(
8282
output=output,
8383
usage=Usage(),
84-
referenceable_id=None,
84+
response_id=None,
8585
)
8686

8787
async def stream_response(

tests/test_items_helpers.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_to_input_items_for_message() -> None:
168168
message = ResponseOutputMessage(
169169
id="m1", content=[content], role="assistant", status="completed", type="message"
170170
)
171-
resp = ModelResponse(output=[message], usage=Usage(), referenceable_id=None)
171+
resp = ModelResponse(output=[message], usage=Usage(), response_id=None)
172172
input_items = resp.to_input_items()
173173
assert isinstance(input_items, list) and len(input_items) == 1
174174
# The dict should contain exactly the primitive values of the message
@@ -193,7 +193,7 @@ def test_to_input_items_for_function_call() -> None:
193193
tool_call = ResponseFunctionToolCall(
194194
id="f1", arguments="{}", call_id="c1", name="func", type="function_call"
195195
)
196-
resp = ModelResponse(output=[tool_call], usage=Usage(), referenceable_id=None)
196+
resp = ModelResponse(output=[tool_call], usage=Usage(), response_id=None)
197197
input_items = resp.to_input_items()
198198
assert isinstance(input_items, list) and len(input_items) == 1
199199
expected: ResponseFunctionToolCallParam = {
@@ -211,7 +211,7 @@ def test_to_input_items_for_file_search_call() -> None:
211211
fs_call = ResponseFileSearchToolCall(
212212
id="fs1", queries=["query"], status="completed", type="file_search_call"
213213
)
214-
resp = ModelResponse(output=[fs_call], usage=Usage(), referenceable_id=None)
214+
resp = ModelResponse(output=[fs_call], usage=Usage(), response_id=None)
215215
input_items = resp.to_input_items()
216216
assert isinstance(input_items, list) and len(input_items) == 1
217217
expected: ResponseFileSearchToolCallParam = {
@@ -226,7 +226,7 @@ def test_to_input_items_for_file_search_call() -> None:
226226
def test_to_input_items_for_web_search_call() -> None:
227227
"""A web search tool call output should produce the same dict as a web search input."""
228228
ws_call = ResponseFunctionWebSearch(id="w1", status="completed", type="web_search_call")
229-
resp = ModelResponse(output=[ws_call], usage=Usage(), referenceable_id=None)
229+
resp = ModelResponse(output=[ws_call], usage=Usage(), response_id=None)
230230
input_items = resp.to_input_items()
231231
assert isinstance(input_items, list) and len(input_items) == 1
232232
expected: ResponseFunctionWebSearchParam = {
@@ -248,7 +248,7 @@ def test_to_input_items_for_computer_call_click() -> None:
248248
pending_safety_checks=[],
249249
status="completed",
250250
)
251-
resp = ModelResponse(output=[comp_call], usage=Usage(), referenceable_id=None)
251+
resp = ModelResponse(output=[comp_call], usage=Usage(), response_id=None)
252252
input_items = resp.to_input_items()
253253
assert isinstance(input_items, list) and len(input_items) == 1
254254
converted_dict = input_items[0]
@@ -268,7 +268,7 @@ def test_to_input_items_for_reasoning() -> None:
268268
"""A reasoning output should produce the same dict as a reasoning input item."""
269269
rc = Summary(text="why", type="summary_text")
270270
reasoning = ResponseReasoningItem(id="rid1", summary=[rc], type="reasoning")
271-
resp = ModelResponse(output=[reasoning], usage=Usage(), referenceable_id=None)
271+
resp = ModelResponse(output=[reasoning], usage=Usage(), response_id=None)
272272
input_items = resp.to_input_items()
273273
assert isinstance(input_items, list) and len(input_items) == 1
274274
converted_dict = input_items[0]

tests/test_openai_chatcompletions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def patched_fetch_response(self, *args, **kwargs):
8080
assert resp.usage.input_tokens == 7
8181
assert resp.usage.output_tokens == 5
8282
assert resp.usage.total_tokens == 12
83-
assert resp.referenceable_id is None
83+
assert resp.response_id is None
8484

8585

8686
@pytest.mark.allow_call_model_methods

tests/test_run_step_execution.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def test_empty_response_is_final_output():
4343
response = ModelResponse(
4444
output=[],
4545
usage=Usage(),
46-
referenceable_id=None,
46+
response_id=None,
4747
)
4848
result = await get_execute_result(agent, response)
4949

@@ -59,7 +59,7 @@ async def test_plaintext_agent_no_tool_calls_is_final_output():
5959
response = ModelResponse(
6060
output=[get_text_message("hello_world")],
6161
usage=Usage(),
62-
referenceable_id=None,
62+
response_id=None,
6363
)
6464
result = await get_execute_result(agent, response)
6565

@@ -79,7 +79,7 @@ async def test_plaintext_agent_no_tool_calls_multiple_messages_is_final_output()
7979
get_text_message("bye"),
8080
],
8181
usage=Usage(),
82-
referenceable_id=None,
82+
response_id=None,
8383
)
8484
result = await get_execute_result(
8585
agent,
@@ -105,7 +105,7 @@ async def test_plaintext_agent_with_tool_call_is_run_again():
105105
response = ModelResponse(
106106
output=[get_text_message("hello_world"), get_function_tool_call("test", "")],
107107
usage=Usage(),
108-
referenceable_id=None,
108+
response_id=None,
109109
)
110110
result = await get_execute_result(agent, response)
111111

@@ -140,7 +140,7 @@ async def test_multiple_tool_calls():
140140
get_function_tool_call("test_2"),
141141
],
142142
usage=Usage(),
143-
referenceable_id=None,
143+
response_id=None,
144144
)
145145

146146
result = await get_execute_result(agent, response)
@@ -166,7 +166,7 @@ async def test_handoff_output_leads_to_handoff_next_step():
166166
response = ModelResponse(
167167
output=[get_text_message("Hello, world!"), get_handoff_tool_call(agent_1)],
168168
usage=Usage(),
169-
referenceable_id=None,
169+
response_id=None,
170170
)
171171
result = await get_execute_result(agent_3, response)
172172

@@ -186,7 +186,7 @@ async def test_final_output_without_tool_runs_again():
186186
response = ModelResponse(
187187
output=[get_function_tool_call("tool_1")],
188188
usage=Usage(),
189-
referenceable_id=None,
189+
response_id=None,
190190
)
191191
result = await get_execute_result(agent, response)
192192

@@ -203,7 +203,7 @@ async def test_final_output_leads_to_final_output_next_step():
203203
get_final_output_message(Foo(bar="123").model_dump_json()),
204204
],
205205
usage=Usage(),
206-
referenceable_id=None,
206+
response_id=None,
207207
)
208208
result = await get_execute_result(agent, response)
209209

@@ -222,7 +222,7 @@ async def test_handoff_and_final_output_leads_to_handoff_next_step():
222222
get_handoff_tool_call(agent_1),
223223
],
224224
usage=Usage(),
225-
referenceable_id=None,
225+
response_id=None,
226226
)
227227
result = await get_execute_result(agent_3, response)
228228

@@ -241,7 +241,7 @@ async def test_multiple_final_output_leads_to_final_output_next_step():
241241
get_final_output_message(Foo(bar="456").model_dump_json()),
242242
],
243243
usage=Usage(),
244-
referenceable_id=None,
244+
response_id=None,
245245
)
246246
result = await get_execute_result(agent_3, response)
247247

tests/test_run_step_processing.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_empty_response():
3939
response = ModelResponse(
4040
output=[],
4141
usage=Usage(),
42-
referenceable_id=None,
42+
response_id=None,
4343
)
4444

4545
result = RunImpl.process_model_response(
@@ -58,7 +58,7 @@ def test_no_tool_calls():
5858
response = ModelResponse(
5959
output=[get_text_message("Hello, world!")],
6060
usage=Usage(),
61-
referenceable_id=None,
61+
response_id=None,
6262
)
6363
result = RunImpl.process_model_response(
6464
agent=agent, response=response, output_schema=None, handoffs=[], all_tools=[]
@@ -76,7 +76,7 @@ async def test_single_tool_call():
7676
get_function_tool_call("test", ""),
7777
],
7878
usage=Usage(),
79-
referenceable_id=None,
79+
response_id=None,
8080
)
8181
result = RunImpl.process_model_response(
8282
agent=agent,
@@ -102,7 +102,7 @@ async def test_missing_tool_call_raises_error():
102102
get_function_tool_call("missing", ""),
103103
],
104104
usage=Usage(),
105-
referenceable_id=None,
105+
response_id=None,
106106
)
107107

108108
with pytest.raises(ModelBehaviorError):
@@ -132,7 +132,7 @@ async def test_multiple_tool_calls():
132132
get_function_tool_call("test_2", "xyz"),
133133
],
134134
usage=Usage(),
135-
referenceable_id=None,
135+
response_id=None,
136136
)
137137

138138
result = RunImpl.process_model_response(
@@ -162,7 +162,7 @@ async def test_handoffs_parsed_correctly():
162162
response = ModelResponse(
163163
output=[get_text_message("Hello, world!")],
164164
usage=Usage(),
165-
referenceable_id=None,
165+
response_id=None,
166166
)
167167
result = RunImpl.process_model_response(
168168
agent=agent_3,
@@ -176,7 +176,7 @@ async def test_handoffs_parsed_correctly():
176176
response = ModelResponse(
177177
output=[get_text_message("Hello, world!"), get_handoff_tool_call(agent_1)],
178178
usage=Usage(),
179-
referenceable_id=None,
179+
response_id=None,
180180
)
181181
result = RunImpl.process_model_response(
182182
agent=agent_3,
@@ -205,7 +205,7 @@ async def test_missing_handoff_fails():
205205
response = ModelResponse(
206206
output=[get_text_message("Hello, world!"), get_handoff_tool_call(agent_2)],
207207
usage=Usage(),
208-
referenceable_id=None,
208+
response_id=None,
209209
)
210210
with pytest.raises(ModelBehaviorError):
211211
RunImpl.process_model_response(
@@ -229,7 +229,7 @@ async def test_multiple_handoffs_doesnt_error():
229229
get_handoff_tool_call(agent_2),
230230
],
231231
usage=Usage(),
232-
referenceable_id=None,
232+
response_id=None,
233233
)
234234
result = RunImpl.process_model_response(
235235
agent=agent_3,
@@ -254,7 +254,7 @@ async def test_final_output_parsed_correctly():
254254
get_final_output_message(Foo(bar="123").model_dump_json()),
255255
],
256256
usage=Usage(),
257-
referenceable_id=None,
257+
response_id=None,
258258
)
259259

260260
RunImpl.process_model_response(
@@ -281,7 +281,7 @@ async def test_file_search_tool_call_parsed_correctly():
281281
response = ModelResponse(
282282
output=[get_text_message("hello"), file_search_call],
283283
usage=Usage(),
284-
referenceable_id=None,
284+
response_id=None,
285285
)
286286
result = RunImpl.process_model_response(
287287
agent=agent,
@@ -306,7 +306,7 @@ async def test_function_web_search_tool_call_parsed_correctly():
306306
response = ModelResponse(
307307
output=[get_text_message("hello"), web_search_call],
308308
usage=Usage(),
309-
referenceable_id=None,
309+
response_id=None,
310310
)
311311
result = RunImpl.process_model_response(
312312
agent=agent,
@@ -333,7 +333,7 @@ async def test_reasoning_item_parsed_correctly():
333333
response = ModelResponse(
334334
output=[reasoning],
335335
usage=Usage(),
336-
referenceable_id=None,
336+
response_id=None,
337337
)
338338
result = RunImpl.process_model_response(
339339
agent=Agent(name="test"),
@@ -401,7 +401,7 @@ async def test_computer_tool_call_without_computer_tool_raises_error():
401401
response = ModelResponse(
402402
output=[computer_call],
403403
usage=Usage(),
404-
referenceable_id=None,
404+
response_id=None,
405405
)
406406
with pytest.raises(ModelBehaviorError):
407407
RunImpl.process_model_response(
@@ -430,7 +430,7 @@ async def test_computer_tool_call_with_computer_tool_parsed_correctly():
430430
response = ModelResponse(
431431
output=[computer_call],
432432
usage=Usage(),
433-
referenceable_id=None,
433+
response_id=None,
434434
)
435435
result = RunImpl.process_model_response(
436436
agent=agent,
@@ -460,7 +460,7 @@ async def test_tool_and_handoff_parsed_correctly():
460460
get_handoff_tool_call(agent_1),
461461
],
462462
usage=Usage(),
463-
referenceable_id=None,
463+
response_id=None,
464464
)
465465

466466
result = RunImpl.process_model_response(

0 commit comments

Comments
 (0)