mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-21 15:12:26 +02:00
chore: format and lint fixes for DiffChannel implementation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
318fee9fc6
commit
ebd98f2e27
@@ -469,7 +469,9 @@ class PostgresSaver(BasePostgresSaver):
|
||||
break
|
||||
|
||||
payloads.reverse()
|
||||
result[channel] = DiffChainValue(base=base, deltas=[p["d"] for p in payloads])
|
||||
result[channel] = DiffChainValue(
|
||||
base=base, deltas=[p["d"] for p in payloads]
|
||||
)
|
||||
return result
|
||||
|
||||
def _load_checkpoint_tuple(self, value: DictRow) -> CheckpointTuple:
|
||||
|
||||
@@ -430,7 +430,9 @@ class AsyncPostgresSaver(BasePostgresSaver):
|
||||
break
|
||||
|
||||
payloads.reverse()
|
||||
result[channel] = DiffChainValue(base=base, deltas=[p["d"] for p in payloads])
|
||||
result[channel] = DiffChainValue(
|
||||
base=base, deltas=[p["d"] for p in payloads]
|
||||
)
|
||||
return result
|
||||
|
||||
async def _load_checkpoint_tuple(self, value: DictRow) -> CheckpointTuple:
|
||||
|
||||
@@ -208,7 +208,9 @@ class BasePostgresSaver(BaseCheckpointSaver[str]):
|
||||
|
||||
if diff_channel_payloads:
|
||||
result.update(
|
||||
self._load_diff_chains(thread_id, checkpoint_ns, diff_channel_payloads, cur=cur)
|
||||
self._load_diff_chains(
|
||||
thread_id, checkpoint_ns, diff_channel_payloads, cur=cur
|
||||
)
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
@@ -134,7 +134,7 @@ class InMemorySaver(
|
||||
continue
|
||||
vv = self.blobs[kk]
|
||||
if vv[0] == "diff":
|
||||
diff_channels[k] = v
|
||||
diff_channels[k] = str(v)
|
||||
elif vv[0] != "empty":
|
||||
channel_values[k] = self.serde.loads_typed(vv)
|
||||
|
||||
@@ -163,7 +163,9 @@ class InMemorySaver(
|
||||
break
|
||||
vv = self.blobs[kk]
|
||||
if vv[0] == "diff":
|
||||
payload = self.serde.loads_typed(vv) # {"d": [...], "p": version|None}
|
||||
payload = self.serde.loads_typed(
|
||||
vv
|
||||
) # {"d": [...], "p": version|None}
|
||||
chain_deltas.append(payload["d"])
|
||||
version = payload["p"]
|
||||
else:
|
||||
|
||||
@@ -9405,8 +9405,9 @@ def test_fork_does_not_apply_pending_writes(
|
||||
async def test_diff_channel_end_to_end_inmemory() -> None:
|
||||
"""Full graph run: DiffChannel accumulates correctly across multiple turns."""
|
||||
from langchain_core.messages import AIMessage, HumanMessage
|
||||
from langgraph.channels.diff import DiffChannel
|
||||
from langgraph.checkpoint.memory import InMemorySaver
|
||||
|
||||
from langgraph.channels.diff import DiffChannel
|
||||
from langgraph.graph import START, StateGraph
|
||||
from langgraph.graph.message import add_messages
|
||||
|
||||
@@ -9446,8 +9447,9 @@ async def test_diff_channel_end_to_end_inmemory() -> None:
|
||||
async def test_diff_channel_time_travel() -> None:
|
||||
"""Time-travel back to turn-1 checkpoint and resume; continuation must not include turn-2 deltas."""
|
||||
from langchain_core.messages import AIMessage, HumanMessage
|
||||
from langgraph.channels.diff import DiffChannel
|
||||
from langgraph.checkpoint.memory import InMemorySaver
|
||||
|
||||
from langgraph.channels.diff import DiffChannel
|
||||
from langgraph.graph import START, StateGraph
|
||||
from langgraph.graph.message import add_messages
|
||||
|
||||
@@ -9458,7 +9460,11 @@ async def test_diff_channel_time_travel() -> None:
|
||||
|
||||
def respond(state: State) -> dict:
|
||||
counter["n"] += 1
|
||||
return {"messages": [AIMessage(content=f"ai-{counter['n']}", id=f"ai-{counter['n']}")]}
|
||||
return {
|
||||
"messages": [
|
||||
AIMessage(content=f"ai-{counter['n']}", id=f"ai-{counter['n']}")
|
||||
]
|
||||
}
|
||||
|
||||
builder = StateGraph(State)
|
||||
builder.add_node("respond", respond)
|
||||
@@ -9488,7 +9494,9 @@ async def test_diff_channel_time_travel() -> None:
|
||||
)
|
||||
msgs = result["messages"]
|
||||
# Should be: h1, ai-1, h3, ai-N — 4 messages total
|
||||
assert len(msgs) == 4, f"expected 4 messages after time-travel resume, got {len(msgs)}: {msgs}"
|
||||
assert len(msgs) == 4, (
|
||||
f"expected 4 messages after time-travel resume, got {len(msgs)}: {msgs}"
|
||||
)
|
||||
assert msgs[0].content == "h1"
|
||||
assert msgs[1].content == "ai-1"
|
||||
assert msgs[2].content == "h3"
|
||||
|
||||
Reference in New Issue
Block a user