Skip to content

Commit 39b16a9

Browse files
committed
test(workflow): Remove node_name from simplified events to reduce redundancy
Removed node_name from simplify_event_with_node output and from keys in simplified_nodes in simplify_events_with_node_and_agent_state. Updated all test call sites in tests/unittests/workflow to match the new output format. Change-Id: If17c4cc343b8baa331f1ec516e7d42bc061cf749
1 parent 4476854 commit 39b16a9

18 files changed

Lines changed: 260 additions & 394 deletions

tests/unittests/workflow/old/test_function_node.py

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -107,31 +107,29 @@ def sync_gen_func_raw_output(
107107
assert simplify_events_with_node(events) == [
108108
(
109109
'test_workflow_agent_various_function_nodes@1/async_gen_func@1',
110-
{'node_name': 'async_gen_func', 'output': 'Hello from AsyncGen'},
110+
{'output': 'Hello from AsyncGen'},
111111
),
112112
(
113113
'test_workflow_agent_various_function_nodes@1/sync_func_out@1',
114-
{'node_name': 'sync_func_out', 'output': 'Hello from SyncFunc'},
114+
{'output': 'Hello from SyncFunc'},
115115
),
116116
(
117117
'test_workflow_agent_various_function_nodes@1/async_func_out@1',
118-
{'node_name': 'async_func_out', 'output': 'Hello from AsyncFunc'},
118+
{'output': 'Hello from AsyncFunc'},
119119
),
120120
(
121121
'test_workflow_agent_various_function_nodes@1/sync_gen_func@1',
122-
{'node_name': 'sync_gen_func', 'output': 'Hello from SyncGen'},
122+
{'output': 'Hello from SyncGen'},
123123
),
124124
(
125125
'test_workflow_agent_various_function_nodes@1/async_gen_func_raw_output@1',
126126
{
127-
'node_name': 'async_gen_func_raw_output',
128127
'output': 'Hello from AsyncGenRawOutput',
129128
},
130129
),
131130
(
132131
'test_workflow_agent_various_function_nodes@1/sync_gen_func_raw_output@1',
133132
{
134-
'node_name': 'sync_gen_func_raw_output',
135133
'output': 'Hello from SyncGenRawOutput',
136134
},
137135
),
@@ -165,7 +163,6 @@ def check_state_node_fn(param1: str, param2: str = 'default2') -> str:
165163
(
166164
'test_workflow_agent_state_injection@1/check_state_node_fn@1',
167165
{
168-
'node_name': 'check_state_node_fn',
169166
'output': 'param1=value1, param2=default2',
170167
},
171168
),
@@ -247,14 +244,12 @@ def node2_fn(node_input: dict[str, Any]) -> str:
247244
(
248245
'test_workflow_agent_input_injection_dict@1/node1_fn@1',
249246
{
250-
'node_name': 'node1_fn',
251247
'output': {'p1': 'value1_from_node_input', 'p2': 100},
252248
},
253249
),
254250
(
255251
'test_workflow_agent_input_injection_dict@1/node2_fn@1',
256252
{
257-
'node_name': 'node2_fn',
258253
'output': 'p1=value1_from_node_input, p2=100',
259254
},
260255
),
@@ -293,14 +288,12 @@ def node2_fn(node_input: MyModel) -> str:
293288
(
294289
'test_workflow_agent_input_injection_pydantic@1/node1_fn@1',
295290
{
296-
'node_name': 'node1_fn',
297291
'output': {'p1': 'value1_from_node_input', 'p2': 100},
298292
},
299293
),
300294
(
301295
'test_workflow_agent_input_injection_pydantic@1/node2_fn@1',
302296
{
303-
'node_name': 'node2_fn',
304297
'output': 'p1=value1_from_node_input, p2=100',
305298
},
306299
),
@@ -361,14 +354,12 @@ def node2_fn(node_input: list) -> str:
361354
(
362355
'test_workflow_agent_input_list_no_item_type@1/node1_fn@1',
363356
{
364-
'node_name': 'node1_fn',
365357
'output': [1, 2],
366358
},
367359
),
368360
(
369361
'test_workflow_agent_input_list_no_item_type@1/node2_fn@1',
370362
{
371-
'node_name': 'node2_fn',
372363
'output': 'list=[1, 2]',
373364
},
374365
),
@@ -406,12 +397,11 @@ def nodeb_fn(
406397
assert simplify_events_with_node(events) == [
407398
(
408399
'test_node_param_injection_single_and_state@1/nodea_fn@1',
409-
{'node_name': 'nodea_fn', 'output': 'value_A'},
400+
{'output': 'value_A'},
410401
),
411402
(
412403
'test_node_param_injection_single_and_state@1/nodeb_fn@1',
413404
{
414-
'node_name': 'nodeb_fn',
415405
'output': (
416406
'node_input=value_A, p_state=value_from_state,'
417407
' p_default=default2'
@@ -450,7 +440,6 @@ def node2_fn(my_model: MyModel) -> str:
450440
(
451441
'test_workflow_agent_state_injection_pydantic@1/node2_fn@1',
452442
{
453-
'node_name': 'node2_fn',
454443
'output': 'p1=value1_from_state, p2=200',
455444
},
456445
),
@@ -534,7 +523,6 @@ def process_input_fn(node_input: dict[str, Any]) -> str:
534523
(
535524
'test_workflow_agent_hitl@1/request_input_fn@1',
536525
{
537-
'node_name': 'request_input_fn',
538526
'output': {'text': 'Hello from user'},
539527
},
540528
),
@@ -550,7 +538,6 @@ def process_input_fn(node_input: dict[str, Any]) -> str:
550538
(
551539
'test_workflow_agent_hitl@1/process_input_fn@1',
552540
{
553-
'node_name': 'process_input_fn',
554541
'output': 'received: Hello from user',
555542
},
556543
),
@@ -981,15 +968,13 @@ def read_state(user_request: str) -> str:
981968
(
982969
'test_ctx_state_delta_sync@1/set_state_via_ctx@1',
983970
{
984-
'node_name': 'set_state_via_ctx',
985971
'output': 'done',
986972
'state_delta': {'user_request': 'build a tracker app'},
987973
},
988974
),
989975
(
990976
'test_ctx_state_delta_sync@1/read_state@1',
991977
{
992-
'node_name': 'read_state',
993978
'output': 'request=build a tracker app',
994979
},
995980
),
@@ -1024,15 +1009,13 @@ def read_state(counter: int, name: str) -> str:
10241009
(
10251010
'test_ctx_state_delta_async@1/set_state_via_ctx@1',
10261011
{
1027-
'node_name': 'set_state_via_ctx',
10281012
'output': 'set',
10291013
'state_delta': {'counter': 42, 'name': 'test'},
10301014
},
10311015
),
10321016
(
10331017
'test_ctx_state_delta_async@1/read_state@1',
10341018
{
1035-
'node_name': 'read_state',
10361019
'output': 'counter=42, name=test',
10371020
},
10381021
),
@@ -1065,15 +1048,13 @@ def read_state(my_key: str) -> str:
10651048
(
10661049
'test_ctx_state_delta_none_return@1/set_state_return_none@1',
10671050
{
1068-
'node_name': 'set_state_return_none',
10691051
'state_delta': {'my_key': 'my_value'},
10701052
'output': None,
10711053
},
10721054
),
10731055
(
10741056
'test_ctx_state_delta_none_return@1/read_state@1',
10751057
{
1076-
'node_name': 'read_state',
10771058
'output': 'my_key=my_value',
10781059
},
10791060
),
@@ -1110,7 +1091,6 @@ def read_state(from_ctx: str, from_event: str) -> str:
11101091
(
11111092
'test_ctx_state_delta_event_return@1/set_state_return_event@1',
11121093
{
1113-
'node_name': 'set_state_return_event',
11141094
'output': 'result',
11151095
'state_delta': {
11161096
'from_event': 'event_value',
@@ -1121,7 +1101,6 @@ def read_state(from_ctx: str, from_event: str) -> str:
11211101
(
11221102
'test_ctx_state_delta_event_return@1/read_state@1',
11231103
{
1124-
'node_name': 'read_state',
11251104
'output': 'from_ctx=ctx_value, from_event=event_value',
11261105
},
11271106
),
@@ -1160,23 +1139,20 @@ def read_state(key1: str, key2: str) -> str:
11601139
(
11611140
'test_ctx_state_delta_generator@1/gen_with_state@1',
11621141
{
1163-
'node_name': 'gen_with_state',
11641142
'output': None,
11651143
'state_delta': {'key1': 'value1'},
11661144
},
11671145
),
11681146
(
11691147
'test_ctx_state_delta_generator@1/gen_with_state@1',
11701148
{
1171-
'node_name': 'gen_with_state',
11721149
'output': 'done',
11731150
'state_delta': {'key1': 'value1', 'key2': 'value2'},
11741151
},
11751152
),
11761153
(
11771154
'test_ctx_state_delta_generator@1/read_state@1',
11781155
{
1179-
'node_name': 'read_state',
11801156
'output': 'key1=value1, key2=value2',
11811157
},
11821158
),
@@ -1705,11 +1681,11 @@ def produce():
17051681
assert simplify_events_with_node(events) == [
17061682
(
17071683
'test_bind_from_node_input@1/produce@1',
1708-
{'node_name': 'produce', 'output': producer_output},
1684+
{'output': producer_output},
17091685
),
17101686
(
17111687
'test_bind_from_node_input@1/add@1',
1712-
{'node_name': 'add', 'output': expected_output},
1688+
{'output': expected_output},
17131689
),
17141690
]
17151691

@@ -1773,11 +1749,11 @@ def greet(name: str, ctx: Context):
17731749
assert simplify_events_with_node(events) == [
17741750
(
17751751
'test_bind_node_input_ctx@1/produce@1',
1776-
{'node_name': 'produce', 'output': {'name': 'Alice'}},
1752+
{'output': {'name': 'Alice'}},
17771753
),
17781754
(
17791755
'test_bind_node_input_ctx@1/greet@1',
1780-
{'node_name': 'greet', 'output': 'Hello, Alice!'},
1756+
{'output': 'Hello, Alice!'},
17811757
),
17821758
]
17831759

tests/unittests/workflow/old/test_node.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def my_func():
6464
(
6565
"test_agent@1/decorated_node@1",
6666
{
67-
"node_name": "decorated_node",
6867
"output": "Hello from decorated_func",
6968
},
7069
),
@@ -122,35 +121,30 @@ async def producer_func() -> list[int]:
122121
(
123122
"test_agent@1/producer_func@1",
124123
{
125-
"node_name": "producer_func",
126124
"output": [1, 2, 3],
127125
},
128126
),
129127
(
130128
"test_agent@1/my_func@1/my_func@1",
131129
{
132-
"node_name": "my_func",
133130
"output": 2,
134131
},
135132
),
136133
(
137134
"test_agent@1/my_func@1/my_func@2",
138135
{
139-
"node_name": "my_func",
140136
"output": 4,
141137
},
142138
),
143139
(
144140
"test_agent@1/my_func@1/my_func@3",
145141
{
146-
"node_name": "my_func",
147142
"output": 6,
148143
},
149144
),
150145
(
151146
"test_agent@1/my_func@1",
152147
{
153-
"node_name": "my_func",
154148
"output": [2, 4, 6],
155149
},
156150
),
@@ -275,15 +269,13 @@ def read_state(tool_key: str, tool_count: int) -> str:
275269
(
276270
"test_tool_node_state_delta@1/stateful_tool@1",
277271
{
278-
"node_name": "stateful_tool",
279272
"output": {"status": "ok"},
280273
"state_delta": {"tool_key": "tool_value", "tool_count": 10},
281274
},
282275
),
283276
(
284277
"test_tool_node_state_delta@1/read_state@1",
285278
{
286-
"node_name": "read_state",
287279
"output": "tool_key=tool_value, tool_count=10",
288280
},
289281
),
@@ -320,15 +312,13 @@ def read_state(silent_key: str) -> str:
320312
(
321313
"test_tool_node_state_delta_no_return@1/stateful_tool_no_return@1",
322314
{
323-
"node_name": "stateful_tool_no_return",
324315
"output": None,
325316
"state_delta": {"silent_key": "silent_value"},
326317
},
327318
),
328319
(
329320
"test_tool_node_state_delta_no_return@1/read_state@1",
330321
{
331-
"node_name": "read_state",
332322
"output": "silent_key=silent_value",
333323
},
334324
),

tests/unittests/workflow/old/test_node_timeout.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async def test_node_completes_within_timeout(request: pytest.FixtureRequest):
100100
events = [e async for e in agent.run_async(ctx)]
101101

102102
assert simplify_events_with_node(events) == [
103-
('test_workflow@1/NodeA@1', {'node_name': 'NodeA', 'output': 'done'}),
103+
('test_workflow@1/NodeA@1', {'output': 'done'}),
104104
]
105105

106106

@@ -138,7 +138,7 @@ async def test_node_no_timeout(request: pytest.FixtureRequest):
138138
events = [e async for e in agent.run_async(ctx)]
139139

140140
assert simplify_events_with_node(events) == [
141-
('test_workflow@1/NodeA@1', {'node_name': 'NodeA', 'output': 'done'}),
141+
('test_workflow@1/NodeA@1', {'output': 'done'}),
142142
]
143143

144144

@@ -172,7 +172,7 @@ async def test_timeout_with_retry(request: pytest.FixtureRequest):
172172
events = [e async for e in agent.run_async(ctx)]
173173

174174
assert simplify_events_with_node(events) == [
175-
('test_workflow@1/NodeA@1', {'node_name': 'NodeA', 'output': 'success'}),
175+
('test_workflow@1/NodeA@1', {'output': 'success'}),
176176
]
177177

178178
# Verify retry_count in agent state events to confirm retry occurred.

0 commit comments

Comments
 (0)