Repository: langchain
Issue: NotImplementedError in RootListenersTracer.on_llm_end callback
Labels: 🤖:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.
- [X] I am sure that this is a bug in LangChain rather than my code.
- [X] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

### Example Code

from langchain_core.chat_history import BaseChatMessageHistory, InMemoryChatMessageHistory
from langchain_core.runnables.history import RunnableWithMessageHistory
from langchain_ollama import ChatOllama

llm = ChatOllama(base_url="http://127.0.0.1:32101",
                 model="qwen2:latest",
                 temperature=0.8,
                 num_predict=1024,
                 )

store = {}

def get_session_history(session_id: str) -> BaseChatMessageHistory:
    if session_id not in store:
        store[session_id] = InMemoryChatMessageHistory()
    return store[session_id]


with_message_history = RunnableWithMessageHistory(llm, get_session_history)
config = {"configurable": {"session_id": "abc2"}}
response = with_message_history.invoke(
    [("human", "编程.")],
    config=config,
)
print(response.content)

### Error Message and Stack Trace (if applicable)

当然，我很乐意帮助您解决编程问题。请告诉我具体需要帮助的内容：

1. 您正在使用哪种编程语言（例如：Python, Java, C++, JavaScript等）？
2. 需要实现的功能或项目类型是什么？
3. 遇到的具体问题或错误信息是什么？

比如如果您在学习 Python 并遇到了一些问题，您可以告诉我您在编写代码时遇到的特定错误、尝试运行但没有得到预期结果的部分代码或具体场景。这样我就能提供更具体的帮助和指导。

请提供更多详细信息以便我能更好地协助您！
NotImplementedError in RootListenersTracer.on_llm_end callback: NotImplementedError('Trying to load an object that doesn\'t implement serialization: {\'lc\': 1, \'type\': \'not_implemented\', \'id\': [\'ollama\', \'_types\', \'Message\'], \'repr\': "Message(role=\'assistant\', content=\'\', images=None, tool_calls=None)"}')


### Description

I'm trying to use langchain ChatOllama RunnableWithMessageHistory
I expect it to run normally
but An abnormality message has appeared
`NotImplementedError in RootListenersTracer.on_llm_end callback: NotImplementedError('Trying to load an object that doesn\'t implement serialization: {\'lc\': 1, \'type\': \'not_implemented\', \'id\': [\'ollama\', \'_types\', \'Message\'], \'repr\': "Message(role=\'assistant\', content=\'\', images=None, tool_calls=None)"}')`

### System Info

aiohappyeyeballs==2.4.4
aiohttp==3.11.9
aiosignal==1.3.1
annotated-types==0.7.0
anyio==4.6.2.post1
async-timeout==4.0.3
attrs==24.2.0
certifi==2024.8.30
charset-normalizer==3.4.0
distro==1.9.0
exceptiongroup==1.2.2
filelock==3.16.1
frozenlist==1.5.0
fsspec==2024.10.0
greenlet==3.1.1
h11==0.14.0
httpcore==1.0.7
httpx==0.27.2
huggingface-hub==0.26.3
idna==3.10
Jinja2==3.1.4
jiter==0.8.0
jsonpatch==1.33
jsonpointer==3.0.0
langchain==0.3.9
langchain-core==0.3.21
langchain-ollama==0.2.1
langchain-openai==0.2.11
langchain-text-splitters==0.3.2
langsmith==0.1.147
MarkupSafe==3.0.2
mpmath==1.3.0
multidict==6.1.0
networkx==3.4.2
numpy==1.26.4
ollama==0.4.2
openai==1.57.0
orjson==3.10.12
packaging==24.2
pandas==2.2.3
propcache==0.2.1
pydantic==2.10.3
pydantic_core==2.27.1
python-dateutil==2.9.0.post0
pytz==2024.2
PyYAML==6.0.2
regex==2024.11.6
requests==2.32.3
requests-toolbelt==1.0.0
safetensors==0.4.5
six==1.17.0
sniffio==1.3.1
SQLAlchemy==2.0.36
sympy==1.13.3
tenacity==9.0.0
tiktoken==0.8.0
tokenizers==0.20.3
torch==2.2.2
tqdm==4.67.1
transformers==4.46.3
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.2.3
yarl==1.18.3