Skip to content

Commit c43953f

Browse files
committed
docs(workflow): add comment to NodeState and fix formatting in _workflow_class.py
Change-Id: Ic49dfd0fc7593db81dceac8ea1c5dd69d63d6e74
1 parent 7c7a0d7 commit c43953f

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/google/adk/workflow/_node_state.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ class NodeState(BaseModel):
5050
"""The responses for resuming the node, keyed by interrupt id."""
5151

5252
run_counter: int = Field(default=0, exclude_if=lambda v: v == 0)
53-
"""Sequential counter incremented each time the node gets a fresh run."""
53+
"""Sequential counter incremented each time the node gets a fresh run.
54+
55+
Preserving this count independently of run_id prevents path collisions
56+
if a node switches between custom string IDs and auto-generated numeric IDs.
57+
"""
5458

5559
run_id: str | None = None
5660
"""The run ID of this node run."""

src/google/adk/workflow/_workflow_class.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,11 @@ def _restore_static_nodes_from_events(
597597
# For nodes with events but no output:
598598
# If wait_for_output is True, they are still WAITING for output.
599599
# Otherwise, they are considered COMPLETED (e.g., side-effect nodes).
600-
status = NodeStatus.WAITING if is_wait_for_output and child.output is None else NodeStatus.COMPLETED
600+
status = (
601+
NodeStatus.WAITING
602+
if is_wait_for_output and child.output is None
603+
else NodeStatus.COMPLETED
604+
)
601605
nodes[child_name] = NodeState(
602606
status=status,
603607
run_id=existing_evt_run_id,
@@ -701,7 +705,11 @@ def _scan_child_events(self, ctx: Context) -> dict[str, _ChildScanState]:
701705

702706
# New run_id → reset child state (previous run stale).
703707
# ONLY update run_id from direct child events, not descendants!
704-
evt_run_id = event.node_info.path.rsplit('@', 1)[-1] if '@' in event.node_info.path else ''
708+
evt_run_id = (
709+
event.node_info.path.rsplit('@', 1)[-1]
710+
if '@' in event.node_info.path
711+
else ''
712+
)
705713
if (
706714
is_direct_child(event.node_info.path, workflow_path)
707715
and evt_run_id

0 commit comments

Comments
 (0)