@@ -611,7 +611,7 @@ def test_smolagents_llm_user_get_tool():
611611def test_smolagents_message_conversion_tool_call_attributes ():
612612 """Test _convert_smolagents_messages preserves tool_calls from ChatMessage objects."""
613613 from maseval .interface .agents .smolagents import SmolAgentAdapter
614- from smolagents .models import ChatMessage , MessageRole
614+ from smolagents .models import ChatMessage , ChatMessageToolCall , ChatMessageToolCallFunction , MessageRole
615615 from unittest .mock import Mock
616616
617617 mock_agent = Mock ()
@@ -621,18 +621,23 @@ def test_smolagents_message_conversion_tool_call_attributes():
621621
622622 adapter = SmolAgentAdapter (agent_instance = mock_agent , name = "msg_agent" )
623623
624- # Create ChatMessage with tool_calls attribute
625- msg = ChatMessage (role = MessageRole .ASSISTANT , content = "Using tool" )
626- msg .tool_calls = [{"id" : "call_1" , "function" : {"name" : "search" , "arguments" : '{"q": "test"}' }}]
624+ # Create ChatMessage with tool_calls attribute using proper types
625+ tool_call = ChatMessageToolCall (
626+ id = "call_1" ,
627+ type = "function" ,
628+ function = ChatMessageToolCallFunction (name = "search" , arguments = '{"q": "test"}' ),
629+ )
630+ msg = ChatMessage (role = MessageRole .ASSISTANT , content = "Using tool" , tool_calls = [tool_call ])
627631
628632 history = adapter ._convert_smolagents_messages ([msg ])
629633
630634 assert len (history ) == 1
631635 assert history [0 ]["role" ] == "assistant"
632636 assert history [0 ]["content" ] == "Using tool"
633637 assert "tool_calls" in history [0 ]
634- assert history [0 ]["tool_calls" ][0 ]["id" ] == "call_1"
635- assert history [0 ]["tool_calls" ][0 ]["function" ]["name" ] == "search"
638+ assert len (history [0 ]["tool_calls" ]) == 1
639+ assert history [0 ]["tool_calls" ][0 ].id == "call_1"
640+ assert history [0 ]["tool_calls" ][0 ].function .name == "search"
636641
637642
638643# =============================================================================
0 commit comments