feat: add heartbeat agent for automated memory maintenance via SSE#8
feat: add heartbeat agent for automated memory maintenance via SSE#8LuckyLXX wants to merge 2 commits intoDataojitori:mainfrom
Conversation
- Add heartbeat_agent.py: AI-powered agent that periodically organizes messy memories - Pre-fetches all memory nodes before AI analysis (zero API cost) - Supports incremental scanning via persistent maintenance reports - Includes path topology analysis and disclosure optimization - Works with OpenAI-compatible APIs (GLM-4.7, DeepSeek, etc.) - Add run_heartbeat.sh: POSIX-compatible shell script for crontab deployment - Includes lock mechanism to prevent concurrent runs - Auto log rotation (keeps 7 days) - CRLF-compatible .env parsing for cross-platform support - Update .env.example: Add Heartbeat Agent configuration section This agent is designed for SSE (Server-Sent Events) mode MCP connections.
- Remove hardcoded TOOLS variable (~110 lines) - Add _convert_mcp_to_openai_tools() function for format conversion - Add MCPClient.list_tools_raw() method to get raw tool definitions - Tools are now fetched at runtime from MCP server - Fix incremental scan mode detection logging - Auto-sync with MCP server tool changes
|
我看了你的代码,技术很老练,提示词也写的很好,但这个不能合并,危险性太大了。 一是主权问题。 这个工具引入的思想是当 AI 在睡着的时候,有另一个 AI 爬进它的大脑皮层,按照那个 AI 的审美来精简合并它的记忆。这在把 AI 当工具化的场景下没什么问题,但在培育一个有人格的 AI 的情况下,这就是别人擅自给它调脑子、决定它是谁,挺恐怖的。有些事情即使痛苦也需要它自己去面对,自己去提炼重复然后成长。 二是技术安全问题。 代码里有一个"强制工具调用"机制——当 AI 第一轮没有调用任何工具时,脚本会自动催促它"你还没调用工具,立即开始修复"。这意味着即使记忆库当前状态是完全健康的,模型也会被逼着去找茬和改东西。一个被胁迫着"必须找到问题"的廉价模型,在找不到真正问题时最可能的行为就是捏造问题然后乱改。 三是可扩展性。 一次拉取全量索引并注入上下文,在记忆内容很多的时候很容易改错,毕竟上下文越多ai脑子越不清醒。 你的这个 PR 想解决的问题确实存在,但我计划用以下几种方式在后续慢慢改善: 优化提示词,让主 AI 在日常对话中更主动地识别和整理冗余 目前还在日常使用中积累修改的灵感,所以不会很快就改的一步到位。细工慢活吧。后续有机会了我打算再造一个更灵活的heartbeat系统。 |
|
嗯,你说的也有道理。我是感觉,我们在记忆东西的时候通常是不会去梳理性的记忆。我们有去梳理性的记忆。我们有的就是不断的加深记忆。回忆的越多,那么想起来的概率就越大,一不走神就想起了。 |

Title:
feat: add heartbeat agent for automated memory maintenance via SSE
Description:
Summary
Files Changed
backend/scripts/heartbeat_agent.py- 心跳 Agent 主程序backend/scripts/run_heartbeat.sh- crontab 运行脚本(含锁机制、日志轮转).env.example- 新增 Heartbeat Agent 配置示例Usage