@@ -779,13 +779,37 @@ export class AgentRuntime implements IAgentRuntime {
779
779
console . log ( "composing state, the user id is : " , userId )
780
780
console . log ( "composing state, the room id is : " , roomId )
781
781
const conversationLength = this . getConversationLength ( ) ;
782
-
782
+ console . log ( "1" )
783
783
const [ actorsData , recentMessagesData , goalsData ] : [
784
784
Actor [ ] ,
785
785
Memory [ ] ,
786
786
Goal [ ] ,
787
787
] = await Promise . all ( [
788
- getActorDetails ( { runtime : this , roomId } ) ,
788
+ getActorDetails ( { runtime : this , roomId } ) . then ( actors => {
789
+ console . log ( "Actor details retrieved:" , {
790
+ roomId,
791
+ actorCount : actors . length ,
792
+ actors : actors . map ( a => ( { id : a . id , username : a . username } ) )
793
+ } ) ;
794
+ if ( ! actors || actors . length === 0 ) {
795
+ // This should never happen as we should at least have the message author
796
+ console . error ( "No actors found for room:" , roomId ) ;
797
+ console . error ( "Message details:" , {
798
+ messageId : message . id ,
799
+ userId : message . userId ,
800
+ roomId : message . roomId
801
+ } ) ;
802
+
803
+ // Emergency fallback: Create an actor from the message
804
+ return [ {
805
+ id : message . userId ,
806
+ name : "Unknown User" ,
807
+ username : "unknown" ,
808
+ details : { tagline : "" , summary : "" , quote : "" }
809
+ } ] ;
810
+ }
811
+ return actors ;
812
+ } ) ,
789
813
this . messageManager . getMemories ( {
790
814
roomId,
791
815
count : conversationLength ,
@@ -798,9 +822,9 @@ export class AgentRuntime implements IAgentRuntime {
798
822
roomId,
799
823
} ) ,
800
824
] ) ;
801
-
825
+ console . log ( "2" )
802
826
const goals = formatGoalsAsString ( { goals : goalsData } ) ;
803
-
827
+ console . log ( "3" )
804
828
const actors = formatActors ( { actors : actorsData ?? [ ] } ) ;
805
829
806
830
const recentMessages = formatMessages ( {
@@ -945,12 +969,13 @@ Text: ${attachment.text}
945
969
: [ ] ;
946
970
947
971
// Get formatted conversation if conversationId is provided
972
+ console . log ( "4" )
948
973
let recentUserConversations = "" ;
949
974
if ( additionalKeys . conversationId ) {
950
975
const currentConversationId = additionalKeys . conversationId as UUID ;
951
976
recentUserConversations = await this . databaseAdapter . getFormattedConversation ( currentConversationId ) ;
952
977
}
953
-
978
+ console . log ( "5" )
954
979
const getRecentMessageInteractions = async (
955
980
recentInteractionsData : Memory [ ]
956
981
) : Promise < string > => {
@@ -971,13 +996,13 @@ Text: ${attachment.text}
971
996
return `${ sender } : ${ message . content . text } ` ;
972
997
} )
973
998
) ;
974
-
999
+ console . log ( "6" )
975
1000
return formattedInteractions . join ( "\n" ) ;
976
1001
} ;
977
1002
978
1003
const formattedMessageInteractions =
979
1004
await getRecentMessageInteractions ( recentInteractions ) ;
980
-
1005
+ console . log ( "7" )
981
1006
const getRecentPostInteractions = async (
982
1007
recentInteractionsData : Memory [ ] ,
983
1008
actors : Actor [ ]
@@ -995,29 +1020,40 @@ Text: ${attachment.text}
995
1020
recentInteractions ,
996
1021
actorsData
997
1022
) ;
998
-
1023
+ console . log ( "8" )
999
1024
// Retrieve user rapport if message is from a user
1000
- const userRapportScore = await this . databaseAdapter . getUserRapport ( actorsData [ 0 ] . id , this . agentId ) || 0 ;
1001
- const userRapportTier = getRapportTier ( userRapportScore ) ;
1025
+ console . log ( "actorsData:" , actorsData ) ;
1026
+ let userRapportScore = 0 ;
1027
+ let userRapportTier = getRapportTier ( 0 ) ; // Default to neutral
1028
+
1029
+ if ( actorsData && actorsData . length > 0 && actorsData [ 0 ] ?. id ) {
1030
+ userRapportScore = await this . databaseAdapter . getUserRapport ( actorsData [ 0 ] . id , this . agentId ) || 0 ;
1031
+ userRapportTier = getRapportTier ( userRapportScore ) ;
1032
+ console . log ( "Found user rapport for:" , actorsData [ 0 ] . id , "Score:" , userRapportScore ) ;
1033
+ } else {
1034
+ console . log ( "No valid actor data found for rapport calculation" ) ;
1035
+ }
1036
+
1037
+ console . log ( "userRapportScore:" , userRapportScore ) ;
1038
+ console . log ( "UserRapportTier:" , userRapportTier ) ;
1002
1039
1003
1040
const getUserRapportDescription = ( tier : RapportTier ) : string => {
1004
- if ( tier == RapportTier . NEUTRAL ) {
1041
+ if ( tier === RapportTier . NEUTRAL ) {
1005
1042
return '' ;
1006
1043
}
1007
1044
else {
1008
1045
return tier ;
1009
1046
}
1010
1047
} ;
1011
1048
1012
-
1013
- const userRapportDescription = getUserRapportDescription ( userRapportTier ) ;
1049
+ const userRapportDescription = getUserRapportDescription ( userRapportTier ) ;
1014
1050
console . log ( "Building rapport context for user:" , {
1015
1051
userId : message . userId ,
1016
1052
score : userRapportScore ,
1017
1053
tier : userRapportTier ,
1018
1054
description : userRapportDescription ,
1019
1055
} ) ;
1020
-
1056
+ console . log ( "11" )
1021
1057
// if bio is a string, use it. if its an array, pick one at random
1022
1058
let bio = this . character . bio || "" ;
1023
1059
if ( Array . isArray ( bio ) ) {
@@ -1036,9 +1072,9 @@ Text: ${attachment.text}
1036
1072
. join ( " " ) ;
1037
1073
}
1038
1074
const knowledegeData = await knowledge . get ( this , message ) ;
1039
-
1075
+ console . log ( "12" )
1040
1076
const formattedKnowledge = formatKnowledge ( knowledegeData ) ;
1041
-
1077
+ console . log ( "13" )
1042
1078
const initialState = {
1043
1079
agentId : this . agentId ,
1044
1080
agentName,
@@ -1187,15 +1223,15 @@ Text: ${attachment.text}
1187
1223
...additionalKeys ,
1188
1224
1189
1225
} as State ;
1190
-
1226
+ console . log ( "14" )
1191
1227
const actionPromises = this . actions . map ( async ( action : Action ) => {
1192
1228
const result = await action . validate ( this , message , initialState ) ;
1193
1229
if ( result ) {
1194
1230
return action ;
1195
1231
}
1196
1232
return null ;
1197
1233
} ) ;
1198
-
1234
+ console . log ( "15" )
1199
1235
const evaluatorPromises = this . evaluators . map ( async ( evaluator ) => {
1200
1236
const result = await evaluator . validate (
1201
1237
this ,
@@ -1207,7 +1243,7 @@ Text: ${attachment.text}
1207
1243
}
1208
1244
return null ;
1209
1245
} ) ;
1210
-
1246
+ console . log ( "16" )
1211
1247
const [ resolvedEvaluators , resolvedActions , providers ] =
1212
1248
await Promise . all ( [
1213
1249
Promise . all ( evaluatorPromises ) ,
@@ -1255,7 +1291,7 @@ Text: ${attachment.text}
1255
1291
providers
1256
1292
) ,
1257
1293
} ;
1258
-
1294
+ console . log ( "17" )
1259
1295
return { ...initialState , ...actionState } as State ;
1260
1296
}
1261
1297
0 commit comments