From f02c0f0ce575ce1d3879b09ee3c534446c31a983 Mon Sep 17 00:00:00 2001 From: ccurme Date: Tue, 21 Jul 2026 15:57:18 -0400 Subject: [PATCH] feat(langgraph): drop tags from TracePolicy (#8402) --- libs/langgraph/langgraph/graph/state.py | 5 +---- libs/langgraph/langgraph/types.py | 5 +---- libs/langgraph/tests/test_trace_policy.py | 23 +---------------------- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/libs/langgraph/langgraph/graph/state.py b/libs/langgraph/langgraph/graph/state.py index 297db4989..0e0df9157 100644 --- a/libs/langgraph/langgraph/graph/state.py +++ b/libs/langgraph/langgraph/graph/state.py @@ -700,8 +700,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): trace_policy: Optional policy controlling how this node's run is traced. Its `process_inputs` callable transforms the node's input before it is recorded (e.g. to omit or summarize large message history) without - changing the value passed to the node, and `tags` attaches tags to the - run (e.g. to hide it from the trace tree). Does not affect execution. + changing the value passed to the node. Does not affect execution. destinations: Destinations that indicate where a node can route to. Useful for edgeless graphs with nodes that return `Command` objects. @@ -1529,7 +1528,6 @@ class CompiledStateGraph( if node.defer else EphemeralValue(Any, guard=False) ) - trace_tags = node.trace_policy.tags if node.trace_policy else None self.nodes[key] = PregelNode( triggers=[branch_channel], # read state keys and managed values @@ -1538,7 +1536,6 @@ class CompiledStateGraph( mapper=mapper, # publish to state keys writers=[ChannelWrite(write_entries)], - tags=list(trace_tags) if trace_tags else None, metadata=node.metadata, retry_policy=node.retry_policy, cache_policy=node.cache_policy, diff --git a/libs/langgraph/langgraph/types.py b/libs/langgraph/langgraph/types.py index e79ecfb3d..8175e47e9 100644 --- a/libs/langgraph/langgraph/types.py +++ b/libs/langgraph/langgraph/types.py @@ -3,7 +3,7 @@ from __future__ import annotations import sys from collections import deque from collections.abc import Callable, Hashable, Sequence -from dataclasses import asdict, dataclass, field +from dataclasses import asdict, dataclass from datetime import timedelta from typing import ( TYPE_CHECKING, @@ -547,9 +547,6 @@ class TracePolicy: node's trace run. Use to omit or summarize large payloads (e.g. message history). Does not affect the value passed to the node.""" - tags: list[str] = field(default_factory=list) - """Tags to attach to this node's trace run.""" - _DEFAULT_INTERRUPT_ID = "placeholder-id" diff --git a/libs/langgraph/tests/test_trace_policy.py b/libs/langgraph/tests/test_trace_policy.py index e04dcc9e5..e72d0299c 100644 --- a/libs/langgraph/tests/test_trace_policy.py +++ b/libs/langgraph/tests/test_trace_policy.py @@ -1,4 +1,4 @@ -"""End-to-end tests for `TracePolicy` (input processing + hidden tag) on node runs.""" +"""End-to-end tests for `TracePolicy` input processing on node trace runs.""" from typing import Any @@ -86,24 +86,3 @@ async def test_trace_policy_transforms_recorded_inputs_async() -> None: run = _node_run(tracer, "n") assert run.inputs == {"scrubbed_in": True} assert run.outputs == {"value": 6} - - -def test_trace_policy_tags_applied_to_run() -> None: - graph = ( - StateGraph(State) - .add_node("shown", _incr) - .add_node( - "hush", _incr, trace_policy=TracePolicy(tags=["langsmith:hidden_middleware"]) - ) - .add_edge(START, "shown") - .add_edge("shown", "hush") - .add_edge("hush", END) - .compile() - ) - - tracer = FakeTracer() - graph.invoke({"value": 0}, {"callbacks": [tracer]}) - - # the policy's tags land on the node's run; other nodes are unaffected - assert "langsmith:hidden_middleware" in _node_run(tracer, "hush").tags - assert "langsmith:hidden_middleware" not in _node_run(tracer, "shown").tags