Skip to content

Strip message ID to improve cache performance #33883

@mdrxy

Description

@mdrxy

Checked other resources

  • This is a feature request, not a bug report or usage question.
  • I added a clear and descriptive title that summarizes the feature request.
  • I used the GitHub search to find a similar feature request and didn't find it.
  • I checked the LangChain documentation and API reference to see if this feature already exists.
  • This is not related to the langchain-community package.

Feature Description

Implement message ID normalization for improved caching efficiency with chat models.

Messages have unique IDs which are used as part of the cache keys generation process, causing functionally identical messages to create separate cache entries.

This feature would add a _strip_ids_from_messages function to normalize messages before cache key generation, ensuring that messages with identical content produce cache hits regardless of their unique identifiers.

Use Case

Messages with identical content but different IDs bypass cache hits, leading to reduced cache effectiveness and hit rates.

Proposed Solution

No response

Alternatives Considered

No response

Additional Context

Original attempt in #32642

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRelated to the package `langchain-core`feature requestrequest for an enhancement / additional functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions