Changing keywords using Plugin API / Listener Interface on Browser Library

Hi Team,

I am trying to implement a Browser Grid (similar to Selenium Grid) for Browser Library executions. Basically, whenever I run a Browser library testcase, it should connect to one of the browser pods (I have 3 pods running one each for Firefox, chromium and webkit).
I have tried this using listener interface but I am not able to change the keyword using the start_library_keyword. I was able to partially do it at the start_test but there are lot of conditions it would fail and the arguments need to be handled.
I am now looking at PluginAPI which seems to be a better implementation since it doesn’t change the keyword in the log. I was able to define a keyword New Browser which connects to browser. Now when I do a similar approach for New Page or New Context, it throws a ‘maximum recursion depth exceeded’ error. Here’s a sample code of the plugin.

@keyword
def new_page(self,*args,**kwargs):
    print(f"Plugin -> New Page -> Arguments: {kwargs}")

self.library.connect_to_browser(wsEndpoint=“ws://localhost:52298/firefox”)
return self.library.new_page(*args, **kwargs)

Has anyone implemented a Browser Grid previously. If so, can you share how you implemented it?

Thanks,
VP