最新资讯
www.infoq.com Edera 推出 Object Capability Bounded Authority,试图将凭证与 AI Agent 工作负载隔离 wechat 这波杀疯了!旗舰级模型不限量、1个月视频额度免费领 dev.to 如何在专用 GPU 服务器上用 OpenAI 兼容 API 部署 LLM dev.to 审计 153 份 Claude Code 与 Codex 会话记录:User-Agent 与 URL 中的邮箱泄露 dev.to 你的 Agent Harness 应具备的 17 项能力 dev.to 离线 AI 记忆中 0.8 余弦阈值为何失效 dev.to Kimi K3.1 Pro 开放权重:自托管 2.8T 模型前的开发者清单 dev.to 如何通过工具调用引导模型以提升 Harness 质量 dev.to AI Agent 审计轨迹不等于对话记录 dev.to 精简 MCP server 工具数量:更少工具、更小影响面,双重收益 dev.to 为什么 git checkout 无法撤销 AI 编码 agent 的改动? wechat AI短剧门槛降降降!实测即梦短剧工作室:剧本分镜预演一条龙,伙伴计划长期护航
多元动态
登录 注册
智能体 dev.to · @Andrea Redegalli

为什么仅靠向量相似度不足以支撑 coding agent 的记忆

原文 我的收藏

文章指出,coding agent 记忆的难点不在于检索语义相近的文档片段,而在于判断过去的结论是否足够安全可复用。向量搜索擅长找语义近邻,但排序列表不等于决策:最相似的结果可能来自不同框架版本、描述已废弃方案、依赖未言明的部署约束,或已被后续架构决策取代。作者建议将记忆系统拆分为不同确定性层级的操作:verified recall 仅在多信号支持时返回候选,并输出 STRONG/WEAK/MISS 门控;混合检索结合语义相似度与词法信号(配置键、异常类型、表名、包版本、命令参数),用 reciprocal-rank fusion 融合独立排序;图探索则回答“还有什么与之相关”,保留关系与多样性而非压平为单一相似度分数。相应地,存储对象应从“文档”转为“learnings”。

AI推荐理由 文章提出 coding agent 记忆系统的具体设计观点:向量相似度只能找到语义近邻,不能判断过往结论是否可安全复用;建议区分 verified recall(STRONG/WEAK/MISS 门控)、混合检索(dense + BM25 + reciprocal-rank fusion)与图探索,并把记忆写成 learnings 而非文档。属于开发者视角的架构讨论,有明确论点与用例(Docker healthcheck、框架版本、被取代的架构决策),但为个人博客观点,无实验数据或基准验证,也未给出实现细节。

72

正文

A coding agent fixes a tricky deployment failure. Two weeks later, another session sees the same failure described in different words. The expensive part is not finding a nearby document chunk. It is deciding whether a past conclusion is safe enough to reuse. That distinction is why I think agent memory needs more than vector similarity. Similar is not the same as reusable Vector search is excellent at finding semantic neighbours. Ask for help with a Docker healthcheck and it may find memories about container startup, service discovery, or a previous networking issue. Those can be useful leads. But a ranked list is not a decision. The top result may be merely adjacent: it may apply to a different framework version; describe an abandoned approach; be true only under an unstated deployment constraint; or have been superseded by a later architectural decision. For a human, these are normal caveats. For an agent working under time and context pressure, treating the nearest neighbour as an answer can turn retrieval into a subtle source of confident mistakes. The question is not only “what is semantically close?” It is also “have we seen this problem closely enough before to make that prior learning part of the current reasoning?” Separate recall from exploration A useful memory system can expose different operations for different levels of certainty. Verified recall is the narrowest path. It returns one candidate only when multiple signals support the match; otherwise it says that the match is weak or absent. The important output is not just a snippet, but a gate: STRONG, WEAK, or MISS. A STRONG result is still evidence, not an instruction. The agent should inspect the returned context and decide whether it fits. A WEAK result should encourage investigation rather than shortcut it. A MISS tells the agent to solve the problem normally instead of inventing continuity. Hybrid retrieval is broader. Semantic similarity is valuable, but it should be combined with lexical signals. Exact terms often carry disproportionate meaning in engineering work: a configuration key, exception type, table name, package version, or command flag. Dense retrieval captures paraphrase; BM25 preserves those precise anchors. Reciprocal-rank fusion is a practical way to blend independent rankings without pretending either is universally correct. Graph exploration answers a third question: what else is connected to this? A deployment failure may touch a prior decision about ingress, a known local-development exception, and a later supersession. Those relationships are often more useful than another ten chunks with similar embeddings. Exploration should favour diversity and keep the relationship visible, rather than flattening everything into one similarity score. Write memories as learnings, not documents This changes what we store. A codebase index asks: “What documents might answer this query?” Agent memory asks: “What did the agent learn that would be expensive to rediscover?” Good memory entries are compact and explicit: the root cause and fix; the architectural choice and why it was made; a framework or infrastructure gotcha; a constraint that rules out an appealing approach; or a failed experiment worth not repeating. Lifecycle matters too. If a decision changes, deleting the old memory loses context; leaving it untreated risks a stale answer. A better model marks the old learning as superseded and links it to the newer one. History remains inspectable while retrieval can favour what is current. Retrieval quality is a product decision There is no universal threshold at which a match becomes safe. A recall system has to decide its false-positive and false-negative trade-off. For an agent that proposes code changes, false positives are costly: a plausible but stale memory can send work down the wrong path. For an agent doing background research, a false negative may be less harmful: it can simply search more broadly. Confidence should therefore be exposed as part of the contract rather than hidden inside a score. A practical evaluation loop should include failures, not just happy-path hits: paraphrases of the same historical problem; near misses involving a different version, environment, or dependency; contradictions and superseded decisions; exact-identifier queries that vectors may dilute; and small noisy stores where every result appears relevant. The goal is not a leaderboard score. It is to learn when the system should stay silent. A local-first implementation I am building these ideas into Graft, an Apache-2.0 local memory layer for coding agents. Its core is a C11 daemon backed by SQLite, FTS5, sqlite-vec, llama.cpp, and local BGE-M3 embeddings. It does not require a SaaS account, external embedding API, or external LLM call for its storage and retrieval loop. Graft keeps the three paths separate: confidence-gated query, hybrid retrieve using vector search plus BM25 title/body search with reciprocal-rank fusion, and explore for semantic and keyword relationships. It is an active alpha, and the cross-encoder reranker is scaffolded rather than active today; verification currently uses vector similarity plus lexical signals. If you are building long-running coding-agent workflows, I would value feedback on the hard part: what evidence would make you willing—or unwilling—to reuse a prior agent learning?

来源报道 · 1 篇 · 以下链接均前往原始媒体

← 返回精选动态 原文

更多内容