Tags are duplicated at every subgraph level since 1.2.3 (2^depth copies)
Checked other resources
- This is a bug, not a usage question.
- I added a clear and descriptive title that summarizes this issue.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangGraph rather than my code.
- The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).
- This is not related to the langchain-community package.
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Related Issues / PRs
- #7926 (changed
ensure_configfrom overwrite to merge; the duplication starts here) - #8038 (sibling 1.2.3 regression from the same #7926 ambient merge)
- #8053 (fixed #8038; only touches
configurablecheckpoint keys, not tags)
Reproduction Steps / Example Code (Python)
from langchain_core.runnables import RunnableConfig
from typing_extensions import TypedDict
from langgraph.graph import START, StateGraph
class State(TypedDict):
copies: int
def leaf(state: State, config: RunnableConfig) -> State:
return {"copies": config["tags"].count("my-tag")}
def build(depth: int):
builder = StateGraph(State)
builder.add_node("leaf", leaf)
builder.add_edge(START, "leaf")
graph = builder.compile()
for _ in range(depth):
builder = StateGraph(State)
builder.add_node("sub", graph)
builder.add_edge(START, "sub")
graph = builder.compile()
return graph
for depth in range(4):
out = build(depth).invoke({"copies": 0}, {"tags": ["my-tag"]})
print(f"subgraph depth {depth}: leaf sees 'my-tag' {out['copies']}x")Error Message and Stack Trace (if applicable)
# langgraph 1.2.12 (also 1.2.3, 1.2.4, main)
subgraph depth 0: leaf sees 'my-tag' 1x
subgraph depth 1: leaf sees 'my-tag' 2x
subgraph depth 2: leaf sees 'my-tag' 4x
subgraph depth 3: leaf sees 'my-tag' 8x
# langgraph 1.2.2
subgraph depth 0: leaf sees 'my-tag' 1x
subgraph depth 1: leaf sees 'my-tag' 1x
subgraph depth 2: leaf sees 'my-tag' 1x
subgraph depth 3: leaf sees 'my-tag' 1xDescription
Tags passed at invoke time (or bound on the outer graph with with_config) are doubled at each subgraph level, so a node three subgraphs deep gets 8 copies of every tag. The same copies show up in config["tags"] inside nodes, in callback handlers, custom BaseTracer subclasses and astream_events (8x my-tag on the leaf's on_chain_start with the repro above; the repro's async variants need Python 3.11+ to show it). LangSmith traces look fine because LangChainTracer dedupes tags before posting. Only tags are affected: metadata and callback handlers are not duplicated (each handler fires once). The repro uses a plain compiled subgraph as a node, no custom config handling.
It also happens when a node or tool passes its own config to a nested graph, e.g. subgraph.invoke(state, config) (agents as tools); each such call doubles them again (2x, 4x, 8x for 1, 2, 3 nested forwards), while subgraph.invoke(state) gives 1x. On Python 3.10, async nodes that forward their config show 1x, but async tools that do so still show 2x. deepagents stopped forwarding the parent's callbacks/tags/configurable to subagents because of this (comment: "Forwarding those keys explicitly would double-count under the merge (e.g. duplicate tags)").
Expected: each tag appears once, as in 1.2.2.
Cause: ensure_config in langgraph/_internal/_config.py starts from the ambient var_child_runnable_config, which already holds the parent's tags, then appends the tags of each explicit config. Since #7926 this is a concatenation instead of an overwrite. The config passed to the subgraph carries the same tags as the ambient one (RunnableSeq.invoke sets it as the context and passes it explicitly), so each level adds them again. #8053 fixed a related ambient-vs-explicit problem after #7926, but only for configurable checkpoint keys; tags are still concatenated onto the ambient ones.
Possible fix: when merging explicit tags, skip the ones already inherited from the ambient config. That keeps what #7926 wanted (tags bound with with_config survive, explicit configs still concatenate (tags already inherited from the ambient config are not appended again), test_ensure_config_tags_concat_preserves_order_and_duplicates still passes) and removes the doubling. I have this working locally with two regression tests and the libs/langgraph suite passing (without Docker, so the postgres/redis/remote-graph variants were not run). Happy to open a PR if you're OK with the approach.
System Info
System Information
------------------
> OS: Darwin
> OS Version: Darwin Kernel Version 25.5.0: Tue Jun 9 22:28:17 PDT 2026; root:xnu-12377.121.10~1/RELEASE_ARM64_T8142
> Python Version: 3.14.2 (main, Jan 14 2026, 23:37:46) [Clang 21.1.4 ]
Package Information
-------------------
> langchain_core: 1.6.5
> langsmith: 0.14.1
> langchain_protocol: 0.0.19
> langgraph_sdk: 0.4.5langgraph 1.2.12 (sys_info does not list it).
Source: langchain-ai/langgraph