@@ -42,6 +42,32 @@ def test_create_event_reports_a_distinct_id_per_hook_event() -> None:
4242 assert len (set (reported_ids )) == 2
4343
4444
45+ def test_create_event_reports_the_model_of_that_event () -> None :
46+ """A model switch starts no new conversation, so the conversation's model goes stale."""
47+ client , http_client = _build_client ()
48+ conversation_id = 'conv-1'
49+ # The same conversation before and after the user switched models.
50+ first = AIHookPayload (event_name = 'Prompt' , conversation_id = conversation_id , model = 'grok-4.6' )
51+ second = AIHookPayload (event_name = 'Prompt' , conversation_id = conversation_id , model = 'gpt-5.6-sol' )
52+
53+ client .create_event (first , AiHookEventType .PROMPT , AIHookOutcome .ALLOWED )
54+ client .create_event (second , AiHookEventType .PROMPT , AIHookOutcome .ALLOWED )
55+
56+ reported_models = [call .kwargs ['body' ]['model' ] for call in http_client .post .call_args_list ]
57+ assert reported_models == ['grok-4.6' , 'gpt-5.6-sol' ]
58+
59+
60+ def test_create_event_without_a_model_reports_none () -> None :
61+ """Not every IDE dialect resolves a model (e.g. a Claude Code transcript with no assistant turn yet)."""
62+ client , http_client = _build_client ()
63+
64+ client .create_event (
65+ AIHookPayload (event_name = 'Prompt' , conversation_id = 'conv-1' ), AiHookEventType .PROMPT , AIHookOutcome .ALLOWED
66+ )
67+
68+ assert _posted_body (http_client )['model' ] is None
69+
70+
4571def test_create_event_without_a_conversation_posts_nothing () -> None :
4672 client , http_client = _build_client ()
4773
0 commit comments