mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-10-04 23:45:08 +02:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1be024f5c | ||
|
|
f61e9b45b6 |
@@ -142,6 +142,9 @@ ANY_TYPE = object()
|
||||
|
||||
ASYNCIO_ACCEPTS_CONTEXT = sys.version_info >= (3, 11)
|
||||
|
||||
# Cache for inspect.signature results, keyed by function object
|
||||
_SIGNATURE_CACHE: dict[Callable, inspect.Signature] = {}
|
||||
|
||||
# List of keyword arguments that can be injected into nodes / tasks / tools at runtime.
|
||||
# A named argument may appear multiple times if it appears with distinct types.
|
||||
KWARGS_CONFIG_KEYS: tuple[tuple[str, tuple[Any, ...], str, Any], ...] = (
|
||||
@@ -315,7 +318,16 @@ class RunnableCallable(Runnable):
|
||||
raise ValueError("At least one of func or afunc must be provided.")
|
||||
|
||||
self.func_accepts: dict[str, tuple[str, Any]] = {}
|
||||
params = inspect.signature(cast(Callable, func or afunc)).parameters
|
||||
target = cast(Callable, func or afunc)
|
||||
try:
|
||||
sig = _SIGNATURE_CACHE[target]
|
||||
except (KeyError, TypeError):
|
||||
sig = inspect.signature(target)
|
||||
try:
|
||||
_SIGNATURE_CACHE[target] = sig
|
||||
except TypeError:
|
||||
pass # unhashable function, skip caching
|
||||
params = sig.parameters
|
||||
|
||||
for kw, typ, runtime_key, default in KWARGS_CONFIG_KEYS:
|
||||
p = params.get(kw)
|
||||
|
||||
@@ -198,6 +198,7 @@ class PregelLoop:
|
||||
_migrate_checkpoint: Callable[[Checkpoint], None] | None
|
||||
submit: Submit
|
||||
channels: Mapping[str, BaseChannel]
|
||||
_has_untracked_channels: bool
|
||||
# Futures from `checkpointer.put_writes` calls that produced delta-channel
|
||||
# writes. `_checkpointer_put_after_previous` drains this list (swap to a
|
||||
# local `futs` then reset to `[]` and wait/gather) before putting the
|
||||
@@ -437,9 +438,7 @@ class PregelLoop:
|
||||
writes_to_save = writes
|
||||
|
||||
# check if any writes are to an UntrackedValue channel
|
||||
if any(
|
||||
isinstance(channel, UntrackedValue) for channel in self.channels.values()
|
||||
):
|
||||
if self._has_untracked_channels:
|
||||
# we do not persist untracked values in checkpoints
|
||||
writes_to_save = [
|
||||
# sanitize UntrackedValues that are nested within Send packets
|
||||
@@ -1161,9 +1160,7 @@ class PregelLoop:
|
||||
elif "counters_since_delta_snapshot" in self.checkpoint_metadata:
|
||||
del self.checkpoint_metadata["counters_since_delta_snapshot"]
|
||||
# sanitize TASK channel in the checkpoint before saving (durability=="exit")
|
||||
if TASKS in self.checkpoint["channel_values"] and any(
|
||||
isinstance(channel, UntrackedValue) for channel in self.channels.values()
|
||||
):
|
||||
if TASKS in self.checkpoint["channel_values"] and self._has_untracked_channels:
|
||||
sanitized_tasks = [
|
||||
sanitize_untracked_values_in_send(value, self.channels)
|
||||
if isinstance(value, Send)
|
||||
@@ -1695,6 +1692,9 @@ class SyncPregelLoop(PregelLoop, AbstractContextManager):
|
||||
saver=self.checkpointer,
|
||||
config=self.checkpoint_config,
|
||||
)
|
||||
self._has_untracked_channels = any(
|
||||
isinstance(ch, UntrackedValue) for ch in self.channels.values()
|
||||
)
|
||||
self.stack.push(self._suppress_interrupt)
|
||||
self.status = "input"
|
||||
self.step = self.checkpoint_metadata["step"] + 1
|
||||
@@ -1955,6 +1955,9 @@ class AsyncPregelLoop(PregelLoop, AbstractAsyncContextManager):
|
||||
saver=self.checkpointer,
|
||||
config=self.checkpoint_config,
|
||||
)
|
||||
self._has_untracked_channels = any(
|
||||
isinstance(ch, UntrackedValue) for ch in self.channels.values()
|
||||
)
|
||||
self.stack.push(self._suppress_interrupt)
|
||||
self.status = "input"
|
||||
self.step = self.checkpoint_metadata["step"] + 1
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "langgraph"
|
||||
version = "1.2.10"
|
||||
version = "1.2.9"
|
||||
description = "Building stateful, multi-actor applications with LLMs"
|
||||
authors = []
|
||||
requires-python = ">=3.10"
|
||||
|
||||
Generated
+1
-1
@@ -1439,7 +1439,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "langgraph"
|
||||
version = "1.2.10"
|
||||
version = "1.2.9"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "langchain-core" },
|
||||
|
||||
Generated
+1
-1
@@ -285,7 +285,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "langgraph"
|
||||
version = "1.2.10"
|
||||
version = "1.2.9"
|
||||
source = { editable = "../langgraph" }
|
||||
dependencies = [
|
||||
{ name = "langchain-core" },
|
||||
|
||||
Generated
+1
-1
@@ -298,7 +298,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "langgraph"
|
||||
version = "1.2.10"
|
||||
version = "1.2.9"
|
||||
source = { editable = "../langgraph" }
|
||||
dependencies = [
|
||||
{ name = "langchain-core" },
|
||||
|
||||
Reference in New Issue
Block a user