Skip to content

Neo4jChatMessageHistory creates duplicate session nodes #70

@dpdlewis

Description

@dpdlewis

libs/neo4j/langchain_neo4j/chat_message_histories/neo4j.py
line 73:

    self._driver.execute_query(
        CREATE_SESSION_NODE_QUERY.format(node_label=self._node_label),
        {"session_id": self._session_id},
        database=self._database,
    )

This is now creating duplicate session nodes due to the below commit in the neo4j-graphrag-python

neo4j/neo4j-graphrag-python@18963b2#diff-95eebe4cb4f7674a0fcc3dec22df2d83b405e2944e516e2bc2d0b6da740532fc

The library used now runs a merge commit with createdAt appended, causing session nodes to be created every time you call Neo4jChatMessageHistory, regardless of passing in a previous sessionId.

Each session node created will also then have messages appended to them each time you create a new message, leading to exponential data increase.

The poetry.lock file uses version 1.6.1 of this library, but the pyproject.toml uses ^1.5.0. Perhaps setting it to 1.6.1 specifically will fix the issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions