Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

message of type RemoveMessage is not handled in langchain- #28900

Open
5 tasks done
daher928 opened this issue Dec 24, 2024 · 3 comments
Open
5 tasks done

message of type RemoveMessage is not handled in langchain- #28900

daher928 opened this issue Dec 24, 2024 · 3 comments
Assignees
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: core Related to langchain-core investigate Flagged for investigation.

Comments

@daher928
Copy link

Checked other resources

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

Example Code

from langchain_openai.chat_models.base import _convert_message_to_dict
from langchain_core.messages import RemoveMessage
_convert_message_to_dict(RemoveMessage(id="1"))

Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
  File "/Users/projects/my-chat/main.py", line 23, in <module>
    _convert_message_to_dict(RemoveMessage(id="1"))
  File "/Users/.pyenv/versions/chat/lib/python3.11/site-packages/langchain_openai/chat_models/base.py", line 257, in _convert_message_to_dict
    raise TypeError(f"Got unknown type {message}")
TypeError: Got unknown type content='' additional_kwargs={} response_metadata={} id='1'

Description

In langchain_openai.chat_models.base (and more specifically in langchain_openai.chat_models.base._convert_message_to_dict) there is no handling of messages of type RemoveMessage and it fails over unknown type

System Info

System Information
------------------
> OS:  Darwin
> OS Version:  Darwin Kernel Version 23.6.0: Thu Sep 12 23:35:10 PDT 2024; root:xnu-10063.141.1.701.1~1/RELEASE_ARM64_T6030
> Python Version:  3.11.6 (main, Jun 24 2024, 09:02:31) [Clang 15.0.0 (clang-1500.3.9.4)]

Package Information
-------------------
> langchain_core: 0.3.28
> langchain: 0.3.13
> langchain_community: 0.3.13
> langsmith: 0.2.4
> langchain_experimental: 0.3.4
> langchain_openai: 0.2.14
> langchain_text_splitters: 0.3.4
> langgraph_api: 0.0.15
> langgraph_cli: 0.1.65
> langgraph_license: Installed. No version info available.
> langgraph_platform: Installed. No version info available.
> langgraph_sdk: 0.1.48
> langgraph_storage: Installed. No version info available.

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.11.11
> async-timeout: Installed. No version info available.
> click: 8.1.8
> cryptography: 43.0.3
> dataclasses-json: 0.6.7
> httpx: 0.28.1
> httpx-sse: 0.4.0
> jsonpatch: 1.33
> jsonschema-rs: 0.25.1
> langgraph: 0.2.60
> langgraph-checkpoint: 2.0.9
> langsmith-pyo3: Installed. No version info available.
> numpy: 1.26.4
> openai: 1.58.1
> orjson: 3.10.12
> packaging: 24.2
> pydantic: 2.10.4
> pydantic-settings: 2.7.0
> pyjwt: 2.10.1
> python-dotenv: 1.0.1
> PyYAML: 6.0.2
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> SQLAlchemy: 2.0.36
> sse-starlette: 2.1.3
> starlette: 0.41.3
> structlog: 24.4.0
> tenacity: 8.5.0
> tiktoken: 0.8.0
> typing-extensions: 4.12.2
> uvicorn: 0.34.0
> watchfiles: 1.0.3

@langcarl langcarl bot added the investigate Flagged for investigation. label Dec 24, 2024
@dosubot dosubot bot added Ɑ: core Related to langchain-core 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Dec 24, 2024
@daher928
Copy link
Author

@hwchase17 Hello Harrison, could you please take a lot at this issue?

@efriis
Copy link
Member

efriis commented Dec 24, 2024

Assigning to @vbarda ! I believe the RemoveMessage was intended as a langgraph feature, and we may want to add this as a feature of BaseChatModel to remove this confusion.

I don't think this is a regression (i.e. this always behaved this way). Let me know if that seems right to you!

@daher928
Copy link
Author

@efriis It happens when I try to remove messages from graph state in LangGraph and using Azure chat model

I would appreciate fixing it as soon as possible! :)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: core Related to langchain-core investigate Flagged for investigation.
Projects
None yet
Development

No branches or pull requests

3 participants