loadContainerState

open suspend override fun loadContainerState(userId: String): KarlContainerState?(source)

Retrieves the most recently saved learning state for a specific user.

This method provides efficient state recovery capabilities that enable the AI system to resume learning from exactly where it left off in previous sessions. The operation is optimized for quick application startup and seamless user experience continuity.

Recovery Process:

  • User Isolation: Queries only data associated with the specified user

  • Latest State: Returns the most recent state for version compatibility

  • Binary Deserialization: Efficiently reconstructs state from binary data

  • Null Safety: Gracefully handles cases where no previous state exists

Performance Optimization: The query is optimized using database indexes on userId for rapid retrieval. The operation is dispatched to the IO thread pool to maintain UI responsiveness during application initialization.

Compatibility Handling: The method includes version information in the returned state, allowing upstream components to handle migration scenarios when model architectures have evolved between application versions.

Return

The most recent learning state for the user, or null if no state exists

Parameters

userId

Unique identifier for the user whose state should be retrieved

See also

For the structure of returned state data