5555 InMemoryResponseProvider ,
5656 ResponseContext ,
5757 ResponseExitForRecovery ,
58+ ResponseObject ,
5859 ResponsesServerOptions ,
5960)
6061from azure .ai .agentserver .responses .aio import ResponseEventStream
@@ -1092,57 +1093,69 @@ def run_dispatch(*args: Any, **kwargs: Any) -> ResponseStream[AgentResponseUpdat
10921093 async def test_omit_failed_conversation_input_provider_drops_terminal_failed_input (self ) -> None :
10931094 inner = InMemoryResponseProvider ()
10941095 store = _OmitFailedConversationInputProvider (inner , set ())
1095- poison_item : dict [str , Any ] = {
1096- "id" : "item_poison" ,
1097- "type" : "function_call_output" ,
1098- "call_id" : "call_12345abc" ,
1099- "output" : "example function call output" ,
1100- "status" : "completed" ,
1101- }
1102- ok_item : dict [str , Any ] = {
1103- "id" : "item_ok" ,
1104- "type" : "message" ,
1105- "role" : "user" ,
1106- "content" : [{"type" : "input_text" , "text" : "Hello, how are you?" }],
1107- "status" : "completed" ,
1108- }
1096+ poison_item = cast (
1097+ OutputItem ,
1098+ {
1099+ "id" : "item_poison" ,
1100+ "type" : "function_call_output" ,
1101+ "call_id" : "call_12345abc" ,
1102+ "output" : "example function call output" ,
1103+ "status" : "completed" ,
1104+ },
1105+ )
1106+ ok_item = cast (
1107+ OutputItem ,
1108+ {
1109+ "id" : "item_ok" ,
1110+ "type" : "message" ,
1111+ "role" : "user" ,
1112+ "content" : [{"type" : "input_text" , "text" : "Hello, how are you?" }],
1113+ "status" : "completed" ,
1114+ },
1115+ )
11091116
11101117 await store .create_response (
1111- {"id" : "resp_failed" , "status" : "failed" , "conversation" : "conv-1" , "output" : []},
1118+ cast ( ResponseObject , {"id" : "resp_failed" , "status" : "failed" , "conversation" : "conv-1" , "output" : []}) ,
11121119 [poison_item ],
11131120 None ,
11141121 )
11151122 await store .create_response (
1116- {"id" : "resp_ok" , "status" : "completed" , "conversation" : "conv-1" , "output" : []},
1123+ cast ( ResponseObject , {"id" : "resp_ok" , "status" : "completed" , "conversation" : "conv-1" , "output" : []}) ,
11171124 [ok_item ],
11181125 None ,
11191126 )
11201127
11211128 history_ids = await store .get_history_item_ids (None , "conv-1" , 100 )
11221129 assert "item_poison" not in history_ids
11231130 assert "item_ok" in history_ids
1124- assert _is_failed_stored_response ({ "status " : "failed " , "conversation " : "conv-1" } )
1125- assert not _is_failed_stored_response ({ "status " : "completed " , "conversation " : "conv-1" } )
1131+ assert _is_failed_stored_response (cast ( ResponseObject , { "id " : "resp_failed " , "status " : "failed" }) )
1132+ assert not _is_failed_stored_response (cast ( ResponseObject , { "id " : "resp_ok " , "status " : "completed" }) )
11261133
11271134 async def test_omit_failed_conversation_input_provider_updates_existing_response_in_place (self ) -> None :
11281135 inner = InMemoryResponseProvider ()
11291136 store = _OmitFailedConversationInputProvider (inner , set ())
1130- poison_item : dict [str , Any ] = {
1131- "id" : "item_poison" ,
1132- "type" : "function_call_output" ,
1133- "call_id" : "call_12345abc" ,
1134- "output" : "example function call output" ,
1135- "status" : "completed" ,
1136- }
1137- in_progress : dict [str , Any ] = {
1138- "id" : "resp_stream_fail" ,
1139- "status" : "in_progress" ,
1140- "conversation" : "conv-1" ,
1141- "output" : [],
1142- }
1137+ poison_item = cast (
1138+ OutputItem ,
1139+ {
1140+ "id" : "item_poison" ,
1141+ "type" : "function_call_output" ,
1142+ "call_id" : "call_12345abc" ,
1143+ "output" : "example function call output" ,
1144+ "status" : "completed" ,
1145+ },
1146+ )
1147+ in_progress = cast (
1148+ ResponseObject ,
1149+ {
1150+ "id" : "resp_stream_fail" ,
1151+ "status" : "in_progress" ,
1152+ "conversation" : "conv-1" ,
1153+ "output" : [],
1154+ },
1155+ )
11431156
11441157 await store .create_response (in_progress , [poison_item ], None )
1145- await store .update_response ({** in_progress , "status" : "failed" })
1158+ await store .update_response (cast ( ResponseObject , {** in_progress , "status" : "failed" }) )
11461159
11471160 persisted = await inner .get_response ("resp_stream_fail" )
11481161 input_items = await inner .get_input_items ("resp_stream_fail" , ascending = True )
@@ -1153,16 +1166,22 @@ async def test_omit_failed_conversation_input_provider_drops_known_failed_initia
11531166 inner = InMemoryResponseProvider ()
11541167 failed_response_ids = {"resp_failed" }
11551168 store = _OmitFailedConversationInputProvider (inner , failed_response_ids )
1156- poison_item : dict [str , Any ] = {
1157- "id" : "item_poison" ,
1158- "type" : "function_call_output" ,
1159- "call_id" : "call_12345abc" ,
1160- "output" : "example function call output" ,
1161- "status" : "completed" ,
1162- }
1169+ poison_item = cast (
1170+ OutputItem ,
1171+ {
1172+ "id" : "item_poison" ,
1173+ "type" : "function_call_output" ,
1174+ "call_id" : "call_12345abc" ,
1175+ "output" : "example function call output" ,
1176+ "status" : "completed" ,
1177+ },
1178+ )
11631179
11641180 await store .create_response (
1165- {"id" : "resp_failed" , "status" : "in_progress" , "conversation" : "conv-1" , "output" : []},
1181+ cast (
1182+ ResponseObject ,
1183+ {"id" : "resp_failed" , "status" : "in_progress" , "conversation" : "conv-1" , "output" : []},
1184+ ),
11661185 [poison_item ],
11671186 None ,
11681187 )
0 commit comments