关于人工智能编码代理的记忆思考

2作者: hoangnnguyen8 天前原帖
我在日常工作中尝试使用AI编码助手,遇到了一个反复出现的问题:我不断重复相同的工程原则。<p>比如验证输入、谨慎处理新的依赖关系,或者遵循某些产品约束。通常的解决方案是提示或规则。<p>但在使用这两者一段时间后,我发现它们都不太合适。 - 提示在每个任务完成后就消失了。 - 规则仅在狭窄的上下文中触发,通常与特定文件或模式相关。 - 一些原则是个人偏好,而不是我希望在项目层面强制执行的内容。 - 还有一些根本不是“规则”,而是关于产品约束和过去权衡的知识。<p>这让我开始尝试为AI助手创建一个独立的“记忆”层。不是聊天记录,而是小而原子的知识片段:决策、约束和可以在相关时检索的重复原则。<p>一旦我认真使用它,有几件事变得显而易见: - 模糊的记忆导致模糊的行为 - 长期记忆会污染上下文 - 重复条目使检索变得更糟 - 许多问题只有在你每天依赖这个助手时才会显现出来<p>AI在上下文正确时执行得很好。但决定哪些内容应该被记住、哪些应该被拒绝,以及何时可预测性比聪明才智更重要,仍然需要人类的判断。<p>我很好奇其他人是如何处理这个问题的。在与AI编码助手合作时,你主要依赖提示、规则,还是某种形式的持久知识呢?
查看原文
I’ve been experimenting with AI coding agents in real day-to-day work and ran into a recurring problem, I keep repeating the same engineering principles over and over.<p>Things like validating input, being careful with new dependencies, or respecting certain product constraints. The usual solutions are prompts or rules.<p>After using both for a while, neither felt right. - Prompts disappear after each task. - Rules only trigger in narrow contexts, often tied to specific files or patterns. - Some principles are personal preferences, not something I want enforced at the project level. - Others aren’t really “rules” at all, but knowledge about product constraints and past tradeoffs.<p>That led me to experiment with a separate “memory” layer for AI agents. Not chat history, but small, atomic pieces of knowledge: decisions, constraints, and recurring principles that can be retrieved when relevant.<p>A few things became obvious once I started using it seriously: - vague memory leads to vague behavior - long memory pollutes context - duplicate entries make retrieval worse - many issues only show up when you actually depend on the agent daily<p>AI was great at executing once the context was right. But deciding what should be remembered, what should be rejected, and when predictability matters more than cleverness still required human judgment.<p>Curious how others are handling this. Are you relying mostly on prompts, rules, or some form of persistent knowledge when working with AI coding agents?