Dynamically Enabling/Disabling Graphs in a LangGraph Server at Runtime

I am using the LangGraph CLI to build a Docker image from a langgraph.json configuration that defines multiple graphs/agents. By default, when the container starts, all configured agents are available through the server endpoints.

I would like to keep a single reusable Docker image containing all agents, but selectively enable only a subset of agents at runtime based on an environment variable or configuration setting (for example, enabling only specific graphs per deployment without rebuilding the image).

Is there a recommended or supported approach for dynamically controlling which graphs/agents are exposed when the LangGraph server starts? Ideally, I would like to avoid maintaining separate Docker images for different agent combinations.

Thanks for any guidance.

Hey @mag

There isn’t a documented first-class knob like ENABLED_GRAPHS=agent,research that hot-disables graphs after the server is running. Graph exposure is determined at startup from the graphs map in langgraph.json, which the CLI turns into a LANGSERVE_GRAPHS env var in the Docker image (CLI / dockerfile). You can still use one image and choose which agents are registered per deployment by overriding that env var (or generating config in an entrypoint) before the process starts.

When you build with langgraph build / langgraph dockerfile , every entry under graphs in langgraph.json is baked into the image, e.g.

ENV LANGSERVE_GRAPHS='{"agent": "/deps/__outer_graphs/src/agent.py:graph", "storm": "/deps/__outer_graphs/src/storm.py:graph"}'

Check LangGraph CLI - Docs by LangChain

On startup, the Agent Server loads those graphs and creates a default assistant per graph (Assistants). That’s why “all configured agents” show up in the API by default.

Compiled graphs are loaded once at startup and reused (Agent Server – graph loading). Changing which graphs are registered requires a restart, not a live toggle.

What you can do is override LANGSERVE_GRAPHS at deploy time, build a fat image that includes all graph code, but register only the subset you want via container env:

docker run --env-file .env -p 8123:8000 \
  -e LANGSERVE_GRAPHS='{"agent":"/deps/__outer_graphs/src/agent.py:graph"}' \
  my-org/agents:1.2.3

Thanks @keenborder786 .

@mag if this solution works, can you mark the answer as solution so it is helpful for rest of the community.