Skip to content

Commit 2368fb8

Browse files
committed
refactor(workflow): Remove run ID handling in tests
Removed node name mapping, run ID splitting, and related parameters from testing utils as unique names are no longer generated for dynamic nodes. Change-Id: I2a1e96b0b37d62800b847f71720ddf51a43eb5bc
1 parent 2be5027 commit 2368fb8

2 files changed

Lines changed: 3 additions & 51 deletions

File tree

tests/unittests/workflow/testing_utils.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -141,37 +141,17 @@ def append_user_content(
141141
return event
142142

143143

144-
def _is_run_id_suffix(part: str) -> bool:
145-
"""Checks if a string part looks like an auto-generated run ID suffix."""
146-
return len(part) == 15 or part.isdigit()
147-
148-
149-
def _split_name_and_run_id(name: str) -> tuple[str, str | None]:
150-
"""Splits a node name into base name and run ID suffix if present."""
151-
for sep in ('@', '_'):
152-
if sep in name:
153-
parts = name.split(sep)
154-
if _is_run_id_suffix(parts[-1]):
155-
return sep.join(parts[:-1]), parts[-1]
156-
return name, None
157-
158-
159144
# Extracts the contents from the events and transform them into a list of
160145
# (author, simplified_content) tuples.
161-
def simplify_events(
162-
events: list[Event], *, strip_run_id: bool = False
163-
) -> list[tuple[str, types.Part]]:
146+
def simplify_events(events: list[Event]) -> list[tuple[str, types.Part]]:
164147
res = []
165148
for event in events:
166149
if event.content:
167150
author = event.author
168-
if strip_run_id:
169-
author, _ = _split_name_and_run_id(author)
170151
res.append((author, simplify_content(event.content)))
171152
return res
172153

173154

174-
175155
END_OF_AGENT = 'end_of_agent'
176156

177157

tests/unittests/workflow/workflow_testing_utils.py

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
from pydantic import Field
4242
from typing_extensions import override
4343

44-
from .testing_utils import _split_name_and_run_id
4544
from .testing_utils import END_OF_AGENT
4645
from .testing_utils import simplify_content
4746

@@ -183,19 +182,6 @@ async def create_parent_invocation_context(
183182
)
184183

185184

186-
def _build_node_name_map(events: list[Event]) -> dict[str, str]:
187-
"""Builds a map from node name to source node name from state updates."""
188-
node_name_map = {}
189-
for event in events:
190-
if event.actions.agent_state:
191-
nodes = event.actions.agent_state.get('nodes', {})
192-
for node_name, node_state in nodes.items():
193-
source_name = node_state.get('source_node_name')
194-
if source_name:
195-
node_name_map[node_name] = source_name
196-
return node_name_map
197-
198-
199185
def simplify_event_with_node(
200186
event: Event,
201187
include_state_delta: bool = False,
@@ -240,14 +226,9 @@ def simplify_events_with_node(
240226
events: list[Event],
241227
*,
242228
include_state_delta: bool = False,
243-
map_dynamic_node_to_the_source: bool = False,
244229
include_workflow_output: bool = False,
245230
) -> list[tuple[str, Any]]:
246231
results = []
247-
node_name_map = {}
248-
249-
if map_dynamic_node_to_the_source:
250-
node_name_map = _build_node_name_map(events)
251232

252233
# Second pass: Simplify events
253234
for event in events:
@@ -268,11 +249,7 @@ def simplify_events_with_node(
268249
if hasattr(event, 'node_info') and event.node_info.path:
269250
author = event.node_info.path
270251
else:
271-
author = node_name_map.get(event.author, event.author)
272-
# Strip auto-generated dynamic execution run IDs or counter numeric indices
273-
# from dynamic child/standalone parallel execution authors so assertions
274-
# match base node definition names consistently.
275-
author, _ = _split_name_and_run_id(author)
252+
author = event.author
276253
results.append((author, simplified_event))
277254
return results
278255

@@ -283,7 +260,6 @@ def simplify_events_with_node_and_agent_state(
283260
include_state_delta: bool = False,
284261
include_inputs_and_triggers: bool = False,
285262
include_resume_inputs: bool = False,
286-
map_dynamic_node_to_the_source: bool = False,
287263
include_workflow_output: bool = False,
288264
):
289265
fields_to_exclude = {'run_id'}
@@ -293,10 +269,6 @@ def simplify_events_with_node_and_agent_state(
293269
fields_to_exclude.add('resume_inputs')
294270

295271
results = []
296-
node_name_map = {}
297-
298-
if map_dynamic_node_to_the_source:
299-
node_name_map = _build_node_name_map(events)
300272

301273
for event in events:
302274
# Optionally skip top-level workflow output events.
@@ -313,7 +285,7 @@ def simplify_events_with_node_and_agent_state(
313285
if hasattr(event, 'node_info') and event.node_info.path:
314286
author = event.node_info.path
315287
else:
316-
author = node_name_map.get(event.author, event.author)
288+
author = event.author
317289

318290
if simplified_event:
319291
results.append((author, simplified_event))

0 commit comments

Comments
 (0)