@@ -488,11 +488,18 @@ async def test_run_captures_assistant_usage_event(
488488 input_tokens = 5 ,
489489 output_tokens = 2 ,
490490 finish_reason = "length" ,
491+ content_filter_triggered = True ,
491492 ),
492493 id = uuid4 (),
493494 timestamp = datetime .now (timezone .utc ),
494495 type = SessionEventType .ASSISTANT_USAGE ,
495496 )
497+ empty_usage_event = SessionEvent (
498+ data = AssistantUsageData (model = "gpt-5.1-mini" ),
499+ id = uuid4 (),
500+ timestamp = datetime .now (timezone .utc ),
501+ type = SessionEventType .ASSISTANT_USAGE ,
502+ )
496503 usage_handler : Any = None
497504
498505 def mock_on (handler : Any ) -> Any :
@@ -503,6 +510,7 @@ def mock_on(handler: Any) -> Any:
503510 async def mock_send_and_wait (* args : Any , ** kwargs : Any ) -> SessionEvent :
504511 usage_handler (usage_event )
505512 usage_handler (second_usage_event )
513+ usage_handler (empty_usage_event )
506514 return assistant_message_event
507515
508516 mock_session .on = mock_on
@@ -511,7 +519,7 @@ async def mock_send_and_wait(*args: Any, **kwargs: Any) -> SessionEvent:
511519 agent = GitHubCopilotAgent (client = mock_client )
512520 response = await agent .run ("Hello" )
513521
514- assert response .finish_reason == "length "
522+ assert response .finish_reason == "content_filter "
515523 assert response .usage_details == {
516524 "input_token_count" : 125 ,
517525 "output_token_count" : 42 ,
@@ -596,7 +604,7 @@ async def test_run_streaming_captures_assistant_usage_event(
596604 model = "gpt-5.1-mini" ,
597605 input_tokens = 10 ,
598606 output_tokens = 4 ,
599- finish_reason = "stop " ,
607+ finish_reason = "provider_specific_reason " ,
600608 )
601609 usage_event = SessionEvent (
602610 data = usage_data ,
@@ -620,7 +628,7 @@ def mock_on(handler: Any) -> Any:
620628 response = await stream .get_final_response ()
621629
622630 assert response .text == "Hello"
623- assert response .finish_reason == "stop "
631+ assert response .finish_reason == "provider_specific_reason "
624632 assert response .usage_details == {
625633 "input_token_count" : 10 ,
626634 "output_token_count" : 4 ,
0 commit comments