How to create an agent with memory that uses the GraphCypherQAChain?

I created a react-chat agent with memory with the cypher_qa tool. This tool is bassically GraphCypherQAChain:

from langchain_openai import ChatOpenAI
from langchain.prompts import PromptTemplate
from tools.cypher import cypher_qa
from langchain.chains.conversation.memory import ConversationBufferMemory
from langchain.agents import AgentExecutor, create_react_agent
from langchain.tools import Tool
from langchain import hub

llm = ChatOpenAI(openai_api_key="sk-")

prompt = PromptTemplate(
template="""
You are a movie expert. You find movies from a genre or plot.

ChatHistory:{chat_history}
Question:{input}
""",
input_variables=["chat_history", "input"],

)

memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)

tools = [
Tool.from_function(
name="Movie Chat",
description="For when you need to chat about movies. The question will be a string. Return a string.",
func=cypher_qa,
return_direct=True,
)
]

agent_prompt = hub.pull("hwchase17/react-chat")
agent = create_react_agent(llm, tools, agent_prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, memory=memory)

while True:
q = input("> ")
response = agent_executor.invoke({"input": q})
print(response["output"])

The cypher_qa tool works well and produces the cypher query and the results. But then I get an error when saving to memory:
pydantic.v1.error_wrappers.ValidationError: 2 validation errors for AIMessage
content
str type expected (type=type_error.str)
content
value is not a valid list (type=type_error.list)

I think the ouput from the tool is a list or dict and memory expects sting, but I cannot find out how to resolve it.