Handle emoji better

This commit is contained in:
Corey Johnson 2025-06-19 17:06:37 -07:00
parent 2292b3fa62
commit 38975981aa

View File

@ -91,14 +91,16 @@ const reactionAgent = new Agent({
const reactionGuardrail: InputGuardrail = {
name: "Reaction Guardrail",
execute: async ({ input, context }) => {
// const result = await run(reactionAgent, input.slice(-1), { context })
const emoji = " %F0%9F%91%8D " //result.finalOutput?.trim()
const result = await run(reactionAgent, input.slice(-1), { context })
const emoji = result.finalOutput?.trim()
if (emoji && emoji !== "0") {
console.log(`😐 Spike reacted with ${emoji}`)
const msg = (context.context as UserContext).msg
const history = (historyForChannel[msg.channel.id] ||= [])
history.push(system(`Spike reacted with ${emoji}`))
msg.react(emoji)
msg.react(emoji).catch((error) => {
console.error(`💥 Failed to react with ${emoji}:`, error)
})
}
// Always return false, we aren't really using this for a guardrail