Problem
LlmSessionActor has an implicit state machine implemented via Become() calls
with Command<> registrations that don't compose cleanly. The current states
(Ready, Processing, Compacting) work but adding new states is fragile:
Command<> handlers registered in one Become() scope can conflict with handlers
in shared methods like CommandSubscriptionMessages()
- Adding a
Passivating state (needed for pre-shutdown memory distillation) requires
either duplicating shared handler registration or using boolean flags — both are
brittle
- The actor is 3000+ lines and its state transitions are scattered across methods
rather than being explicitly defined
Motivation
This blocks two features:
Proposed approach
- Define an explicit state enum:
Ready, Processing, Compacting, Passivating
- Extract shared command handlers into composable methods that can be mixed into any state
- Make state transitions explicit and testable
- Extract dependencies (memory observation, compaction, tool execution) into
independently testable components where possible
- Reduce the actor's line count by extracting concerns into child actors or services
Related
Problem
LlmSessionActorhas an implicit state machine implemented viaBecome()callswith
Command<>registrations that don't compose cleanly. The current states(Ready, Processing, Compacting) work but adding new states is fragile:
Command<>handlers registered in oneBecome()scope can conflict with handlersin shared methods like
CommandSubscriptionMessages()Passivatingstate (needed for pre-shutdown memory distillation) requireseither duplicating shared handler registration or using boolean flags — both are
brittle
rather than being explicitly defined
Motivation
This blocks two features:
distill before the session stops, requiring a
Passivatingbehavior statewhich requires explicit lifecycle state management
Proposed approach
Ready,Processing,Compacting,Passivatingindependently testable components where possible
Related