By configuring Orleans to serialize also CancellationTokens with System.Text.Json, I made the webapplication version work and also produce the expected output.
For that the nuget package Microsoft.Orleans.Serialization.SystemTextJson must be installed.
builder
.UseOrleans(siloBuilder =>
{
siloBuilder.UseLocalhostClustering();
siloBuilder.Services.AddSerializer(serializerBuilder =>
{
serializerBuilder.AddJsonSerializer(isSupported: typeCand => typeCand == typeof(System.Threading.CancellationToken));
});
});
More details and other approaches can be found in the docs (https://learn.microsoft.com/en-us/dotnet/orleans/host/configuration-guide/serialization-configuration?pivots=orleans-7-0#configure-orleans-to-use-systemtextjson).