Skip to content

runtime/session: recover interrupted actor resumes - #3649

Open
shashankram wants to merge 2 commits into
kagent-dev:mainfrom
shashankram:resume-canceled
Open

shashankram wants to merge 2 commits into
kagent-dev:mainfrom
shashankram:resume-canceled

Conversation

@shashankram

Copy link
Copy Markdown
Contributor

Description

Requires #3635 to merge first. This branch builds on that PR; its separate follow-up commit is d30cb0bd.

Canceling message delivery during actor restoration can leave the actor RESUMING without a turn, holding worker capacity. The existing Session lifecycle worker now retries resume, then suspends the actor so a later message can resume normally.

  • Retain the same cleanup claim through resume, suspension, and snapshot recording, preventing new turns from racing cleanup.
  • Queue bounded attempts with exponential backoff capped at 15 seconds, freeing workers during delays. Database retries do not repeat completed runtime operations.
  • Preserve uncertain claims, coordinate crash recovery, and allow explicit force deletion when cleanup cannot safely finish.
Interrupted-resume cleanup flow
sequenceDiagram
    participant D as Session store
    participant W as Lifecycle worker
    participant S as Substrate
    W->>D: Claim expired dispatch with no active turn
    W->>S: Read actor identity and state
    alt Actor is RESUMING
        W->>S: Resume actor
        S-->>W: Confirm RUNNING
    end
    W->>S: Suspend actor and save durable snapshot
    S-->>W: Confirm suspension and snapshot
    W->>D: Record snapshot and clear dispatch and claim
    Note over W,S: Retryable failures requeue the same owner with backoff
Loading

Testing

  • Added coverage for interrupted resume, lost replies, retained ownership, competing lifecycle work, worker fairness, and shutdown.
  • Added an E2E regression that cancels during RESUMING, verifies suspension with no tasks or worker assignment, then sends a successful subsequent message.

Change Type

/kind fix

Changelog

Actors left resuming after canceled message delivery now recover and suspend automatically.

\# Description

Canceled delivery can leave a restored actor running without a turn,
holding worker capacity indefinitely.

- Retain expired dispatch attempts for the existing lifecycle worker to process.
- Claim suspension only when no active turn or newer delivery owns the Session.
- Preserve snapshots and logical readiness so subsequent messages resume normally.
- Cover cancellation, competing lifecycle work, retries, and subsequent delivery.

\# Change Type

```
/kind fix
```

\# Changelog

```release-note
Actors left running after canceled message delivery now suspend and release worker capacity automatically.
```

\# Additional Notes

Signed-off-by: Shashank Ram <shashank.ram@solo.io>
\# Description

Canceled message delivery can leave an actor stuck resuming without a turn,
holding worker capacity until another caller resumes it.

- Resume interrupted actors before suspending under the existing cleanup claim.
- Queue bounded retries with backoff capped at 15 seconds to free workers.
- Preserve ownership across retries and allow explicit force deletion of cleanup.
- Cover cancellation, lost replies, competing lifecycle work, and later delivery.

\# Change Type

```
/kind fix
```

\# Changelog

```release-note
Actors left resuming after canceled message delivery now recover and suspend automatically.
```

\# Additional Notes

Signed-off-by: Shashank Ram <shashank.ram@solo.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant