langgraph-api 0.20.0.dev3__py3-none-any.whl → 0.20.0.dev4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. langgraph_api/__init__.py +1 -1
  2. langgraph_api/_checkpointer/_adapter.py +5 -4
  3. langgraph_api/api/__init__.py +4 -7
  4. langgraph_api/api/assistants.py +2 -9
  5. langgraph_api/api/event_streaming.py +1 -5
  6. langgraph_api/api/mcp/_call_thread.py +1 -1
  7. langgraph_api/api/meta.py +5 -10
  8. langgraph_api/api/runs.py +8 -20
  9. langgraph_api/api/store.py +1 -1
  10. langgraph_api/api/threads.py +9 -24
  11. langgraph_api/cache.py +2 -15
  12. langgraph_api/cli.py +2 -11
  13. langgraph_api/cron_scheduler.py +2 -23
  14. langgraph_api/encryption/middleware.py +1 -66
  15. langgraph_api/errors.py +1 -2
  16. langgraph_api/feature_flags.py +8 -9
  17. langgraph_api/graph.py +3 -133
  18. langgraph_api/grpc/ops/runs.py +14 -2
  19. langgraph_api/grpc/ops/threads.py +2 -3
  20. langgraph_api/js/remote.py +3 -3
  21. langgraph_api/metrics_collector.py +15 -25
  22. langgraph_api/metrics_otlp.py +2 -2
  23. langgraph_api/models/run.py +1 -6
  24. langgraph_api/operator_routes.py +1 -6
  25. langgraph_api/queue_entrypoint.py +2 -2
  26. langgraph_api/runtime/encryption.py +11 -149
  27. langgraph_api/runtime/lifespan.py +2 -2
  28. langgraph_api/runtime/store.py +134 -2
  29. langgraph_api/self_hosted_metrics.py +2 -8
  30. langgraph_api/server.py +1 -1
  31. langgraph_api/store.py +47 -22
  32. langgraph_api/stream.py +14 -22
  33. langgraph_api/transcript/__init__.py +0 -0
  34. langgraph_api/transcript/input_ids.py +100 -0
  35. langgraph_api/worker.py +1 -6
  36. langgraph_api/worker_runtime.py +5 -16
  37. {langgraph_api-0.20.0.dev3.dist-info → langgraph_api-0.20.0.dev4.dist-info}/METADATA +3 -3
  38. {langgraph_api-0.20.0.dev3.dist-info → langgraph_api-0.20.0.dev4.dist-info}/RECORD +49 -52
  39. langgraph_grpc_common/proto/core_api_pb2.py +178 -174
  40. langgraph_grpc_common/proto/core_api_pb2.pyi +101 -6
  41. langgraph_runtime/__init__.py +27 -55
  42. langgraph_runtime/checkpoint.py +5 -1
  43. langgraph_runtime/database.py +5 -1
  44. langgraph_runtime/encryption.py +6 -13
  45. langgraph_runtime/routes.py +6 -9
  46. langgraph_runtime/store.py +5 -1
  47. langgraph_runtime/lifespan.py +0 -4
  48. langgraph_runtime/metrics.py +0 -4
  49. langgraph_runtime/ops.py +0 -4
  50. langgraph_runtime/queue.py +0 -4
  51. langgraph_runtime/retry.py +0 -4
  52. {langgraph_api-0.20.0.dev3.dist-info → langgraph_api-0.20.0.dev4.dist-info}/WHEEL +0 -0
  53. {langgraph_api-0.20.0.dev3.dist-info → langgraph_api-0.20.0.dev4.dist-info}/entry_points.txt +0 -0
  54. {langgraph_api-0.20.0.dev3.dist-info → langgraph_api-0.20.0.dev4.dist-info}/licenses/LICENSE +0 -0
langgraph_api/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.20.0.dev3"
1
+ __version__ = "0.20.0.dev4"
@@ -404,13 +404,13 @@ async def get_checkpointer(
404
404
  )
405
405
 
406
406
  from langgraph_api.feature_flags import ( # noqa: PLC0415
407
- INMEM_USES_CORE,
407
+ IS_INMEM_BACKEND,
408
408
  IS_POSTGRES_BACKEND,
409
409
  PREFER_GRPC_CHECKPOINTER,
410
410
  )
411
411
 
412
- # Inmem on Go core has no Python checkpointer.
413
- if INMEM_USES_CORE or (IS_POSTGRES_BACKEND and PREFER_GRPC_CHECKPOINTER):
412
+ # The in-memory runtime has no Python checkpointer.
413
+ if IS_INMEM_BACKEND or (IS_POSTGRES_BACKEND and PREFER_GRPC_CHECKPOINTER):
414
414
  return cast(
415
415
  "FullCheckpointerProtocol",
416
416
  GrpcCheckpointer(
@@ -420,7 +420,8 @@ async def get_checkpointer(
420
420
  ),
421
421
  )
422
422
 
423
- from langgraph_runtime.checkpoint import Checkpointer # noqa: PLC0415
423
+ # Only the Postgres runtime has a Python checkpointer.
424
+ Checkpointer = importlib.import_module("langgraph_runtime.checkpoint").Checkpointer
424
425
 
425
426
  return Checkpointer(
426
427
  conn, unpack_hook=unpack_hook, use_direct_connection=use_direct_connection
@@ -39,16 +39,15 @@ from langgraph_api.config import (
39
39
  )
40
40
  from langgraph_api.feature_flags import (
41
41
  FF_V2_EVENT_STREAMING,
42
- IS_POSTGRES_OR_GRPC_BACKEND,
43
42
  )
44
43
  from langgraph_api.graph import js_bg_tasks
45
44
  from langgraph_api.grpc.client import get_shared_client
46
45
  from langgraph_api.js.base import is_js_path
46
+ from langgraph_api.runtime.retry import OVERLOADED_EXCEPTIONS
47
47
  from langgraph_api.timing import profiled_import
48
48
  from langgraph_api.validation import render_docs_html
49
49
  from langgraph_runtime import database as runtime_database
50
50
  from langgraph_runtime.database import healthcheck
51
- from langgraph_runtime.retry import OVERLOADED_EXCEPTIONS
52
51
 
53
52
  HEALTHCHECK_TIMEOUT_SECONDS = 3.0
54
53
 
@@ -77,9 +76,8 @@ async def grpc_healthcheck():
77
76
  def _data_dependency_checks() -> dict[str, Callable[[], Awaitable[None]]]:
78
77
  """Per-dependency probes, or the combined `healthcheck` as a fallback.
79
78
 
80
- Both in-repo runtimes provide `dependency_checks`. `langgraph_runtime`
81
- resolves its backend from LANGGRAPH_RUNTIME_EDITION at import time, and an
82
- out-of-tree edition (`community`) is not pinned here, so it may not.
79
+ Both in-repo runtimes provide `dependency_checks`; the fallback covers a
80
+ runtime package older than this server.
83
81
  """
84
82
  checks = getattr(runtime_database, "dependency_checks", None)
85
83
  if checks is None:
@@ -109,8 +107,7 @@ async def ok(request: Request, *, disabled: bool = False):
109
107
  checks["js_runtime"] = js_healthcheck
110
108
 
111
109
  # Check `core-api` server health
112
- if IS_POSTGRES_OR_GRPC_BACKEND:
113
- checks["core_api"] = grpc_healthcheck
110
+ checks["core_api"] = grpc_healthcheck
114
111
 
115
112
  results = await asyncio.gather(
116
113
  *(
@@ -15,7 +15,6 @@ from starlette.routing import BaseRoute
15
15
  from langgraph_api import _checkpointer as api_checkpointer
16
16
  from langgraph_api import store as api_store
17
17
  from langgraph_api.feature_flags import (
18
- IS_POSTGRES_OR_GRPC_BACKEND,
19
18
  USE_RUNTIME_CONTEXT_API,
20
19
  )
21
20
  from langgraph_api.graph import (
@@ -25,8 +24,10 @@ from langgraph_api.graph import (
25
24
  get_graph,
26
25
  graph_exists,
27
26
  )
27
+ from langgraph_api.grpc.ops import Assistants
28
28
  from langgraph_api.js.base import BaseRemotePregel
29
29
  from langgraph_api.route import ApiRequest, ApiResponse, ApiRoute
30
+ from langgraph_api.runtime.retry import retry_db
30
31
  from langgraph_api.schema import ASSISTANT_FIELDS
31
32
  from langgraph_api.serde import json_loads
32
33
  from langgraph_api.utils import (
@@ -46,20 +47,12 @@ from langgraph_api.validation import (
46
47
  ConfigValidator,
47
48
  )
48
49
  from langgraph_runtime.database import connect
49
- from langgraph_runtime.retry import retry_db
50
50
 
51
51
  logger = structlog.stdlib.get_logger(__name__)
52
52
 
53
- if IS_POSTGRES_OR_GRPC_BACKEND:
54
- from langgraph_api.grpc.ops import Assistants
55
- else:
56
- from langgraph_runtime.ops import Assistants
57
-
58
53
 
59
54
  def graph_scope() -> dict[str, list[str]]:
60
55
  """Restrict assistant reads to the graphs this server has registered."""
61
- if not IS_POSTGRES_OR_GRPC_BACKEND:
62
- return {}
63
56
  return {"graph_id_allowlist": sorted(GRAPHS)}
64
57
 
65
58
 
@@ -35,7 +35,6 @@ from starlette.websockets import WebSocketDisconnect
35
35
  from langgraph_api.event_streaming.service import ThreadRunManager
36
36
  from langgraph_api.event_streaming.session import _is_supported_channel
37
37
  from langgraph_api.event_streaming.types import ErrorResponse, Subscription
38
- from langgraph_api.feature_flags import IS_POSTGRES_OR_GRPC_BACKEND
39
38
  from langgraph_api.route import ApiRoute, ApiWebSocketRoute
40
39
  from langgraph_api.serde import json_dumpb
41
40
  from langgraph_api.sse import EventSourceResponse
@@ -47,10 +46,7 @@ if TYPE_CHECKING:
47
46
  from starlette.requests import Request
48
47
  from starlette.websockets import WebSocket
49
48
 
50
- if IS_POSTGRES_OR_GRPC_BACKEND:
51
- from langgraph_api.grpc.ops import Runs, Threads
52
- else:
53
- from langgraph_runtime.ops import Runs, Threads
49
+ from langgraph_api.grpc.ops import Runs, Threads
54
50
 
55
51
  logger = structlog.stdlib.get_logger(__name__)
56
52
 
@@ -24,9 +24,9 @@ from langgraph_api.api.mcp._outcome import Failed, Paused, RunOutcome, parse_out
24
24
  from langgraph_api.api.mcp._request_state import Binding, InvalidRequestState
25
25
  from langgraph_api.config import THREAD_TTL
26
26
  from langgraph_api.models.run import create_valid_run
27
+ from langgraph_api.runtime.retry import retry_db
27
28
  from langgraph_api.validation import RunCreateStateful, sanitize_and_validate
28
29
  from langgraph_runtime.database import connect
29
- from langgraph_runtime.retry import retry_db
30
30
 
31
31
  if TYPE_CHECKING:
32
32
  from collections.abc import AsyncIterator, Iterator, Mapping
langgraph_api/api/meta.py CHANGED
@@ -6,23 +6,19 @@ from starlette.responses import JSONResponse, PlainTextResponse
6
6
 
7
7
  from langgraph_api import __version__, config, metadata
8
8
  from langgraph_api.api.mcp import MCP_SERVED
9
- from langgraph_api.feature_flags import IS_POSTGRES_OR_GRPC_BACKEND
9
+ from langgraph_api.feature_flags import FF_TRANSCRIPT_API
10
10
  from langgraph_api.go_prometheus_metrics import merge_go_prometheus_text
11
+ from langgraph_api.grpc.ops import Runs
11
12
  from langgraph_api.http_metrics import HTTP_METRICS_COLLECTOR
12
13
  from langgraph_api.route import ApiRequest
14
+ from langgraph_api.runtime.metrics import get_metrics
13
15
  from langgraph_api.schema import PoolStats, PostgresPoolStats, RedisPoolStats
14
16
  from langgraph_api.tracing_session import ADDRESS_SUPPORT
15
17
  from langgraph_runtime.database import connect, pool_stats
16
- from langgraph_runtime.metrics import get_metrics
17
18
 
18
19
  # A run's `strict_resume` works only on a langgraph that has the check.
19
20
  STRICT_RESUME = hasattr(langgraph_constants, "CONFIG_KEY_STRICT_RESUME")
20
21
 
21
- if IS_POSTGRES_OR_GRPC_BACKEND:
22
- from langgraph_api.grpc.ops import Runs
23
- else:
24
- from langgraph_runtime.ops import Runs
25
-
26
22
  METRICS_FORMATS = {"prometheus", "json"}
27
23
 
28
24
  logger = structlog.stdlib.get_logger(__name__)
@@ -61,8 +57,6 @@ def _merge_pool_stats(local: PoolStats, remote: PoolStats) -> PoolStats:
61
57
 
62
58
  async def _grpc_pool_stats() -> PoolStats:
63
59
  """Fetch connection pool stats from the Core API (Go) via gRPC for metrics aggregation. Returns {} on error."""
64
- if not IS_POSTGRES_OR_GRPC_BACKEND:
65
- return {}
66
60
  try:
67
61
  return await Runs.pool_stats()
68
62
  except Exception as e:
@@ -94,9 +88,10 @@ async def meta_info(request: ApiRequest):
94
88
  "langsmith_tracing_session_on_runs": True,
95
89
  "langsmith_tracing_address": ADDRESS_SUPPORT,
96
90
  "mcp": MCP_SERVED,
97
- "stream_namespaces": IS_POSTGRES_OR_GRPC_BACKEND,
91
+ "stream_namespaces": True,
98
92
  "stream_lifecycle": True,
99
93
  "strict_resume": STRICT_RESUME,
94
+ "transcript": FF_TRANSCRIPT_API,
100
95
  },
101
96
  "host": {
102
97
  "kind": metadata.HOST,
langgraph_api/api/runs.py CHANGED
@@ -12,10 +12,11 @@ from starlette.responses import Response, StreamingResponse
12
12
 
13
13
  from langgraph_api.asyncio import ValueEvent
14
14
  from langgraph_api.errors import UserInterrupt
15
- from langgraph_api.feature_flags import IS_POSTGRES_OR_GRPC_BACKEND
16
15
  from langgraph_api.graph import _validate_assistant_id
16
+ from langgraph_api.grpc.ops import Crons, Runs, Threads
17
17
  from langgraph_api.models.run import create_valid_run
18
18
  from langgraph_api.route import ApiRequest, ApiResponse, ApiRoute
19
+ from langgraph_api.runtime.retry import retry_db
19
20
  from langgraph_api.schema import (
20
21
  CRON_FIELDS,
21
22
  RUN_FIELDS,
@@ -47,12 +48,6 @@ from langgraph_api.validation import (
47
48
  )
48
49
  from langgraph_api.webhook import validate_or_drop_webhook
49
50
  from langgraph_runtime.database import connect
50
- from langgraph_runtime.retry import retry_db
51
-
52
- if IS_POSTGRES_OR_GRPC_BACKEND:
53
- from langgraph_api.grpc.ops import Crons, Runs, Threads
54
- else:
55
- from langgraph_runtime.ops import Crons, Runs, Threads
56
51
 
57
52
  logger = structlog.stdlib.get_logger(__name__)
58
53
 
@@ -116,20 +111,14 @@ def stream_namespace_query(params: QueryParams) -> str:
116
111
 
117
112
 
118
113
  def stream_namespace_kwargs(params: QueryParams) -> dict[str, list[str]]:
119
- """``Runs.Stream.join`` kwargs for the request's ``namespace`` params.
120
-
121
- Every runtime rejects a bad value, but only the Go core filters by
122
- namespace, so the Python in-memory runtime gets none and streams everything.
123
- """
114
+ """``Runs.Stream.join`` kwargs for the request's ``namespace`` params."""
124
115
  namespaces = parse_stream_namespaces(params)
125
- if not namespaces or not IS_POSTGRES_OR_GRPC_BACKEND:
116
+ if not namespaces:
126
117
  return {}
127
118
  return {"namespaces": namespaces}
128
119
 
129
120
 
130
- # Type alias for stream handlers (GrpcStreamHandler or ContextQueue).
131
- # Runs is selected at runtime, and the implementations have different
132
- # type signatures, so we use Any for compatibility.
121
+ # Stream handler returned by ``Runs.Stream.subscribe``.
133
122
  _StreamHandler = Any
134
123
 
135
124
  _RunResultFallback = Callable[[], Awaitable[bytes]]
@@ -806,11 +795,10 @@ async def join_run_stream(request: ApiRequest):
806
795
  if last_event_id is None:
807
796
  await Runs.Stream.check_run_stream_auth(run_id, thread_id)
808
797
  if checkpoint_id:
809
- # Where the checkpoint goes unused, on the in-memory runtime or a core that
810
- # predates it, "-" replays the whole run instead of streaming only new events.
798
+ # Where a core that predates checkpoint_id ignores it, "-" replays the
799
+ # whole run instead of streaming only new events.
811
800
  last_event_id = "-"
812
- if IS_POSTGRES_OR_GRPC_BACKEND:
813
- join_kwargs["checkpoint_id"] = str(checkpoint_id)
801
+ join_kwargs["checkpoint_id"] = str(checkpoint_id)
814
802
  sub = await Runs.Stream.subscribe(run_id, thread_id)
815
803
 
816
804
  async def body():
@@ -6,6 +6,7 @@ from starlette.routing import BaseRoute
6
6
 
7
7
  from langgraph_api.auth.custom import handle_event as _handle_event
8
8
  from langgraph_api.route import ApiRequest, ApiResponse, ApiRoute
9
+ from langgraph_api.runtime.retry import retry_db
9
10
  from langgraph_api.store import (
10
11
  get_item as get_stored_item,
11
12
  )
@@ -25,7 +26,6 @@ from langgraph_api.validation import (
25
26
  StorePutRequest,
26
27
  StoreSearchRequest,
27
28
  )
28
- from langgraph_runtime.retry import retry_db
29
29
 
30
30
 
31
31
  def _validate_namespace(namespace: Any) -> Response | None:
@@ -14,10 +14,11 @@ from langgraph_api.encryption.shared import (
14
14
  using_encryption,
15
15
  )
16
16
  from langgraph_api.feature_flags import (
17
- IS_POSTGRES_OR_GRPC_BACKEND,
18
17
  PREFER_GRPC_CHECKPOINTER,
19
18
  )
19
+ from langgraph_api.grpc.ops import Threads
20
20
  from langgraph_api.route import ApiRequest, ApiResponse, ApiRoute
21
+ from langgraph_api.runtime.retry import retry_db
21
22
  from langgraph_api.schema import THREAD_FIELDS, THREAD_STATE_FIELDS, ThreadStreamMode
22
23
  from langgraph_api.serde import Fragment, json_dumpb
23
24
  from langgraph_api.sse import EventSourceResponse
@@ -43,12 +44,6 @@ from langgraph_api.validation import (
43
44
  ThreadStateUpdate,
44
45
  )
45
46
  from langgraph_runtime.database import connect
46
- from langgraph_runtime.retry import retry_db
47
-
48
- if IS_POSTGRES_OR_GRPC_BACKEND:
49
- from langgraph_api.grpc.ops import Threads
50
- else:
51
- from langgraph_runtime.ops import Threads
52
47
 
53
48
  if TYPE_CHECKING:
54
49
  from collections.abc import AsyncIterator, Mapping
@@ -68,7 +63,7 @@ async def create_thread(
68
63
  thread_id = thread_id or str(uuid7())
69
64
  supersteps = payload.get("supersteps")
70
65
 
71
- if IS_POSTGRES_OR_GRPC_BACKEND and not supersteps:
66
+ if not supersteps:
72
67
  iter = await Threads.put(
73
68
  None,
74
69
  thread_id,
@@ -77,7 +72,7 @@ async def create_thread(
77
72
  ttl=payload.get("ttl"),
78
73
  )
79
74
  else:
80
- # Need connection for inmem put or gRPC State.bulk
75
+ # State.bulk needs a connection.
81
76
  async with connect(supports_core_api=PREFER_GRPC_CHECKPOINTER) as conn:
82
77
  iter = await Threads.put(
83
78
  conn,
@@ -108,8 +103,8 @@ async def create_thread(
108
103
 
109
104
 
110
105
  def _raw_values_kwargs(raw_values: bool = True) -> dict[str, bool]:
111
- """Have the gRPC ops relay thread values undecoded; in-memory ops always decode."""
112
- return {"raw_values": raw_values} if IS_POSTGRES_OR_GRPC_BACKEND else {}
106
+ """Have the gRPC ops relay thread values undecoded."""
107
+ return {"raw_values": raw_values}
113
108
 
114
109
 
115
110
  def _exclude_metadata_kwargs(payload: dict) -> dict:
@@ -423,19 +418,9 @@ def _history_states(
423
418
  channels: list[str] | None = None,
424
419
  **kwargs: Any,
425
420
  ) -> "AsyncIterator[StateSnapshot]":
426
- if hasattr(Threads.State, "iterate"):
427
- return Threads.State.iterate(
428
- conn, incremental=incremental, channels=channels, **kwargs
429
- )
430
- # langgraph-runtime-inmem releases before ``iterate`` only have ``list``.
431
- return _listed_history_states(conn, **kwargs)
432
-
433
-
434
- async def _listed_history_states(
435
- conn: Any, **kwargs: Any
436
- ) -> "AsyncIterator[StateSnapshot]":
437
- for state in await Threads.State.list(conn, **kwargs):
438
- yield state
421
+ return Threads.State.iterate(
422
+ conn, incremental=incremental, channels=channels, **kwargs
423
+ )
439
424
 
440
425
 
441
426
  _SELECT_VALUES_KEY = re.compile(r"values\.[A-Za-z0-9_-]+")
langgraph_api/cache.py CHANGED
@@ -10,24 +10,11 @@ from typing import Any, Generic, Literal, TypedDict, TypeVar, cast
10
10
 
11
11
  import orjson
12
12
 
13
- from langgraph_api.feature_flags import IS_POSTGRES_OR_GRPC_BACKEND
14
- from langgraph_api.utils.cache import LRUCache
13
+ from langgraph_api.grpc.ops.cache import cache_get as _cache_get
14
+ from langgraph_api.grpc.ops.cache import cache_set as _cache_set
15
15
 
16
16
  MAX_CACHE_TTL = timedelta(hours=24)
17
17
 
18
- if IS_POSTGRES_OR_GRPC_BACKEND:
19
- from langgraph_api.grpc.ops.cache import cache_get as _cache_get
20
- from langgraph_api.grpc.ops.cache import cache_set as _cache_set
21
- else:
22
- _CACHE: LRUCache[bytes] = LRUCache(ttl=MAX_CACHE_TTL.total_seconds())
23
-
24
- async def _cache_get(key: str) -> bytes | None:
25
- return await _CACHE.get(key)
26
-
27
- async def _cache_set(key: str, value: bytes, ttl: timedelta | None = None) -> None:
28
- ttl = _clamp_ttl(ttl)
29
- _CACHE.set(key, value, ttl=ttl.total_seconds())
30
-
31
18
 
32
19
  logger = logging.getLogger(__name__)
33
20
 
langgraph_api/cli.py CHANGED
@@ -200,7 +200,7 @@ def run_server(
200
200
  studio_url: str | None = None,
201
201
  disable_persistence: bool = False,
202
202
  allow_blocking: bool = False,
203
- runtime_edition: Literal["inmem", "community", "postgres"] = "inmem",
203
+ runtime_edition: Literal["inmem", "postgres"] = "inmem",
204
204
  server_level: str = "WARNING",
205
205
  ssl_certfile: str | pathlib.Path | None = None,
206
206
  ssl_keyfile: str | pathlib.Path | None = None,
@@ -301,16 +301,7 @@ def run_server(
301
301
  continue
302
302
  to_patch[k] = v
303
303
 
304
- def _env(name: str, default: str = "") -> str:
305
- if env_vars and name in env_vars:
306
- return env_vars[name]
307
- return os.getenv(name, default)
308
-
309
- use_core = runtime_edition == "inmem" and _env("FF_INMEM_CORE", "true").lower() in (
310
- "true",
311
- "1",
312
- "yes",
313
- )
304
+ use_core = runtime_edition == "inmem"
314
305
  if use_core:
315
306
  to_patch[embedded_core.ADDRESS_ENV] = ""
316
307
  core = (
@@ -7,20 +7,13 @@ import structlog
7
7
 
8
8
  from langgraph_api import config
9
9
  from langgraph_api.encryption.context import set_encryption_context
10
- from langgraph_api.feature_flags import IS_POSTGRES_OR_GRPC_BACKEND
10
+ from langgraph_api.grpc.ops import Crons
11
11
  from langgraph_api.models.run import create_valid_run
12
+ from langgraph_api.runtime.retry import retry_db
12
13
  from langgraph_api.schema import Cron
13
14
  from langgraph_api.serde import json_loads
14
- from langgraph_api.utils import next_cron_date
15
- from langgraph_api.utils.config import run_in_executor
16
15
  from langgraph_api.worker_runtime import set_auth_ctx_for_run
17
16
  from langgraph_runtime.database import connect
18
- from langgraph_runtime.retry import retry_db
19
-
20
- if IS_POSTGRES_OR_GRPC_BACKEND:
21
- from langgraph_api.grpc.ops import Crons
22
- else:
23
- from langgraph_runtime.ops import Crons
24
17
 
25
18
  logger = structlog.stdlib.get_logger(__name__)
26
19
 
@@ -111,20 +104,6 @@ async def cron_scheduler():
111
104
  cron["cron_id"]
112
105
  )
113
106
  )
114
- # gRPC/Postgres path: next_run_date is advanced
115
- # atomically in Go's Crons.Next() to prevent
116
- # concurrent schedulers from claiming the same cron.
117
- if not IS_POSTGRES_OR_GRPC_BACKEND:
118
- next_run_date = await run_in_executor(
119
- None,
120
- next_cron_date,
121
- cron["schedule"],
122
- cron["now"],
123
- cron.get("timezone"),
124
- )
125
- await Crons.set_next_run_date(
126
- conn, cron["cron_id"], next_run_date
127
- )
128
107
 
129
108
  if not batch_was_full(claimed):
130
109
  await asyncio.sleep(SLEEP_TIME)
@@ -29,13 +29,11 @@ from langgraph_api.encryption.custom import (
29
29
  from langgraph_api.encryption.shared import (
30
30
  BLOB_ENCRYPTION_CONTEXT_KEY,
31
31
  ENCRYPTION_CONTEXT_KEY,
32
- get_encryption,
33
32
  strip_encryption_metadata,
34
33
  )
35
- from langgraph_api.serde import Fragment, json_loads
36
34
 
37
35
  if TYPE_CHECKING:
38
- from collections.abc import Callable, Mapping
36
+ from collections.abc import Callable
39
37
 
40
38
  # Only import EncryptionContext at module load if encryption is configured
41
39
  # This avoids requiring langgraph-sdk>=0.2.14 for users who don't use encryption
@@ -285,66 +283,3 @@ async def decrypt_json_if_needed(
285
283
  else "custom_with_aes_migration",
286
284
  )
287
285
  return decrypted
288
-
289
-
290
- async def decrypt_response(
291
- obj: Mapping[str, Any],
292
- model_type: ModelType,
293
- *,
294
- plaintext_from_core: bool,
295
- ) -> dict[str, Any]:
296
- """Decrypt runtime-owned fields, or return Go-decrypted data unchanged."""
297
- if plaintext_from_core:
298
- return obj
299
-
300
- encryption_instance = get_encryption()
301
- if encryption_instance is None:
302
- # Even without encryption, the error field is stored as bytes (bytea column)
303
- # and must be parsed to return as a dict in the API response.
304
- error = obj.get("error")
305
- if isinstance(error, bytes | memoryview | Fragment):
306
- result = dict(obj)
307
- error_bytes = cast(
308
- "bytes | Fragment",
309
- bytes(error) if isinstance(error, memoryview) else error,
310
- )
311
- result["error"] = json_loads(error_bytes)
312
- return result
313
- return obj
314
-
315
- from langgraph_runtime.encryption import ( # noqa: PLC0415
316
- decrypt_fields,
317
- encryption_fields,
318
- )
319
-
320
- field_names = encryption_fields(model_type)
321
- result = dict(obj)
322
- for field_name in field_names:
323
- value = result.get(field_name)
324
- if isinstance(value, (bytes, bytearray, memoryview, str, Fragment)):
325
- result[field_name] = json_loads(value)
326
- await decrypt_fields(result, model_type, field_names, encryption_instance)
327
- return result
328
-
329
-
330
- async def encrypt_request(
331
- data: Mapping[str, Any],
332
- model_type: ModelType,
333
- *,
334
- plaintext_for_core: bool,
335
- ) -> dict[str, Any]:
336
- """Encrypt runtime-owned fields, or leave data plaintext for Go."""
337
- if plaintext_for_core:
338
- return data
339
-
340
- encryption_instance = get_encryption()
341
- if encryption_instance is None:
342
- return data
343
-
344
- from langgraph_runtime.encryption import ( # noqa: PLC0415
345
- encrypt_fields,
346
- encryption_fields,
347
- )
348
-
349
- field_names = encryption_fields(model_type)
350
- return await encrypt_fields(data, model_type, field_names, encryption_instance)
langgraph_api/errors.py CHANGED
@@ -9,6 +9,7 @@ from starlette.requests import Request
9
9
  from starlette.responses import JSONResponse, Response
10
10
 
11
11
  from langgraph_api.js.errors import RemoteException
12
+ from langgraph_api.runtime.retry import OVERLOADED_EXCEPTIONS
12
13
 
13
14
  logger = structlog.stdlib.get_logger(__name__)
14
15
 
@@ -93,8 +94,6 @@ async def overloaded_error_handler(request, exc: ValueError):
93
94
 
94
95
  def app_exception_handlers() -> dict:
95
96
  """The exception handlers shared by the server app and the operator routes."""
96
- # Imported here because the runtime imports this module while it loads.
97
- from langgraph_runtime.retry import OVERLOADED_EXCEPTIONS # noqa: PLC0415
98
97
 
99
98
  return {
100
99
  HTTPException: http_exception_handler,
@@ -20,14 +20,6 @@ USE_DURABILITY = LANGGRAPH_PY_MINOR >= (0, 6)
20
20
  _RUNTIME_EDITION = os.getenv("LANGGRAPH_RUNTIME_EDITION", "inmem")
21
21
  IS_POSTGRES_BACKEND = _RUNTIME_EDITION == "postgres"
22
22
  IS_INMEM_BACKEND = _RUNTIME_EDITION == "inmem"
23
- # The in-memory runtime runs on Go core with SQLite;
24
- # FF_INMEM_CORE=false falls back to the Python runtime.
25
- INMEM_USES_CORE = IS_INMEM_BACKEND and os.getenv("FF_INMEM_CORE", "true").lower() in (
26
- "true",
27
- "1",
28
- "yes",
29
- )
30
- IS_POSTGRES_OR_GRPC_BACKEND = IS_POSTGRES_BACKEND or INMEM_USES_CORE
31
23
  # Server-side kill switch for the Protocol v2 event-streaming surface
32
24
  # (#3296). When false, the v2 routes are not registered (clients hit a
33
25
  # 404), and ``_create_or_resume_run`` rejects any direct call with a
@@ -39,6 +31,13 @@ FF_V2_EVENT_STREAMING = os.getenv("FF_V2_EVENT_STREAMING", "true").lower() in (
39
31
  "1",
40
32
  "yes",
41
33
  )
34
+ # Gates the transcript API: ``GET /threads/{id}/transcript`` and the
35
+ # ``transcript`` thread stream mode.
36
+ FF_TRANSCRIPT_API = os.getenv("FF_TRANSCRIPT_API", "false").lower() in (
37
+ "true",
38
+ "1",
39
+ "yes",
40
+ )
42
41
 
43
42
 
44
43
  def _resolve_prefer_grpc_checkpointer(
@@ -65,7 +64,7 @@ def _resolve_prefer_grpc_checkpointer(
65
64
 
66
65
 
67
66
  # When true on the postgres runtime, use ``GrpcCheckpointer``.
68
- # Inmem on Go core always uses it; Python inmem never does.
67
+ # Inmem edition always uses ``GrpcCheckpointer``.
69
68
  # Custom checkpointer (``backend=custom`` in ``LANGGRAPH_CHECKPOINTER``) and
70
69
  # Mongo (``backend=mongo``) is also unaffected.
71
70
  # langgraph < 0.5 keeps Send() packets in checkpoint["pending_sends"], which only