This video was great inspiration. I've worked with a few of the ideas in here and further refined them.
The idea of adding prompting the AI to output both "message" and "memory" as JSON is really good.
The issue we face is that by default the agents memory only captures what it says to the user in its message.
However there may be many other things it needs to remember such as pubkeys, eventIds, etc.
The e.g. being:
User – Get my latest mention
AI – Here it is, Y says "Z"
User – Zap that note
AI – Sorry I don't have the Id of the note
Without extra memory the last instruction will fail because the AI won't have remembered the eventId, even though it previously had it, as, since it wasn't expressly said by the AI to the user the AI did not commit it to memory.
Instead we prompt the AI to output both a "message" for the user, and also a "memory" for itself. We only pass the message to the user, and we ask the AI to use the memory field extensively for anything it thinks it may need to recall later.
A few refinements vs that video–
- no need to use the extra memory write node, the AI node alone works better, and,
- no need to be prescriptive with the memory format, allowing the AI to specify whatever it thinks it needs works great, and is less prone to JSON parsing errors.