langchain-ai/langgraph · error · TypeError

callbacks must be a handler, sequence, or manager

Error message

callbacks must be a handler, sequence, or manager

What it means

_map_graph_callbacks coerces the 'callbacks' argument into a graph callback manager; after handler/manager/sequence cases are exhausted, a str/bytes or other non-Sequence value is rejected with TypeError because it cannot be interpreted as callbacks.

Solutions

  1. Pass a GraphCallbackHandler, a list/sequence of handlers, or a callback manager.
  2. Strings and bytes are not accepted — check for a wrongly-serialized callbacks value.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at libs/langgraph/langgraph/callbacks.py:190 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/0fc2c0ef50a90877. Report an issue: GitHub.

Appendix: source

Thrown at libs/langgraph/langgraph/callbacks.py:190

            metadata=callbacks.metadata.copy(),
            inheritable_metadata=callbacks.inheritable_metadata.copy(),
            run_id=run_id,
        )
    if isinstance(callbacks, BaseCallbackManager):
        return cls(
            handlers=_filter_graph_handlers(callbacks.handlers),
            inheritable_handlers=_filter_graph_handlers(callbacks.inheritable_handlers),
            parent_run_id=callbacks.parent_run_id,
            tags=callbacks.tags.copy(),
            inheritable_tags=callbacks.inheritable_tags.copy(),
            metadata=callbacks.metadata.copy(),
            inheritable_metadata=callbacks.inheritable_metadata.copy(),
            run_id=run_id,
        )
    if isinstance(callbacks, GraphCallbackHandler):
        return cls((callbacks,), run_id=run_id)
    if isinstance(callbacks, (str, bytes)) or not isinstance(callbacks, Sequence):
        raise TypeError("callbacks must be a handler, sequence, or manager")
    return cls(_filter_graph_handlers(list(callbacks)), run_id=run_id)


def _copy_graph_manager(
    manager: _GraphCallbackManager | _AsyncGraphCallbackManager,
    cls: type[_GraphManagerT],
    run_id: UUID | None | object,
) -> _GraphManagerT:
    resolved_run_id: UUID | None
    if run_id is _MISSING:
        resolved_run_id = manager.run_id
    else:
        if run_id is not None and not isinstance(run_id, UUID):
            raise TypeError("run_id must be a UUID or None")
        resolved_run_id = run_id

    return cls(
        handlers=_filter_graph_handlers(manager.handlers),

View on GitHub (pinned to 38031739e5)