@@ -366,6 +366,45 @@ def orchestrator(ctx: task.OrchestrationContext, input: int):
366366 assert all_results == [1 , 2 , 3 , 4 , 5 ]
367367
368368
369+ def test_continue_as_new_with_activity_e2e ():
370+ """E2E test for continue_as_new with activities (generator-based)."""
371+ activity_results = []
372+
373+ def double_activity (ctx : task .ActivityContext , value : int ) -> int :
374+ """Activity that doubles the value."""
375+ result = value * 2
376+ activity_results .append (result )
377+ return result
378+
379+ def orchestrator (ctx : task .OrchestrationContext , counter : int ):
380+ # Call activity to process the counter
381+ processed = yield ctx .call_activity (double_activity , input = counter )
382+
383+ # Continue as new up to 3 times
384+ if counter < 3 :
385+ ctx .continue_as_new (counter + 1 , save_events = False )
386+ else :
387+ return {"counter" : counter , "processed" : processed , "all_results" : activity_results }
388+
389+ with worker .TaskHubGrpcWorker () as w :
390+ w .add_activity (double_activity )
391+ w .add_orchestrator (orchestrator )
392+ w .start ()
393+
394+ task_hub_client = client .TaskHubGrpcClient ()
395+ id = task_hub_client .schedule_new_orchestration (orchestrator , input = 1 )
396+
397+ state = task_hub_client .wait_for_orchestration_completion (id , timeout = 30 )
398+ assert state is not None
399+ assert state .runtime_status == client .OrchestrationStatus .COMPLETED
400+
401+ output = json .loads (state .serialized_output )
402+ # Should have called activity 3 times with input values 1, 2, 3
403+ assert activity_results == [2 , 4 , 6 ]
404+ assert output ["counter" ] == 3
405+ assert output ["processed" ] == 6
406+
407+
369408# NOTE: This test fails when running against durabletask-go with sqlite because the sqlite backend does not yet
370409# support orchestration ID reuse. This gap is being tracked here:
371410# https://github.com/microsoft/durabletask-go/issues/42
0 commit comments