Skip to content

feat: implement checkpoint deletion after successful graph run#971

Open
mic3b wants to merge 1 commit intocloudwego:mainfrom
mic3b:feat/delete-checkpoint-after-run
Open

feat: implement checkpoint deletion after successful graph run#971
mic3b wants to merge 1 commit intocloudwego:mainfrom
mic3b:feat/delete-checkpoint-after-run

Conversation

@mic3b
Copy link
Copy Markdown

@mic3b mic3b commented Apr 15, 2026

What type of PR is this?

feat: implement checkpoint deletion after successful graph run

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
Currently, after a graph run resumes from an interrupt and completes successfully, the checkpoint
written to the CheckPointStore is never cleaned up. This causes stale checkpoints to accumulate in
the store indefinitely.

This PR adds an opt-in mechanism to automatically delete the checkpoint when a graph run finishes
successfully.

API changes:

  1. A new optional interface CheckPointDeleter (in both internal/core and exported via compose)
    that CheckPointStore implementations can satisfy:
  type CheckPointDeleter interface {
      Delete(ctx context.Context, checkPointID string) error
  }
  1. A new call option WithDeleteCheckpointAfterRun():
  result, err := runnable.Invoke(ctx, input,
      compose.WithCheckPointID("session-123"),
      compose.WithDeleteCheckpointAfterRun(),
  )

Behaviour:

  • The checkpoint is deleted only on successful completion. It is preserved on interrupt so that
    execution can be resumed.
  • Deletion is performed against writeToCheckPointID (which defaults to checkPointID).
  • If the store does not implement CheckPointDeleter, the option is silently ignored — no error,
    full backward compatibility.
  • Deletion is only triggered at the top-level graph, not inside subgraphs.

zh(optional):

目前,图(graph)从中断恢复并成功完成后,写入 CheckPointStore
的检查点不会被清理,导致存储中积累过期的检查点数据。

本 PR 引入了一种可选机制,在图运行成功完成时自动删除检查点。

新增可选接口 CheckPointDeleter,CheckPointStore 的实现可自行选择是否满足该接口。新增调用选项
WithDeleteCheckpointAfterRun():仅在成功完成时删除检查点,中断时保留;若 store 未实现
CheckPointDeleter,则静默忽略,完全向后兼容。

(Optional) Which issue(s) this PR fixes:

Fixes #870

(optional) The PR that updates user documentation:

Will update it when PR is accepted

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 15, 2026

CLA assistant check
All committers have signed the CLA.

@shentongmartin shentongmartin added C-enhancement Category: This is a PR that adds a new feature or fixes a bug. D-checkpoint labels Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-enhancement Category: This is a PR that adds a new feature or fixes a bug. D-checkpoint

Development

Successfully merging this pull request may close these issues.

Option to delete a checkpoint after resumption

3 participants