mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-27 03:55:00 +02:00
fix(delta-channel): fix chain assembly and get_state paths
- Fix InMemorySaver.get_channel_blob: use correct storage[thread_id][ns] nesting and deserialize the checkpoint before extracting channel_versions. - Pass checkpoint_id to after_checkpoint() in channels_from_checkpoint so DeltaChannel seeds _last_checkpoint_id correctly on load; without this every turn broke the chain at its boundary. - Wire _assemble_delta_channels into _prepare_state_snapshot and _aprepare_state_snapshot (get_state / get_state_history paths) and into perform_superstep / aperform_superstep (update_state paths) — previously only the loop __enter__ path did assembly. - Fix test_get_channel_blob to use the correct storage structure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
bae7486565
commit
4c2ce5c8a9
@@ -141,11 +141,11 @@ class InMemorySaver(
|
||||
channel: str,
|
||||
) -> Any:
|
||||
"""Fast-path blob lookup: checkpoint → channel version → blob."""
|
||||
ns_storage = self.storage.get((thread_id, checkpoint_ns), {})
|
||||
ns_storage = self.storage.get(thread_id, {}).get(checkpoint_ns, {})
|
||||
entry = ns_storage.get(checkpoint_id)
|
||||
if entry is None:
|
||||
return NotImplemented
|
||||
checkpoint = entry[1]
|
||||
checkpoint = self.serde.loads_typed(entry[0])
|
||||
version = checkpoint["channel_versions"].get(channel)
|
||||
if version is None:
|
||||
return NotImplemented
|
||||
|
||||
@@ -326,7 +326,9 @@ class TestInMemorySaverDeltaChannel:
|
||||
cp = empty_checkpoint()
|
||||
cp["id"] = "cp1"
|
||||
cp["channel_versions"][channel] = version
|
||||
saver.storage[(thread_id, ns)] = {"cp1": ({}, cp, {})}
|
||||
saver.storage[thread_id][ns] = {
|
||||
"cp1": (serde.dumps_typed(cp), serde.dumps_typed({}), None)
|
||||
}
|
||||
|
||||
result = saver.get_channel_blob(thread_id, ns, "cp1", channel)
|
||||
assert isinstance(result, DeltaValue)
|
||||
@@ -336,4 +338,6 @@ class TestInMemorySaverDeltaChannel:
|
||||
def test_get_channel_blob_missing(self) -> None:
|
||||
"""get_channel_blob returns NotImplemented when checkpoint or channel not found."""
|
||||
saver = InMemorySaver()
|
||||
assert saver.get_channel_blob("t1", "", "no-such-cp", "messages") is NotImplemented
|
||||
assert (
|
||||
saver.get_channel_blob("t1", "", "no-such-cp", "messages") is NotImplemented
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user