@@ -136,15 +136,9 @@ export const handleFindMatches = async ({senderFid, name, messages, response, no
136136
137137 await createMatch ( senderFid . toString ( ) , matchedUser . fid . toString ( ) ) ;
138138
139- const foundNew = {
140- candidate_name : matchedUser . name ,
141- candidate_username : matchedUser . username ,
142- candidate_profile : matchedUser . profile ,
143- candidate_intent : matchedUser . intent ,
144- result : 'found_new'
145- }
146-
147- await sendToolMessage ( { fid : senderFid , messages, content : `Found a new match: ${ JSON . stringify ( foundNew ) } ` } ) ;
139+ const currentUser = await findUserByFid ( senderFid ) ;
140+ const introMessage = await prepareIntroMessage ( currentUser , matchedUser ) ;
141+ await farcaster . sendDirectMessage ( senderFid , introMessage ) ;
148142
149143}
150144
@@ -316,12 +310,14 @@ export const agentLogic = async ({messages, conversationId, senderFid, name, use
316310 try {
317311 const matches = await getUserState ( senderFid ) ;
318312
319- messages . unshift ( {
320- role : `system` ,
321- content : `Here are the matching states for the user: ${ matches . map ( match =>
322- Object . entries ( match ) . map ( ( [ key , value ] ) => `${ key } : ${ value } ` ) . join ( '\n' )
323- ) . join ( '\n----\n' ) } `
324- } ) ;
313+ if ( matches . length > 0 ) {
314+ messages . unshift ( {
315+ role : `system` ,
316+ content : `Here are the pending match state for the user: ${ matches . map ( match =>
317+ Object . entries ( match ) . map ( ( [ key , value ] ) => `${ key } : ${ value } ` ) . join ( '\n' )
318+ ) . join ( '\n----\n' ) } `
319+ } ) ;
320+ }
325321 } catch ( error ) {
326322 console . error ( 'Error getting user state:' , error ) ;
327323
0 commit comments