-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Random CancelledError in AsyncPregelLoop cleanup #6950
Description
Checked other resources
- This is a bug, not a usage question.
- I added a clear and descriptive title that summarizes this issue.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangGraph rather than my code.
- The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).
- This is not related to the langchain-community package.
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Reproduction Steps / Example Code (Python)
no reproduction :(Error Message and Stack Trace (if applicable)
CancelledError(<Task cancelled name='Task-39700' coro=<AsyncExitStack.__aexit__() done, defined at /usr/local/lib/python3.11/contextlib.py:698>>)Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/langgraph/pregel/main.py", line 2891, in astream
async with AsyncPregelLoop(
File "/usr/local/lib/python3.11/site-packages/langgraph/pregel/_loop.py", line 1323, in __aexit__
return await exit_task
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/contextlib.py", line 745, in __aexit__
raise exc_details[1]
File "/usr/local/lib/python3.11/contextlib.py", line 728, in __aexit__
cb_suppress = await cb(*exc_details)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langgraph/pregel/_executor.py", line 200, in __aexit__
await asyncio.wait(tasks)
File "/usr/local/lib/python3.11/asyncio/tasks.py", line 428, in wait
return await _wait(fs, timeout, return_when, loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/tasks.py", line 535, in _wait
await waiter
asyncio.exceptions.CancelledError: <Task cancelled name='Task-39700' coro=<AsyncExitStack.__aexit__() done, defined at /usr/local/lib/python3.11/contextlib.py:698>>Description
I'm experiencing random asyncio.CancelledError during AsyncPregelLoop cleanup phase when running agents on LangSmith Cloud.
The error occurs sporadically in production so I'm unable to create a reliable reproduction.
System Info
System Information
OS: Linux
OS Version: #1 SMP Mon Feb 16 11:19:06 UTC 2026
Python Version: 3.11.14 (main, Feb 24 2026, 19:56:57) [GCC 12.2.0]
Package Information
langchain_core: 1.2.15
langchain: 1.2.9
langchain_community: 0.4.1
langsmith: 0.7.6
langchain_anthropic: 1.3.3
langchain_classic: 1.0.1
langchain_openai: 1.1.9
langchain_postgres: 0.0.16
langchain_tavily: 0.2.17
langchain_text_splitters: 1.1.1
langgraph_api: 0.7.55
langgraph_cli: 0.4.12
langgraph_grpc_common: 0.1.0
langgraph_runtime_inmem: 0.26.0
langgraph_sdk: 0.3.6
Optional packages not installed
deepagents
deepagents-cli
Other Dependencies
aiohttp: 3.13.3
anthropic: 0.84.0
asyncpg: 0.31.0
blockbuster: 1.5.26
click: 8.3.1
cloudpickle: 3.1.2
croniter: 6.0.0
cryptography: 46.0.5
dataclasses-json: 0.6.7
grpcio: 1.78.1
grpcio-health-checking: 1.78.1
grpcio-tools: 1.78.0
httpx: 0.28.1
httpx-sse: 0.4.3
jsonpatch: 1.33
jsonschema-rs: 0.29.1
langgraph: 1.0.9
langgraph-checkpoint: 4.0.0
numpy: 2.4.2
openai: 2.24.0
opentelemetry-api: 1.39.1
opentelemetry-exporter-otlp-proto-http: 1.39.1
opentelemetry-sdk: 1.39.1
orjson: 3.10.16
packaging: 26.0
pgvector: 0.3.6
protobuf: 6.33.5
psycopg: 3.2.10
psycopg-pool: 3.3.0
pydantic: 2.11.10
pydantic-settings: 2.13.1
pyjwt: 2.11.0
pytest: 9.0.2
python-dotenv: 1.2.1
PyYAML: 6.0.3
pyyaml: 6.0.3
requests: 2.32.5
requests-toolbelt: 1.0.0
rich: 14.3.3
sqlalchemy: 2.0.47
SQLAlchemy: 2.0.47
sse-starlette: 2.1.3
starlette: 0.48.0
structlog: 25.5.0
tenacity: 9.1.4
tiktoken: 0.12.0
truststore: 0.10.4
typing-extensions: 4.15.0
uuid-utils: 0.14.1
uvicorn: 0.37.0
watchfiles: 1.1.1
xxhash: 3.6.0
zstandard: 0.25.0