Portal Community

Escalation Flow

1

Original actor times out

HILTimeoutJob detects expired suspension with TimeoutBehavior=Escalate.

2

Resolve escalation actor

HILEscalationService resolves escalationActorId (static or dynamic expression).

3

Cancel original task

Original HIL task marked as Escalated. Original actor's inbox item disappears.

4

Create escalation task

New HIL task created for escalation actor. ExpiresAt reset to escalationDuration from now.

5a

Escalation actor responds

Normal resume flow. Execution continues on approved/rejected port.

5b

Escalation also times out

Timeout port fires — route to fallback node or end.

HILEscalationService Code

public async Task EscalateAsync(SuspendedExecution suspension, CancellationToken ct)
{
    // Resolve escalation actor (may be a dynamic expression)
    var escalationActorId = await ResolveActorAsync(suspension.EscalationActorId, suspension.ExecutionId, ct);

    // Cancel the original task
    await _hilTaskRepo.CancelAsync(suspension.HilTaskId, "Escalated due to timeout", ct);

    // Reset expiry for escalation
    var escalationDuration = suspension.EscalationDuration ?? suspension.TimeoutDuration;
    var newExpiresAt = DateTimeOffset.UtcNow.Add(escalationDuration);

    // Update the suspension with escalation actor and new deadline
    await _suspendedRepo.UpdateForEscalationAsync(
        suspension.ExecutionResId, escalationActorId, newExpiresAt, ct);

    // Create new HIL task for escalation actor
    await _hilTaskRepo.CreateAsync(new HilTask
    {
        ExecutionResId = suspension.ExecutionResId,
        ActorId        = escalationActorId,
        IsEscalated    = true,
        ExpiresAt      = newExpiresAt
    }, ct);

    // Notify escalation actor
    await _notificationService.NotifyEscalationAsync(escalationActorId, suspension, ct);
}
Double-escalation protection: If the escalation itself times out, the suspension's IsEscalated flag is already set. The timeout job fires the timeout port instead of attempting a second escalation. Chained escalations (manager → director → VP) must be modelled as separate HIL nodes in the workflow graph.