mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-18 13:46:02 +00:00
This commit is contained in:
@@ -35,6 +35,20 @@ def serialize_lc_object(obj: Any) -> Any:
|
||||
return obj.dict()
|
||||
except Exception:
|
||||
pass
|
||||
# Interrupt is a __slots__ class — no model_dump/dict/__dict__, so it
|
||||
# would reach str() and produce a malformed payload.
|
||||
try:
|
||||
from langgraph.types import Interrupt
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
if isinstance(obj, Interrupt):
|
||||
return serialize_lc_object(
|
||||
{
|
||||
"value": obj.value,
|
||||
"id": getattr(obj, "id", None),
|
||||
}
|
||||
)
|
||||
# Last resort
|
||||
try:
|
||||
return str(obj)
|
||||
@@ -45,12 +59,13 @@ def serialize_lc_object(obj: Any) -> Any:
|
||||
def serialize_channel_values(channel_values: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Serialize channel values, stripping internal LangGraph keys.
|
||||
|
||||
Internal keys like ``__pregel_*`` and ``__interrupt__`` are removed
|
||||
to match what the LangGraph Platform API returns.
|
||||
Only ``__pregel_*`` keys are removed — ``__interrupt__`` is deliberately
|
||||
preserved so the LangGraph SDK can detect interrupt events from values
|
||||
chunks (see issue #3595).
|
||||
"""
|
||||
result: dict[str, Any] = {}
|
||||
for key, value in channel_values.items():
|
||||
if key.startswith("__pregel_") or key == "__interrupt__":
|
||||
if key.startswith("__pregel_"):
|
||||
continue
|
||||
result[key] = serialize_lc_object(value)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user