@@ -87,6 +87,7 @@ async def _discover_tools_for_sample(self, sample_id: str, mcp_backend_ref: str)
8787
8888 try :
8989 backend_requests = [{"backend_name_ref" : mcp_backend_ref , "num_instances" : 1 }]
90+ assert self .mcp_intermediary_client is not None
9091 init_response = await self .mcp_intermediary_client .initialize_session (backend_requests )
9192
9293 if init_response .get ("error" ):
@@ -109,6 +110,7 @@ async def _discover_tools_for_sample(self, sample_id: str, mcp_backend_ref: str)
109110 current_instance_id = inst_info_dict .get ("instance_id" )
110111 if not current_instance_id :
111112 continue
113+ assert self .mcp_intermediary_client is not None
112114 list_tools_result = await self .mcp_intermediary_client .list_backend_tools (
113115 rk_session_id = rk_session_id ,
114116 instance_id = current_instance_id ,
@@ -130,6 +132,7 @@ async def _discover_tools_for_sample(self, sample_id: str, mcp_backend_ref: str)
130132 if rk_session_id and self .mcp_intermediary_client :
131133 logger .info (f"Sample { sample_id } : Cleaning up tool discovery session '{ rk_session_id } '." )
132134 try :
135+ assert self .mcp_intermediary_client is not None
133136 await self .mcp_intermediary_client .cleanup_session (rk_session_id )
134137 except Exception as e_cl :
135138 logger .error (
@@ -276,6 +279,7 @@ async def _execute_mcp_agent_rollout(
276279
277280 try :
278281 backend_requests = [{"backend_name_ref" : mcp_backend_ref , "num_instances" : 1 }]
282+ assert self .mcp_intermediary_client is not None
279283 init_response = await self .mcp_intermediary_client .initialize_session (backend_requests )
280284 if init_response .get ("error" ):
281285 raise RuntimeError (
@@ -331,6 +335,7 @@ async def _execute_mcp_agent_rollout(
331335 if not isinstance (tool_args_dict , dict ):
332336 raise ValueError ("Args not dict" )
333337
338+ assert self .mcp_intermediary_client is not None
334339 exec_result = await self .mcp_intermediary_client .call_backend_tool (
335340 rk_session_id = rk_session_id ,
336341 instance_id = primary_instance_id_for_agent_actions ,
@@ -405,6 +410,7 @@ async def _execute_mcp_agent_rollout(
405410 state_capture_tool = self .cfg .agent .get ("state_capture_tool" )
406411 if state_capture_tool :
407412 state_capture_args = dict (self .cfg .agent .get ("state_capture_args" , OmegaConf .create ({})))
413+ assert self .mcp_intermediary_client is not None
408414 final_filesystem_state_from_mcp = await self .mcp_intermediary_client .call_backend_tool (
409415 rk_session_id = rk_session_id ,
410416 instance_id = primary_instance_id_for_agent_actions ,
@@ -432,6 +438,7 @@ async def _execute_mcp_agent_rollout(
432438 }
433439 finally :
434440 if rk_session_id and self .mcp_intermediary_client :
441+ assert self .mcp_intermediary_client is not None
435442 await self .mcp_intermediary_client .cleanup_session (rk_session_id )
436443
437444 async def _process_single_sample (
0 commit comments