@@ -10,13 +10,12 @@ const farcaster = new Farcaster(agentFID, token);
1010
1111const openai = new OpenAI ( { apiKey : process . env . OPENAI_API_KEY } ) ;
1212
13- import { findUsers , indexUser , createMatch , updateMatchStatus , findUserByFid , findPendingMatch , findExpiredMatches } from './db.js' ;
13+ import { findUsers , indexUser , createMatch , updateMatchStatus , findUserByFid , findPendingMatch , findExpiredMatches , getUserState } from './db.js' ;
1414import { evaluatePossibleMatches , prepareDeclineMessage , prepareIntroMessage , prepareMatchSuccessMessage , prepareAlreadyConnectedMessage } from './find_matches.js' ;
1515
1616export const runAgent = async ( messages ) => {
1717
18- messages = messages . slice ( - 100 ) ;
19-
18+ //messages = messages.slice(-100);
2019
2120 // Response schema focused on actions
2221 const responseSchema = z . object ( {
@@ -53,8 +52,8 @@ export const runAgent = async (messages) => {
5352 let agentPromptText = agentPrompt . promptMessages [ 0 ] . prompt . template ;
5453
5554 const aiResponse = await openai . chat . completions . create ( {
56- model : "gpt-4o " ,
57- // reasoning_effort: "medium",
55+ model : "o3-mini " ,
56+ reasoning_effort : "medium" ,
5857 messages : [ { role : "system" , content : agentPromptText } , ...messages ] ,
5958 response_format : zodResponseFormat ( responseSchema , "response" ) ,
6059 stream : false ,
@@ -329,6 +328,16 @@ export const handleExpiredMatches = async () => {
329328}
330329
331330export const agentLogic = async ( { messages, conversationId, senderFid, name, username} ) => {
331+
332+ const matches = await getUserState ( senderFid ) ;
333+
334+ messages . unshift ( {
335+ role : `system` ,
336+ content : `Here are the matching states for the user. : ${ matches . map ( match =>
337+ Object . entries ( match ) . map ( ( [ key , value ] ) => `${ key } : ${ value } ` ) . join ( '\n' )
338+ ) . join ( '\n----\n' ) } `
339+ } ) ;
340+
332341 const response = await runAgent ( messages ) ;
333342
334343 console . log ( response , 'response' ) ;
0 commit comments