langchain-ai/langgraph · error · TypeError

A future is required for source argument

Error message

A future is required for source argument

What it means

Type guard at the top of _chain_future: the 'source' argument is neither an asyncio.Future nor a concurrent.futures.Future, so chaining cannot be set up and TypeError is raised before attaching done-callbacks.

Solutions

  1. Pass a real future (asyncio.Future, concurrent.futures.Future, or a Task) as the source.
  2. If you have a coroutine, wrap it with asyncio.ensure_future first.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at libs/langgraph/langgraph/_internal/_future.py:92 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/dc42ab76d5556bbd. Report an issue: GitHub.

Appendix: source

Thrown at libs/langgraph/langgraph/_internal/_future.py:92

        exception = source.exception()
        if exception is not None:
            dest.set_exception(_convert_future_exc(exception))
        else:
            result = source.result()
            dest.set_result(result)


def _chain_future(source: AnyFuture, destination: AnyFuture) -> None:
    """Chain two futures so that when one completes, so does the other.

    The result (or exception) of source will be copied to destination.
    If destination is cancelled, source gets cancelled too.
    Compatible with both asyncio.Future and concurrent.futures.Future.
    """
    if not asyncio.isfuture(source) and not isinstance(
        source, concurrent.futures.Future
    ):
        raise TypeError("A future is required for source argument")
    if not asyncio.isfuture(destination) and not isinstance(
        destination, concurrent.futures.Future
    ):
        raise TypeError("A future is required for destination argument")
    source_loop = _get_loop(source) if asyncio.isfuture(source) else None
    dest_loop = _get_loop(destination) if asyncio.isfuture(destination) else None

    def _set_state(future: AnyFuture, other: AnyFuture) -> None:
        if asyncio.isfuture(future):
            _copy_future_state(other, future)
        else:
            _set_concurrent_future_state(future, other)

    def _call_check_cancel(destination: AnyFuture) -> None:
        if destination.cancelled():
            if source_loop is None or source_loop is dest_loop:
                source.cancel()
            else:

View on GitHub (pinned to 38031739e5)