Skip to content

Avoid caching sync error and interrupt writes#7114

Open
Alexxigang wants to merge 2 commits intolangchain-ai:mainfrom
Alexxigang:fix/sync-cache-ignore-error-interrupt
Open

Avoid caching sync error and interrupt writes#7114
Alexxigang wants to merge 2 commits intolangchain-ai:mainfrom
Alexxigang:fix/sync-cache-ignore-error-interrupt

Conversation

@Alexxigang
Copy link

Summary

Fixes a sync-only cache inconsistency where SyncPregelLoop.put_writes() cached ERROR and INTERRUPT task writes even though the async path already skips them.

That could poison the sync cache with failed/interrupted task results. In practice, repeated invocations could replay cached failures instead of re-running the task, and cached interrupt() writes could be replayed into the sync scheduler and crash with IndexError: deque index out of range.

Changes

  • add the same ERROR / INTERRUPT cache guard to SyncPregelLoop.put_writes() that already exists in AsyncPregelLoop.put_writes()
  • add targeted regression coverage for sync and async task caching behavior
  • verify that:
    • error writes are never cached
    • interrupt writes are never cached
    • successful writes are still cached
    • cache keys remain input-specific for successful writes

Testing

python -m py_compile libs/langgraph/langgraph/pregel/_loop.py libs/langgraph/tests/test_sync_cache_guard.py
python -m pytest --noconftest libs/langgraph/tests/test_sync_cache_guard.py -q

Passed locally:

  • 8 passed in 0.23s

Issue

Closes #7015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: SyncPregelLoop.put_writes caches ERROR/INTERRUPT writes (async has guard, sync does not)

1 participant