langchain-ai/langgraph · error · TypeError
An asyncio.Future, a coroutine or an awaitable is required.
Error message
An asyncio.Future, a coroutine or an awaitable is required. Got {type(coro_or_future).__name__} instead. What it means
Error "An asyncio.Future, a coroutine or an awaitable is required. Got {type(coro_or_future).__name__} instead." thrown in langchain-ai/langgraph.
Source
Thrown at libs/langgraph/langgraph/_internal/_future.py:159
def _ensure_future(
coro_or_future: Coroutine[None, None, T] | Awaitable[T],
*,
loop: asyncio.AbstractEventLoop,
name: str | None = None,
context: contextvars.Context | None = None,
lazy: bool = True,
) -> asyncio.Task[T]:
called_wrap_awaitable = False
if not asyncio.iscoroutine(coro_or_future):
if inspect.isawaitable(coro_or_future):
coro_or_future = cast(
Coroutine[None, None, T], _wrap_awaitable(coro_or_future)
)
called_wrap_awaitable = True
else:
raise TypeError(
"An asyncio.Future, a coroutine or an awaitable is required."
f" Got {type(coro_or_future).__name__} instead."
)
try:
if CONTEXT_NOT_SUPPORTED:
return loop.create_task(coro_or_future, name=name)
elif EAGER_NOT_SUPPORTED or lazy:
return loop.create_task(coro_or_future, name=name, context=context)
else:
return asyncio.eager_task_factory(
loop, coro_or_future, name=name, context=context
)
except RuntimeError:
if not called_wrap_awaitable:
coro_or_future.close()
raise
View on GitHub (pinned to 38031739e5)
When it happens
Trigger: Thrown at libs/langgraph/langgraph/_internal/_future.py:159 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26).
Data as JSON: /api/errors/22a2ddc01696f55d.
Report an issue: GitHub.