With respect to CLIv2, the application has responsibility for maintaining session and request identifiers, which are returned from CLIv2 at session connection time and request initiation time, respectively.
Thus a program could connect a session in one program and then pass control to another program, passing the session identifier.
The subsequent program could issue requests against that session, providing the passed session identifier as input on the CLIv2 call.
Similarly, a program could initiate a request in one program and pass control to another program, passing the request identifier that was returned when the request was initiated.
The subsequent program could FETch results from the request, providing the passed request identifier as input to the CLIv2 call.