Compare commits

...
Author SHA1 Message Date
William Fu-Hinthorn 666052e6b4 fix(langgraph); Remote baggage 2025-08-19 18:33:18 -07:00
William Fu-Hinthorn b333ffc7bf release(langgraph): 0.6.6 2025-08-18 12:57:38 -07:00
5 changed files with 24 additions and 19 deletions
+9 -9
View File
@@ -733,9 +733,9 @@ class RemoteGraph(PregelProtocol):
interrupt_after=interrupt_after, interrupt_after=interrupt_after,
stream_subgraphs=subgraphs or stream is not None, stream_subgraphs=subgraphs or stream is not None,
if_not_exists="create", if_not_exists="create",
headers=_merge_tracing_headers(headers) headers=(
if self.distributed_tracing _merge_tracing_headers(headers) if self.distributed_tracing else headers
else headers, ),
params=params, params=params,
**kwargs, **kwargs,
): ):
@@ -842,9 +842,9 @@ class RemoteGraph(PregelProtocol):
interrupt_after=interrupt_after, interrupt_after=interrupt_after,
stream_subgraphs=subgraphs or stream is not None, stream_subgraphs=subgraphs or stream is not None,
if_not_exists="create", if_not_exists="create",
headers=_merge_tracing_headers(headers) headers=(
if self.distributed_tracing _merge_tracing_headers(headers) if self.distributed_tracing else headers
else headers, ),
params=params, params=params,
**kwargs, **kwargs,
): ):
@@ -996,11 +996,11 @@ class RemoteGraph(PregelProtocol):
def _merge_tracing_headers(headers: dict[str, str] | None) -> dict[str, str] | None: def _merge_tracing_headers(headers: dict[str, str] | None) -> dict[str, str] | None:
if rt := ls.get_current_run_tree(): if rt := ls.get_current_run_tree():
tracing_headers = rt.to_headers() tracing_headers = rt.to_headers()
baggage = tracing_headers.pop("baggage")
if headers: if headers:
if "baggage" in headers: if "baggage" in headers:
baggage = headers["baggage"] + "," + baggage tracing_headers["baggage"] = (
tracing_headers["baggage"] = baggage f"{headers['baggage']},{tracing_headers['baggage']}"
)
headers.update(tracing_headers) headers.update(tracing_headers)
else: else:
headers = tracing_headers headers = tracing_headers
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "langgraph" name = "langgraph"
version = "0.6.5" version = "0.6.7"
description = "Building stateful, multi-actor applications with LLMs" description = "Building stateful, multi-actor applications with LLMs"
authors = [] authors = []
requires-python = ">=3.9" requires-python = ">=3.9"
+12 -7
View File
@@ -1183,7 +1183,10 @@ async def test_remote_graph_stream_messages_tuple(
@pytest.mark.anyio @pytest.mark.anyio
@pytest.mark.parametrize("distributed_tracing", [False, True]) @pytest.mark.parametrize("distributed_tracing", [False, True])
@pytest.mark.parametrize("stream", [False, True]) @pytest.mark.parametrize("stream", [False, True])
async def test_include_headers(distributed_tracing: bool, stream: bool): @pytest.mark.parametrize("headers", [None, {"foo": "bar"}])
async def test_include_headers(
distributed_tracing: bool, stream: bool, headers: dict[str, str] | None
):
mock_async_client = MagicMock() mock_async_client = MagicMock()
async_iter = MagicMock() async_iter = MagicMock()
return_value = [ return_value = [
@@ -1213,7 +1216,7 @@ async def test_include_headers(distributed_tracing: bool, stream: bool):
async for _ in remote_pregel.astream( async for _ in remote_pregel.astream(
{"input": {"messages": [{"type": "human", "content": "hello"}]}}, {"input": {"messages": [{"type": "human", "content": "hello"}]}},
config, config,
headers={"foo": "bar"}, headers=headers,
): ):
pass pass
@@ -1221,12 +1224,14 @@ async def test_include_headers(distributed_tracing: bool, stream: bool):
await remote_pregel.ainvoke( await remote_pregel.ainvoke(
{"input": {"messages": [{"type": "human", "content": "hello"}]}}, {"input": {"messages": [{"type": "human", "content": "hello"}]}},
config, config,
headers={"foo": "bar"}, headers=headers,
) )
expected = {"foo": "bar"} expected = headers.copy() if headers else None
if distributed_tracing: if distributed_tracing:
if expected is None:
expected = {}
expected["langsmith-trace"] = AnyStr() expected["langsmith-trace"] = AnyStr()
expected["baggage"] = AnyStr() expected["baggage"] = AnyStr("langsmith-metadata=")
assert astream_mock.call_args.kwargs["headers"] == expected assert astream_mock.call_args.kwargs["headers"] == expected
stream_mock.assert_not_called() stream_mock.assert_not_called()
@@ -1237,7 +1242,7 @@ async def test_include_headers(distributed_tracing: bool, stream: bool):
for _ in remote_pregel.stream( for _ in remote_pregel.stream(
{"input": {"messages": [{"type": "human", "content": "hello"}]}}, {"input": {"messages": [{"type": "human", "content": "hello"}]}},
config, config,
headers={"foo": "bar"}, headers=headers,
): ):
pass pass
@@ -1245,6 +1250,6 @@ async def test_include_headers(distributed_tracing: bool, stream: bool):
remote_pregel.invoke( remote_pregel.invoke(
{"input": {"messages": [{"type": "human", "content": "hello"}]}}, {"input": {"messages": [{"type": "human", "content": "hello"}]}},
config, config,
headers={"foo": "bar"}, headers=headers,
) )
assert stream_mock.call_args.kwargs["headers"] == expected assert stream_mock.call_args.kwargs["headers"] == expected
+1 -1
View File
@@ -1269,7 +1269,7 @@ wheels = [
[[package]] [[package]]
name = "langgraph" name = "langgraph"
version = "0.6.5" version = "0.6.7"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "langchain-core" }, { name = "langchain-core" },
+1 -1
View File
@@ -316,7 +316,7 @@ wheels = [
[[package]] [[package]]
name = "langgraph" name = "langgraph"
version = "0.6.5" version = "0.6.6"
source = { editable = "../langgraph" } source = { editable = "../langgraph" }
dependencies = [ dependencies = [
{ name = "langchain-core" }, { name = "langchain-core" },