langchain-ai/langgraph · error · TypeError

A future is required for destination argument

Error message

A future is required for destination argument

What it means

Same guard as for source but on the 'destination' argument of _chain_future: the destination must be an asyncio or concurrent.futures Future, otherwise TypeError is raised because results/exceptions could not be copied into it.

Solutions

  1. Pass a future object as destination (e.g. loop.create_future()).
  2. Do not pass a plain coroutine or awaitable as destination.
Defensive patterns

Strategy: type-guard

When it happens

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

Appendix: source

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

            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:
                source_loop.call_soon_threadsafe(source.cancel)

    def _call_set_state(source: AnyFuture) -> None:
        if destination.cancelled() and dest_loop is not None and dest_loop.is_closed():

View on GitHub (pinned to 38031739e5)