@@ -96,3 +96,32 @@ def test_structured_output(model):
9696 response = model .structured_output (Person )
9797
9898 assert response == Person (name = "test" , age = 20 )
99+
100+
101+ def test_converse_logging (model , messages , tool_specs , system_prompt , caplog ):
102+ """Test that converse method logs the formatted request at debug level."""
103+ import logging
104+
105+ # Set the logger to debug level to capture debug messages
106+ caplog .set_level (logging .DEBUG , logger = "strands.types.models.model" )
107+
108+ # Execute the converse method
109+ response = model .converse (messages , tool_specs , system_prompt )
110+ list (response ) # Consume the generator to trigger all logging
111+
112+ # Check that the expected log messages are present
113+ assert "formatting request" in caplog .text
114+ assert "formatted request=" in caplog .text
115+ assert "invoking model" in caplog .text
116+ assert "got response from model" in caplog .text
117+ assert "finished streaming response from model" in caplog .text
118+
119+ # Check that the formatted request is logged with the expected content
120+ expected_request_str = str (
121+ {
122+ "messages" : messages ,
123+ "tool_specs" : tool_specs ,
124+ "system_prompt" : system_prompt ,
125+ }
126+ )
127+ assert expected_request_str in caplog .text
0 commit comments