@@ -594,6 +594,110 @@ async def mock_request(method, params):
594594 finally :
595595 await client .force_stop ()
596596
597+ @pytest .mark .asyncio
598+ async def test_create_session_defaults_include_sub_agent_streaming_events_to_true (self ):
599+ client = CopilotClient (SubprocessConfig (cli_path = CLI_PATH ))
600+ await client .start ()
601+
602+ try :
603+ captured = {}
604+ original_request = client ._client .request
605+
606+ async def mock_request (method , params ):
607+ captured [method ] = params
608+ return await original_request (method , params )
609+
610+ client ._client .request = mock_request
611+ await client .create_session (
612+ on_permission_request = PermissionHandler .approve_all ,
613+ )
614+ assert captured ["session.create" ]["includeSubAgentStreamingEvents" ] is True
615+ finally :
616+ await client .force_stop ()
617+
618+ @pytest .mark .asyncio
619+ async def test_create_session_preserves_explicit_false_include_sub_agent_streaming_events (
620+ self ,
621+ ):
622+ client = CopilotClient (SubprocessConfig (cli_path = CLI_PATH ))
623+ await client .start ()
624+
625+ try :
626+ captured = {}
627+ original_request = client ._client .request
628+
629+ async def mock_request (method , params ):
630+ captured [method ] = params
631+ return await original_request (method , params )
632+
633+ client ._client .request = mock_request
634+ await client .create_session (
635+ on_permission_request = PermissionHandler .approve_all ,
636+ include_sub_agent_streaming_events = False ,
637+ )
638+ assert captured ["session.create" ]["includeSubAgentStreamingEvents" ] is False
639+ finally :
640+ await client .force_stop ()
641+
642+ @pytest .mark .asyncio
643+ async def test_resume_session_defaults_include_sub_agent_streaming_events_to_true (self ):
644+ client = CopilotClient (SubprocessConfig (cli_path = CLI_PATH ))
645+ await client .start ()
646+
647+ try :
648+ session = await client .create_session (
649+ on_permission_request = PermissionHandler .approve_all
650+ )
651+
652+ captured = {}
653+ original_request = client ._client .request
654+
655+ async def mock_request (method , params ):
656+ captured [method ] = params
657+ if method == "session.resume" :
658+ return {"sessionId" : session .session_id }
659+ return await original_request (method , params )
660+
661+ client ._client .request = mock_request
662+ await client .resume_session (
663+ session .session_id ,
664+ on_permission_request = PermissionHandler .approve_all ,
665+ )
666+ assert captured ["session.resume" ]["includeSubAgentStreamingEvents" ] is True
667+ finally :
668+ await client .force_stop ()
669+
670+ @pytest .mark .asyncio
671+ async def test_resume_session_preserves_explicit_false_include_sub_agent_streaming_events (
672+ self ,
673+ ):
674+ client = CopilotClient (SubprocessConfig (cli_path = CLI_PATH ))
675+ await client .start ()
676+
677+ try :
678+ session = await client .create_session (
679+ on_permission_request = PermissionHandler .approve_all
680+ )
681+
682+ captured = {}
683+ original_request = client ._client .request
684+
685+ async def mock_request (method , params ):
686+ captured [method ] = params
687+ if method == "session.resume" :
688+ return {"sessionId" : session .session_id }
689+ return await original_request (method , params )
690+
691+ client ._client .request = mock_request
692+ await client .resume_session (
693+ session .session_id ,
694+ on_permission_request = PermissionHandler .approve_all ,
695+ include_sub_agent_streaming_events = False ,
696+ )
697+ assert captured ["session.resume" ]["includeSubAgentStreamingEvents" ] is False
698+ finally :
699+ await client .force_stop ()
700+
597701 @pytest .mark .asyncio
598702 async def test_set_model_sends_correct_rpc (self ):
599703 client = CopilotClient (SubprocessConfig (cli_path = CLI_PATH ))
0 commit comments