mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-21 07:02:25 +02:00
Better error message on invalid use lf lastvalue channel
This commit is contained in:
@@ -44,7 +44,7 @@ class LastValue(Generic[Value], BaseChannel[Value, Value, Value]):
|
||||
if len(values) == 0:
|
||||
return
|
||||
if len(values) != 1:
|
||||
raise InvalidUpdateError()
|
||||
raise InvalidUpdateError("LastValue can only receive one value per step.")
|
||||
|
||||
self.value = values[-1]
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ from langgraph.channels.base import (
|
||||
BaseChannel,
|
||||
ChannelsManager,
|
||||
EmptyChannelError,
|
||||
InvalidUpdateError,
|
||||
create_checkpoint,
|
||||
)
|
||||
from langgraph.channels.last_value import LastValue
|
||||
@@ -684,7 +685,12 @@ def _apply_writes(
|
||||
# Apply writes to channels
|
||||
for chan, vals in pending_writes_by_channel.items():
|
||||
if chan in channels:
|
||||
channels[chan].update(vals)
|
||||
try:
|
||||
channels[chan].update(vals)
|
||||
except InvalidUpdateError as e:
|
||||
raise InvalidUpdateError(
|
||||
f"Invalid update for channel {chan}: {e}"
|
||||
) from e
|
||||
checkpoint["channel_versions"][chan] += 1
|
||||
updated_channels.add(chan)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user