Over the past six months, while building an AI SaaS product, I’ve gradually iterated on an AI Agent framework suited for SaaS products. However, the memory system has always been the weak spot. Recently, driven by product needs, I specifically revamped the framework to enhance its memory capabilities.
Here’s a summary.
Separating Fixed Memory from Dynamic Memory
Originally, all memory was stored together. When the AI agent needed to update its memory, it would simply modify the content directly.
But this introduced some unpredictability — certain content was never meant to be changed, yet the agent could alter it anyway.
So in this iteration, I split memory into two independent parts.
One is fixed memory: as long as the user doesn’t proactively modify it, it stays unchanged.
The other is dynamic memory: fully controlled by the Agent, which can add, reduce, or modify content as needed.
This constrains the Agent’s authority, preventing accidental modifications to fixed memory that could impact the entire system.
Why Forgetting Matters More Than Remembering
How do you maintain consistency and continuity in generated content?
I used to focus on dynamic context optimization. Despite various improvements, issues would still emerge after enough rounds of content generation.
That’s why dynamic memory became essential. The combination of fixed memory + dynamic memory + dynamically retrieved context ensures continuity and consistency for the next generation.
And when it comes to dynamic memory — especially when the generated content demands high consistency and continuity — how to forget becomes more important than how to remember.
Take a novel-writing agent as an example.
If you’re writing a story spanning hundreds of chapters, adding the key points of each chapter to dynamic memory as you go can greatly improve continuity for the next chapter. But as more chapters are generated, dynamic memory grows larger and larger — not only does it exceed what can reasonably be sent to the AI as context, it also wastes tokens. More importantly, many earlier chapters in dynamic memory are no longer useful as context; in fact, they pollute the context and degrade the quality of generated content.
So figuring out how to “forget” these useless memories becomes a problem worth thinking about.
独立产品人日记
Notes on indie products, AI tools, growth, and engineering.