Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
fc296c6
feat(core): add a stream sink registry and SSE streaming to the workf…
CasperGN Nov 25, 2026
90685d2
feat(langgraph): stream LLM tokens, node updates and custom events fr…
CasperGN Nov 25, 2026
50164a0
feat(langgraph): end a streamed run in failure when the run failed
CasperGN Nov 25, 2026
ae11143
feat(langgraph): keep updates under backpressure and report dropped o…
CasperGN Nov 25, 2026
3a4e421
feat(langgraph): close streams when the consumer leaves and match nat…
CasperGN Nov 25, 2026
8ad2c0f
feat(langgraph): make the SSE endpoint and astream() safe to run behi…
CasperGN Nov 25, 2026
7857b03
feat(langgraph): run START targets, waiting edges, subgraph and async…
CasperGN Nov 25, 2026
bd3f519
feat(langgraph): replay-safe message ids, reducer first writes, recur…
CasperGN Nov 25, 2026
e173444
feat(langgraph): run each Send as its own task and match LangGraph's …
CasperGN Nov 25, 2026
c75d1ad
feat(langgraph): match LangGraph's step order, limits, managed values…
CasperGN Nov 25, 2026
44cbe3a
test(langgraph): cover streaming, the SSE endpoint, stream lifecycle …
CasperGN Nov 25, 2026
78c2bfa
test(langgraph): cover LangGraph execution semantics in the workflow …
CasperGN Nov 25, 2026
bde4a77
fix(langgraph): only turn input into messages on add_messages channels
CasperGN Nov 25, 2026
e0a8807
test(langgraph): compare Send-router tokens per task, not by arrival …
CasperGN Nov 25, 2026
a3ead2a
test(langgraph): expect a node's routers to run inside its activity
CasperGN Nov 26, 2026
bcec2fc
feat(langgraph): run a node's routers inside the node's activity
CasperGN Nov 26, 2026
4551995
docs(langgraph): drop the router-order limit from the streaming README
CasperGN Nov 26, 2026
17e319e
test(langgraph): expect the values, tasks and debug stream modes
CasperGN Nov 26, 2026
8caf483
feat(langgraph): stream the values, tasks and debug modes
CasperGN Nov 26, 2026
4cb0a24
docs(langgraph): list the stream modes and why checkpoints is refused
CasperGN Nov 26, 2026
6320f3d
test(langgraph): expect workflow_started only after the workflow is s…
CasperGN Nov 26, 2026
77d60e3
fix(langgraph): send workflow_started after scheduling returns
CasperGN Nov 26, 2026
ab19421
test(langgraph): expect GET /agent/run/{id} to return a finished run'…
CasperGN Nov 26, 2026
0e554d0
feat(langgraph): return the run's result from GET /agent/run/{id}, of…
CasperGN Nov 26, 2026
8020d03
test(langgraph): expect routers that streamed nothing in missing_nodes
CasperGN Nov 26, 2026
6e082e5
feat(langgraph): report routers that ran elsewhere in stream_unavailable
CasperGN Nov 26, 2026
199b73e
test(langgraph): expect native langgraph_* task metadata without a st…
CasperGN Nov 26, 2026
988d118
feat(langgraph): set langgraph_* metadata on every task's config, str…
CasperGN Nov 26, 2026
cb15f1d
docs(langgraph): describe running behind a proxy and what to do when …
CasperGN Nov 26, 2026
b1e64ab
test(langgraph): expect thread_id to carry state between runs with a …
CasperGN Nov 26, 2026
952e735
feat(langgraph): carry a thread's state between runs through a checkp…
CasperGN Nov 26, 2026
1f7e639
test(langgraph): drop an unused helper import from the golden values …
CasperGN Nov 26, 2026
58f64fb
test(stream): expect a state-store event log any replica can resume from
CasperGN Nov 26, 2026
1f17423
feat(stream): add a state-store event log and a resumable stream cursor
CasperGN Nov 26, 2026
e9a0956
test(langgraph): expect streams to go through the state-store log whe…
CasperGN Nov 26, 2026
83ebfd5
feat(langgraph): stream through the state-store event log whenever th…
CasperGN Nov 26, 2026
9cbfc52
test(langgraph): expect GET /agent/run/{id}/stream to resume a stream…
CasperGN Nov 26, 2026
c1ffe68
feat(langgraph): reconnect to a run's stream with GET /agent/run/{id}…
CasperGN Nov 26, 2026
68b6b9d
test(langgraph): expect interrupt() to pause the run durably and Comm…
CasperGN Nov 26, 2026
2ace7d7
feat(langgraph): pause a run on interrupt() and resume it with Comman…
CasperGN Nov 26, 2026
2d277a0
test(langgraph): expect the README to document reconnecting, the stre…
CasperGN Nov 26, 2026
6fde78e
docs(langgraph): document reconnecting, the stream transport, SSE ids…
CasperGN Nov 26, 2026
34697ee
refactor(langgraph): move the node loop and Runnable call helpers out…
CasperGN Nov 26, 2026
58eb557
fix(langgraph): pause on interrupt() in a subgraph or a router instea…
CasperGN Nov 26, 2026
fcd3918
fix(langgraph): resume a paused run with invoke(Command(resume=...))
CasperGN Nov 26, 2026
243ecdd
fix(langgraph): carry thread state only for a thread the caller names
CasperGN Nov 26, 2026
7fbf82f
fix(langgraph): expire, prune and etag-write a thread's checkpoints
CasperGN Nov 26, 2026
2e0c588
fix(langgraph): return a run's output when its thread state cannot be…
CasperGN Nov 26, 2026
aa12be9
fix(stream): retry an activity's last stream-log write with backoff
CasperGN Nov 26, 2026
ebb7749
fix(langgraph): send each values chunk once on a reconnect
CasperGN Nov 26, 2026
0f32dea
fix(langgraph): keep streaming after a purged part of the log
CasperGN Nov 26, 2026
e7ace69
fix(langgraph): stream the attempt of a node whose output the run used
CasperGN Nov 26, 2026
08bade7
fix(langgraph): answer 409 to a resume another request beat to the run
CasperGN Nov 26, 2026
f354e66
perf(langgraph): bound a streamed run's custom status and read it less
CasperGN Nov 26, 2026
cf0a9a2
docs(langgraph): say which runs keep thread state and how to secure t…
CasperGN Nov 26, 2026
dbdf339
fix(langgraph): run a node through its sync entry when its middleware…
CasperGN Nov 26, 2026
cd49430
fix(langgraph): type the fix pass for mypy
CasperGN Nov 26, 2026
1500c9d
fix(stream-log): write a batch before the head that counts it
CasperGN Nov 26, 2026
7fe3110
fix(stream-log): look at the head again before an attempt's last write
CasperGN Nov 26, 2026
bf2c69f
fix(langgraph): wait for the final event when a reader is behind the …
CasperGN Nov 26, 2026
a3ea81b
fix(langgraph): keep threads in the workflow state store when there i…
CasperGN Nov 26, 2026
1786d58
fix(langgraph): load a thread's state whatever its id and concurrent …
CasperGN Nov 26, 2026
58c6f0c
fix(langgraph): a replay of a run whose whole log expired says stream…
CasperGN Nov 26, 2026
2584fea
fix(langgraph): resume each of a subgraph's parallel interrupts by it…
CasperGN Nov 26, 2026
0543be2
fix(langgraph): a resume that lost gets 409 even after the run moved on
CasperGN Nov 26, 2026
c554622
fix(langgraph): refuse a null resume over HTTP and a resume that also…
CasperGN Nov 26, 2026
b48af66
fix(langgraph): a stream that fails while the run goes on resumes fro…
CasperGN Nov 26, 2026
92167a3
fix(langgraph): a live stream drains the step a run paused or failed in
CasperGN Nov 26, 2026
9000865
fix(langgraph): a reconnected stream starts at the client's id, not v…
CasperGN Nov 26, 2026
aec4d6b
fix(langgraph): a resume's stream starts after the run's last chunk, …
CasperGN Nov 26, 2026
2cb5131
test(langgraph): keep the inline when_all in place for the whole session
CasperGN Nov 26, 2026
d5f1308
fix(langgraph): take a resume stream's start id before the resume is …
CasperGN Nov 27, 2026
290cf4e
fix(langgraph): record only the stream modes a run was started with
CasperGN Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions diagrid/agent/core/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class DiscoveredComponents:
registry_store_name: Optional[str] = None
"""``state`` type component named ``agent-registry``."""

workflow_store_name: Optional[str] = None
"""The ``state`` type component workflows keep their state in (the actor
state store): every workflow app has one."""

runtime_conf: dict[str, str] = field(default_factory=dict)
"""Config loaded from ``agent-runtime`` statestore key ``agent_runtime``."""

Expand All @@ -53,6 +57,7 @@ def discover_components() -> DiscoveredComponents:
- ``state`` type + name ``agent-memory`` -> ``memory_store_name``
- ``pubsub`` type + name ``agent-pubsub`` -> ``pubsub_name``
- ``state`` type + name ``agent-registry`` -> ``registry_store_name``
- ``state`` type with the ``ACTOR`` capability -> ``workflow_store_name``
- ``state`` type + name ``agent-runtime`` -> loads ``agent_runtime`` key into ``runtime_conf``

Returns ``DiscoveredComponents()`` with empty defaults on sidecar error.
Expand Down Expand Up @@ -81,6 +86,10 @@ def discover_components() -> DiscoveredComponents:
if "pubsub" in ctype and cname == "agent-pubsub":
result.pubsub_name = cname

capabilities = getattr(component, "capabilities", None) or ()
if "state" in ctype and "ACTOR" in capabilities:
result.workflow_store_name = cname

if "state" in ctype and cname == "agent-registry":
result.registry_store_name = cname

Expand Down
51 changes: 51 additions & 0 deletions diagrid/agent/core/state/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,44 @@ def get(self, key: str) -> Any | None:
return None
return json.loads(response.data.decode())

def get_with_etag(self, key: str) -> tuple[Any | None, Optional[str]]:
"""A value and its etag (``(None, None)`` when the key does not exist)."""
response = self._get_client().get_state(store_name=self._store_name, key=key)
if not response.data:
return None, None
return json.loads(response.data.decode()), (response.etag or None)

def save_with_etag(
self,
key: str,
value: Any,
etag: Optional[str],
metadata: Optional[dict[str, str]] = None,
) -> bool:
"""Save ``value`` only if the key still has ``etag`` (first-write wins).

``etag`` ``None`` saves only a key that does not exist yet. Returns
``False`` when another write got there first (the sidecar answers
``ABORTED``); any other error propagates.
"""
from dapr.clients.grpc._state import Concurrency, StateOptions

try:
self._get_client().save_state(
store_name=self._store_name,
key=key,
value=json.dumps(value),
etag=etag,
options=StateOptions(concurrency=Concurrency.first_write),
state_metadata=metadata,
)
except Exception as e:
if _is_etag_conflict(e):
logger.debug("Etag conflict on key=%s store=%s", key, self._store_name)
return False
raise
return True

def delete(self, key: str) -> None:
"""Delete a key from the state store.

Expand Down Expand Up @@ -141,3 +179,16 @@ def close(self) -> None:
if self._client is not None:
self._client.close()
self._client = None


def _is_etag_conflict(error: Exception) -> bool:
"""Whether a save failed because the key's etag changed (gRPC ``ABORTED``)."""
code = getattr(error, "code", None)
if not callable(code):
return False
try:
import grpc

return bool(code() == grpc.StatusCode.ABORTED)
except Exception: # not a gRPC error after all
return False
Loading