langchain-ai/langgraph · error · RuntimeError

Called get_config outside of a runnable context

Error message

Called get_config outside of a runnable context

What it means

Raised by langgraph.config.get_config when there is no runnable context: the contextvar holding the current RunnableConfig is unset, so the call is happening outside graph/node execution (e.g. at module import time or in a plain script).

Solutions

  1. Call get_config() inside a node, tool, or function executed by the graph
  2. Pass the config explicitly down to the code that needs it instead of reading it from context
  3. Wrap the call in try/except RuntimeError when config access is optional
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at libs/langgraph/langgraph/config.py:29 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/d8c1025d3cf49a8a. Report an issue: GitHub.

Appendix: source

Thrown at libs/langgraph/langgraph/config.py:29


def _no_op_stream_writer(c: Any) -> None:
    pass


def get_config() -> RunnableConfig:
    if sys.version_info < (3, 11):
        try:
            if asyncio.current_task():
                raise RuntimeError(
                    "Python 3.11 or later required to use this in an async context"
                )
        except RuntimeError:
            pass
    if var_config := var_child_runnable_config.get():
        return var_config
    else:
        raise RuntimeError("Called get_config outside of a runnable context")


def get_store() -> BaseStore:
    """Access LangGraph store from inside a graph node or entrypoint task at runtime.

    Can be called from inside any [`StateGraph`][langgraph.graph.StateGraph] node or
    functional API [`task`][langgraph.func.task], as long as the `StateGraph` or the [`entrypoint`][langgraph.func.entrypoint]
    was initialized with a store, e.g.:

    ```python
    # with StateGraph
    graph = (
        StateGraph(...)
        ...
        .compile(store=store)
    )

    # or with entrypoint

View on GitHub (pinned to 38031739e5)