Stringify thread_id when of a different type

This commit is contained in:
Nuno Campos
2025-04-15 12:51:33 -07:00
parent cd967c40ac
commit 48c08421fa
3 changed files with 10 additions and 1 deletions
+2
View File
@@ -69,6 +69,8 @@ CONFIG_KEY_ENSURE_LATEST = sys.intern("__pregel_ensure_latest")
# (for distributed mode)
CONFIG_KEY_DELEGATE = sys.intern("__pregel_delegate")
# holds a boolean indicating whether to delegate subgraphs (for distributed mode)
CONFIG_KEY_THREAD_ID = sys.intern("thread_id")
# holds the thread ID for the current invocation
CONFIG_KEY_CHECKPOINT_MAP = sys.intern("checkpoint_map")
# holds a mapping of checkpoint_ns -> checkpoint_id for parent graphs
CONFIG_KEY_CHECKPOINT_ID = sys.intern("checkpoint_id")
+7
View File
@@ -52,6 +52,7 @@ from langgraph.constants import (
CONFIG_KEY_SCRATCHPAD,
CONFIG_KEY_STREAM,
CONFIG_KEY_TASK_ID,
CONFIG_KEY_THREAD_ID,
EMPTY_SEQ,
ERROR,
INPUT,
@@ -285,6 +286,12 @@ class PregelLoop(LoopProtocol):
)
else:
self.checkpoint_config = self.config
if thread_id := config[CONF].get(CONFIG_KEY_THREAD_ID):
if not isinstance(thread_id, str):
self.checkpoint_config = patch_configurable(
self.checkpoint_config,
{CONFIG_KEY_THREAD_ID: str(thread_id)},
)
self.checkpoint_ns = (
tuple(cast(str, self.config[CONF][CONFIG_KEY_CHECKPOINT_NS]).split(NS_SEP))
if self.config[CONF].get(CONFIG_KEY_CHECKPOINT_NS)
+1 -1
View File
@@ -6156,7 +6156,7 @@ def test_falsy_return_from_task(
falsy_task().result()
interrupt("test")
configurable = {"configurable": {"thread_id": str(uuid.uuid4())}}
configurable = {"configurable": {"thread_id": uuid.uuid4()}}
assert [
chunk for chunk in graph.stream({"a": 5}, configurable, stream_mode="debug")
] == [