Skip to content

fix(langgraph): treat clear_cache([]) as no-op instead of clearing all - #9337

Closed
zhgao wants to merge 1 commit into
langchain-ai:mainfrom
zhgao:fix/clear-cache-empty-nodes
Closed

zhgao wants to merge 1 commit into
langchain-ai:mainfrom
zhgao:fix/clear-cache-empty-nodes

Conversation

@zhgao

@zhgao zhgao commented Oct 16, 2026

Copy link
Copy Markdown

Closes #8960

Pregel.clear_cache([]) was treated the same as clear_cache(None), wiping every node's cache, because both the sync and async variants used nodes = nodes or self.nodes.keys(), which conflates an explicit empty list with "not given". Per the BaseCache contract, only None means "all nodes"; an explicit empty list should clear nothing.

Two-line fix: only fall back to all nodes when nodes is None. clear_cache(None) behavior is unchanged.

Tests: reproduced with the issue's own repro script (before: clear_cache([]) triggered recomputation; after: no-op for [], still clears all for None); existing cache tests green locally.

AI assistance disclosure: prepared with AI assistance; reproduced and verified locally.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically closed because you are not assigned to the linked issue.

External contributors must be assigned to an issue before opening a PR for it. Please:

  1. Comment on the linked issue to request assignment from a maintainer
  2. Once assigned, your PR will be reopened automatically

Maintainers: reopen this PR or remove the missing-issue-link label to bypass this check.

@github-actions github-actions Bot closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pregel.clear_cache([]) clears all node caches instead of being a no-op

1 participant