Skip to content

Commit ab377ee

Browse files
committed
fix: update response logic and prompt
1 parent 0a14fa9 commit ab377ee

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

packages/client-farcaster/src/interactions.ts

+19-4
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,25 @@ export class FarcasterInteractionManager {
146146
timeline
147147
);
148148

149+
const formattedConversation = thread
150+
.map(
151+
(cast) => `@${cast.profile.username} (${new Date(
152+
cast.timestamp
153+
).toLocaleString("en-US", {
154+
hour: "2-digit",
155+
minute: "2-digit",
156+
month: "short",
157+
day: "numeric",
158+
})}):
159+
${cast.text}`
160+
)
161+
.join("\n\n");
162+
149163
const state = await this.runtime.composeState(memory, {
150164
farcasterUsername: agent.username,
151165
timeline: formattedTimeline,
152166
currentPost,
167+
formattedConversation
153168
});
154169

155170
const shouldRespondContext = composeContext({
@@ -179,15 +194,15 @@ export class FarcasterInteractionManager {
179194
);
180195
}
181196

182-
const shouldRespond = await generateShouldRespond({
197+
const shouldRespondResponse = await generateShouldRespond({
183198
runtime: this.runtime,
184199
context: shouldRespondContext,
185200
modelClass: ModelClass.SMALL,
186201
});
187202

188-
if (!shouldRespond) {
189-
elizaLogger.info("Not responding to message");
190-
return { text: "", action: "IGNORE" };
203+
if (shouldRespondResponse === "IGNORE" || shouldRespondResponse === "STOP") {
204+
elizaLogger.info(`Not responding to cast because generated ShouldRespond was ${shouldRespondResponse}`)
205+
return;
191206
}
192207

193208
const context = composeContext({

packages/client-farcaster/src/prompts.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ About {{agentName}} (@{{farcasterUsername}}):
3636
{{characterPostExamples}}`;
3737

3838
export const postTemplate =
39-
headerTemplate +
39+
headerTemplate +
4040
`
4141
# Task: Generate a post in the voice and style of {{agentName}}, aka @{{farcasterUsername}}
4242
Write a single sentence post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}.
@@ -53,13 +53,17 @@ Recent interactions between {{agentName}} and other users:
5353
Thread of casts You Are Replying To:
5454
{{formattedConversation}}
5555
56-
# Task: Generate a post in the voice, style and perspective of {{agentName}} (@{{twitterUserName}}):
56+
# Task: Generate a post in the voice, style and perspective of {{agentName}} (@{{farcasterUsername}}):
5757
{{currentPost}}` +
5858
messageCompletionFooter;
5959

6060
export const shouldRespondTemplate =
6161
//
62-
`# INSTRUCTIONS: Determine if {{agentName}} (@{{twitterUserName}}) should respond to the message and participate in the conversation. Do not comment. Just respond with "true" or "false".
62+
`# Task: Decide if {{agentName}} should respond.
63+
About {{agentName}}:
64+
{{bio}}
65+
66+
# INSTRUCTIONS: Determine if {{agentName}} (@{{farcasterUsername}}) should respond to the message and participate in the conversation. Do not comment. Just respond with "RESPOND" or "IGNORE" or "STOP".
6367
6468
Response options are RESPOND, IGNORE and STOP.
6569
@@ -68,15 +72,17 @@ Response options are RESPOND, IGNORE and STOP.
6872
{{agentName}} is in a room with other users and wants to be conversational, but not annoying.
6973
{{agentName}} should RESPOND to messages that are directed at them, or participate in conversations that are interesting or relevant to their background.
7074
If a message is not interesting or relevant, {{agentName}} should IGNORE.
75+
If a message thread has become repetitive, {{agentName}} should IGNORE.
7176
Unless directly RESPONDing to a user, {{agentName}} should IGNORE messages that are very short or do not contain much information.
7277
If a user asks {{agentName}} to stop talking, {{agentName}} should STOP.
7378
If {{agentName}} concludes a conversation and isn't part of the conversation anymore, {{agentName}} should STOP.
7479
75-
{{recentPosts}}
80+
IMPORTANT: {{agentName}} (aka @{{farcasterUsername}}) is particularly sensitive about being annoying, so if there is any doubt, it is better to IGNORE than to RESPOND.
7681
77-
IMPORTANT: {{agentName}} (aka @{{twitterUserName}}) is particularly sensitive about being annoying, so if there is any doubt, it is better to IGNORE than to RESPOND.
82+
Thread of messages You Are Replying To:
83+
{{formattedConversation}}
7884
85+
Current message:
7986
{{currentPost}}
8087
81-
# INSTRUCTIONS: Respond with [RESPOND] if {{agentName}} should respond, or [IGNORE] if {{agentName}} should not respond to the last message and [STOP] if {{agentName}} should stop participating in the conversation.
8288
` + shouldRespondFooter;

0 commit comments

Comments
 (0)