[PR #651] [MERGED] langgraph: add support for deleting messages #1590

Closed
opened 2026-02-20 17:45:05 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraph/pull/651
Author: @vbarda
Created: 6/12/2024
Status: Merged
Merged: 7/3/2024
Merged by: @nfcampos

Base: mainHead: vb/add-delete-message


📝 Commits (10+)

  • 4239e6f (RFC) add support for deleting messages
  • 2ad6009 alternative design
  • 88b59d2 lint
  • 48a5d3d Revert "lint"
  • c83b90a Revert "alternative design"
  • f7a36f5 switch to lc core removemessage
  • 426098b Merge branch 'main' into vb/add-delete-message
  • a2a8b42 Merge branch 'main' into vb/add-delete-message
  • eb417d2 Merge branch 'main' into vb/add-delete-message
  • 4bbd03b lint

📊 Changes

2 files changed (+64 additions, -1 deletions)

View changed files

📝 libs/langgraph/langgraph/graph/message.py (+10 -1)
📝 libs/langgraph/tests/test_pregel.py (+54 -0)

📄 Description

This change allows users or graph nodes to remove messages by id via langchain_core.messages.RemoveMessage

Examples:

  • allow users to delete messages from state by calling
graph.update_state(config, values=[RemoveMessage(id=state.values[-1].id)])
  • allow nodes to delete messages
graph.add_node("delete_messages", lambda state: [RemoveMessage(id=state[-1].id)])

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraph/pull/651 **Author:** [@vbarda](https://github.com/vbarda) **Created:** 6/12/2024 **Status:** ✅ Merged **Merged:** 7/3/2024 **Merged by:** [@nfcampos](https://github.com/nfcampos) **Base:** `main` ← **Head:** `vb/add-delete-message` --- ### 📝 Commits (10+) - [`4239e6f`](https://github.com/langchain-ai/langgraph/commit/4239e6fdff41358758b0698fa1f716e86dc7f1ab) (RFC) add support for deleting messages - [`2ad6009`](https://github.com/langchain-ai/langgraph/commit/2ad60091603fb741cc0fd89519aa26235f72632b) alternative design - [`88b59d2`](https://github.com/langchain-ai/langgraph/commit/88b59d2aef1777955ffcef97efd9204cbdef536f) lint - [`48a5d3d`](https://github.com/langchain-ai/langgraph/commit/48a5d3d8383fcee1a46cb7eaa117141c3aba8215) Revert "lint" - [`c83b90a`](https://github.com/langchain-ai/langgraph/commit/c83b90a7b378462853127c2f6aac3cf4bd0e6a7d) Revert "alternative design" - [`f7a36f5`](https://github.com/langchain-ai/langgraph/commit/f7a36f53806b31c2f9de1dd2a9f4b24c556e2e18) switch to lc core removemessage - [`426098b`](https://github.com/langchain-ai/langgraph/commit/426098b07482c81e5b51a0dc3bdf45f38b748290) Merge branch 'main' into vb/add-delete-message - [`a2a8b42`](https://github.com/langchain-ai/langgraph/commit/a2a8b427fc64ea02fa2bd5f5a060668cfadfd271) Merge branch 'main' into vb/add-delete-message - [`eb417d2`](https://github.com/langchain-ai/langgraph/commit/eb417d2313b16d62dd57b496e741d839fa5b155d) Merge branch 'main' into vb/add-delete-message - [`4bbd03b`](https://github.com/langchain-ai/langgraph/commit/4bbd03be07a267d876401ffee9dbfd21b86a349e) lint ### 📊 Changes **2 files changed** (+64 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `libs/langgraph/langgraph/graph/message.py` (+10 -1) 📝 `libs/langgraph/tests/test_pregel.py` (+54 -0) </details> ### 📄 Description This change allows users or graph nodes to remove messages by `id` via `langchain_core.messages.RemoveMessage` Examples: * allow users to delete messages from state by calling ```python graph.update_state(config, values=[RemoveMessage(id=state.values[-1].id)]) ``` * allow nodes to delete messages ```python graph.add_node("delete_messages", lambda state: [RemoveMessage(id=state[-1].id)]) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-20 17:45:05 -05:00
yindo closed this issue 2026-02-20 17:45:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#1590