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:
Sydney Runkle
2026-04-21 10:40:00 -04:00
co-authored by Claude Sonnet 4.6
parent bae7486565
commit 4c2ce5c8a9
8 changed files with 270 additions and 72 deletions
+6 -2
View File
@@ -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
)