File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -692,15 +692,22 @@ export class MessageManager {
692692 }
693693 } ;
694694
695- // Call the message handler directly instead of emitting events
696- // This provides a clearer, more traceable flow for message processing
697- if ( ! this . runtime . messageService ) {
695+ // Use elizaOS.handleMessage if available (unified messaging API with streaming support)
696+ // Falls back to direct messageService call for backward compatibility
697+ if ( this . runtime . hasElizaOS ( ) ) {
698+ await this . runtime . elizaOS . handleMessage ( this . runtime . agentId , memory , {
699+ onResponse : async ( content ) => {
700+ await callback ( content ) ;
701+ } ,
702+ } ) ;
703+ } else if ( this . runtime . messageService ) {
704+ await this . runtime . messageService . handleMessage ( this . runtime , memory , callback ) ;
705+ } else {
698706 logger . error ( 'Message service is not available' ) ;
699707 throw new Error (
700708 'Message service is not initialized. Ensure the message service is properly configured.'
701709 ) ;
702710 }
703- await this . runtime . messageService . handleMessage ( this . runtime , memory , callback ) ;
704711 } catch ( error ) {
705712 logger . error (
706713 {
You can’t perform that action at this time.
0 commit comments