FakeListLLM in create_react_agent doesn’t allow to use tools

Good morning,
I am trying to implement a fake LLM to use in create_react_agent. The FakeLLM is needed for testing purposes. I am struggling to use tools with the setup I’ve just described.

This is my code:

protein_info_retrieval.py

from langgraph.prebuilt import create_react_agent
from langgraph.checkpoint.sqlite import SqliteSaver
from langchain_google_vertexai import ChatVertexAI
from langchain_core.tools import tool
from langchain.tools import Tool

@tool
def uniprot_search(query: str) -> dict:
    """Searches the query on UNIPROT and returns the list of retrieved records"""
    return {"database":"uniprot", "id": "P12345","name":"TestProtein","sequence":"MKTWITNGG","function":"Unknown"}

@tool
def ncbi_search(query: str) -> dict:
    """Searches the query on NCBI and returns the list of retrieved records"""
    return {"database":"ncbi", "id": "P12345","name":"TestProtein","sequence":"MKTWITNGG","function":"Unknown"}

def create_protein_info_retrieval_agent(llm=None) -> callable:
    message = "You are a helpful assistant. Respond only in Spanish."

    _llm = llm if llm is not None else ChatVertexAI(model="gemini-pro")
    
    _toolkit = [uniprot_search, ncbi_search]
    
    agent_executor  = create_react_agent(model=_llm, 
                                        tools=_toolkit, 
                                        state_modifier=message, 
                                        debug=True)
    return agent_executor

mocked_objects.py

from typing import Optional, List, Any
from langchain_community.llms import FakeListLLM
from langchain.tools import tool
from langchain_core.callbacks import CallbackManagerForLLMRun
from langchain_core.messages import AIMessage

class MockFakeListLLM(FakeListLLM):

    def bind_tools(self, tools):
        # This is a mock implementation
        return self    

def fake_protein_info_llm():
# Step 1: Define the FakeListLLM with responses
response_uniprot =  "Thought: I need to use the Search tool to find information about LangChain.\nAction: Search\nAction Input: When was LangChain created?"
responses_ncbi =   "tool_calls="

    responses = [ response_uniprot, responses_ncbi]
    fake_llm = MockFakeListLLM(responses=responses)
    return fake_llm`

tests/test_protein_info_retrieval.py

from app.agents.protein_info_retrieval import create_protein_info_retrieval_agent
from tests.mocked_objects import *

def print_stream(stream):
    for s in stream:
        message = s["messages"][-1]
        if isinstance(message, tuple):
            print(message)
        else:
            message.pretty_print()

def test_create_protein_info_retrieval_agent():
    inputs = {"messages": [("user", "When was LangChain created?")]}
    llm = fake_protein_info_llm()
    agent = create_protein_info_retrieval_agent(llm=llm)  
    print_stream(agent.stream(inputs, stream_mode="values"))

When I run
poetry run pytest tests/test_protein_info_retrieval.py::test_create_protein_info_retrieval_agent

I get this error:

 def should_continue(state: AgentState):
messages = state["messages"]
last_message = messages[-1]
# If there is no function call, then we finish

>       if not last_message.tool_calls:

E       AttributeError: 'HumanMessage' object has no attribute 'tool_calls'

../.cache/pypoetry/virtualenvs/app-aIDH_6-R-py3.11/lib/python3.11/site-packages/langgraph/prebuilt/chat_agent_executor.py:565: AttributeError
======================================================================== short test summary info =========================================================================
FAILED tests/test_protein_info_retrieval.py::test_create_protein_info_retrieval_agent - AttributeError: 'HumanMessage' object has no attribute 'tool_calls'

Apparently, my LLM implementation lacks the ability to generate good prompt to be converted to tol calling.
Can somebody help me?

Thank you
your text
I tried to override also the _call method, but without any success.

I just want to have a reproducible way to use one tool or an other so that I can test my app.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật