惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
博客园 - Franky
V
V2EX
爱范儿
爱范儿
J
Java Code Geeks
小众软件
小众软件
Last Week in AI
Last Week in AI
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
酷 壳 – CoolShell
酷 壳 – CoolShell
The Register - Security
The Register - Security
GbyAI
GbyAI
Vercel News
Vercel News
Y
Y Combinator Blog
腾讯CDC
F
Fortinet All Blogs
I
InfoQ
N
Netflix TechBlog - Medium
B
Blog RSS Feed
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
Scott Helme
Scott Helme
T
Tor Project blog
U
Unit 42
Google Online Security Blog
Google Online Security Blog
PCI Perspectives
PCI Perspectives
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
NISL@THU
NISL@THU
D
Darknet – Hacking Tools, Hacker News & Cyber Security
aimingoo的专栏
aimingoo的专栏
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
Security Archives - TechRepublic
Security Archives - TechRepublic

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Cognee AI 记忆平台的 5 个隐藏用法:让 Agent 拥有跨会话的持久记忆
· 2026-06-18 · via DEV Community

韩

你知道吗?GitHub 上有一个 17,889 Stars 的开源项目,能让你的 AI Agent 拥有跨会话的持久记忆——不是简单的向量检索,而是一个会自动进化的知识图谱。但大多数开发者只用它来做基础的文档搜索,完全忽略了它真正的能力。

Cognee 是一个开源 AI 记忆平台,它把知识图谱、向量搜索和认知本体论生成统一到一个记忆层中。在 2026 年,AI Agent 正从单轮对话机器人向长时间运行的自主系统演进,而瓶颈不再是模型能力,而是上下文管理。以下是大多数人不知道的五个隐藏用法。

隐藏用法 #1:自动图谱同步的会话记忆

大多数人的做法:把对话历史存在简单的列表或向量数据库里,上下文长了就塞进 prompt。这在前几轮还行,但会话一长就迅速退化。

隐藏技巧:Cognee 的会话记忆充当快速缓存,会在后台自动同步到持久化知识图谱。你既能获得内存上下文的速度,又能拥有图数据库的持久性——而且同步过程完全不需要手动编排。

import cognee
import asyncio

async def agent_session():
    # 会话记忆——快速、临时、按会话隔离
    await cognee.remember(
        "用户询问了 Q3 收入趋势并请求导出 CSV。",
        session_id="support_ticket_4421"
    )

    # 后续查询会话记忆(快速路径)
    results = await cognee.recall(
        "用户问了什么收入相关的问题?",
        session_id="support_ticket_4421"
    )

    # 会话结束时,会话记忆自动同步到永久图谱
    # 无需手动导出,不会丢失任何数据

asyncio.run(agent_session())

效果:你的 Agent 在会话内部保持对话上下文以实现快速响应,但会话结束后不会丢失任何信息。知识图谱会自动跨所有会话积累洞察。

数据来源:Cognee GitHub 17,889 Stars,README 文档中 session_id 参数和自动同步行为在"Use with AI Agents"章节有详细说明。

隐藏用法 #2:面向领域推理的本体论 grounding

大多数人的做法:把文档灌入向量数据库,依赖语义相似性做检索。模糊匹配还行,但当你需要结构化的、领域感知的推理时就不行了。

隐藏技巧:Cognee 的 cognify 流水线不只是嵌入文档——它会从你的数据中生成认知本体论,创建带有类型化关系的结构化知识图谱。这意味着你的 Agent 可以对实体及其连接进行推理,而不仅仅是找到相似的文本。

import cognee
import asyncio

async def build_domain_memory():
    # 摄入领域文档
    await cognee.remember("""
        客户 Acme Corp 有 3 个活跃订阅。
        订阅 A:企业计划,到期日 2026-09-15。
        订阅 B:入门计划,已于 2026-03-01 到期。
        客户经理是 Sarah Chen。
        升级路径:Sarah -> 销售副总裁 -> CRO。
    """)

    # Cognee 自动提取实体和关系:
    # (Acme Corp) --拥有--> (订阅 A)
    # (订阅 A) --类型--> (企业计划)
    # (订阅 A) --到期--> (2026-09-15)
    # (Sarah Chen) --管理--> (Acme Corp)

    # 现在进行结构化精确查询
    results = await cognee.recall(
        "哪些客户在未来 90 天内订阅到期?"
    )
    # 返回 Acme Corp 及具体订阅和日期——
    # 而不仅仅是"关于订阅的相似文本"

asyncio.run(build_domain_memory())

效果:你的 Agent 不再依赖向量相似性碰运气,而是从理解实体类型、关系和时间约束的本体论中获得结构化答案。

数据来源:Cognee README "Product Features"章节描述了"ontology grounding"和"cognitive-science-grounded ontology generation";ArXiv 论文 2505.24478 关于优化知识图谱与 LLM 的接口。

隐藏用法 #3:通过共享图谱实现跨 Agent 知识共享

大多数人的做法:每个 Agent 维护自己独立的记忆。客服 Agent 无法受益于销售 Agent 昨天学到的东西。知识按设计被隔离。

隐藏技巧:Cognee 的知识图谱是一个共享基础设施层。多个基于不同框架构建的 Agent 可以从同一个图谱中读写。发现 Agent 的发现会立即对报告 Agent 可用——无需任何自定义集成代码。

import cognee
import asyncio

async def multi_agent_setup():
    # Agent 1:研究 Agent 发现市场洞察
    await cognee.remember(
        "竞争对手 X 推出了 9 美元/月的新定价层,"
        "目标客户是中小企业。发布日期:2026-06-10。",
        agent_id="research_agent"
    )

    # Agent 2:销售 Agent 自动获得这个洞察
    # 无需显式共享,无需 Agent 之间的 API 调用
    results = await cognee.recall(
        "我们有哪些关于定价的竞争情报?",
        agent_id="sales_agent"
    )
    # 返回研究 Agent 发现的竞争对手定价洞察

    # Agent 3:客服 Agent 也可以访问
    results = await cognee.recall(
        "最近有没有竞争对手的定价变化?",
        agent_id="support_agent"
    )
    # 相同的数据,零重复,零同步代码

asyncio.run(multi_agent_setup())

效果:你的 Agent 舰队构建了一个集体智能层。每个 Agent 都为共享知识库做贡献并从中受益,创造了一个随时间让所有 Agent 都更智能的复利知识效应。

数据来源:Cognee README "Why use Cognee"章节明确提到"cross-agent knowledge sharing"是核心功能;GitHub 1,897 Forks 表明活跃的多 Agent 实验正在进行。

隐藏用法 #4:多模态记忆摄入(PDF、图片、代码)

大多数人的做法:在把文档灌入记忆前剥离文本。图表、表格、代码片段和图片要么丢失,要么通过单独的脆弱流水线处理。

隐藏技巧:Cognee 的摄入流水线原生处理多模态数据。PDF、图片、代码文件和结构化数据都通过同一个 remember API 流动。系统从每种模态中提取实体和关系,并在同一个知识图谱中统一。

import cognee
import asyncio

async def multimodal_ingestion():
    # 摄入 PDF 报告
    await cognee.remember(
        document="path/to/quarterly_report.pdf",
        dataset="reports"
    )

    # 摄入代码仓库的架构文档
    await cognee.remember(
        document="path/to/api_documentation.md",
        dataset="reports"
    )

    # 摄入客户反馈 CSV
    await cognee.remember(
        document="path/to/feedback_data.csv",
        dataset="reports"
    )

    # 所有三种模态现在都可以通过同一个图谱查询
    results = await cognee.recall(
        "报告中提到的客户主要投诉是什么?"
    )
    # 交叉引用 PDF 文本和 CSV 反馈数据

asyncio.run(multimodal_ingestion())

效果:你的 Agent 的记忆不限于文本。它可以跨文档、代码和数据文件进行推理——构建对整个知识景观的统一理解,无需自定义解析逻辑。

数据来源:Cognee README "Product Features"列出了"unified ingestion"和"multimodal"作为核心能力;GitHub topics 包含"graph-database"、"vector-database"、"knowledge-graph"。

隐藏用法 #5:带生命周期钩子的 Claude Code 插件

大多数人的做法:把 Cognee 作为独立记忆服务使用,手动集成到 Agent 代码中。这意味着要编写自定义包装器、管理连接生命周期、处理边界情况。

隐藏技巧:Cognee 作为 Claude Code 插件直接挂入 IDE 的生命周期事件。SessionStart 初始化记忆,PostToolUse 捕获工具调用,UserPromptSubmit 注入相关上下文,PreCompact 在上下文重置时保留记忆,SessionEnd 将所有内容同步到永久图谱。零自定义集成代码。

# 安装 cognee
pip install cognee

# 配置 LLM 提供商
export LLM_API_KEY="your...n# 克隆插件
git clone https://github.com/topoteretes/cognee-integrations.git

# 在 Claude Code 中启用
claude --plugin-dir ./cognee-integrations/integrations/claude-code

# Claude Code 内部自动发生的事情:

# 1. SessionStart:从知识图谱加载相关上下文到对话前言

# 2. PostToolUse:每次工具调用(文件读取、bash 命令等)后,
#    将操作及其结果捕获到会话记忆中

# 3. UserPromptSubmit:在处理用户下一条消息前,
#    查询 Cognee 获取相关历史上下文并注入

# 4. PreCompact:当上下文窗口即将溢出时,
#    将关键洞察保留到永久图谱而不是丢失它们

# 5. SessionEnd:将所有会话记忆同步到知识图谱,
#    供未来会话访问

效果:Claude Code 获得了跨会话的持久记忆,无需编写任何集成代码。你读的每个文件、运行的每个命令、做的每个决策都会被自动捕获并在未来的会话中可用。

数据来源:Cognee README "Use with AI Agents"章节详细记录了全部 5 个生命周期钩子(SessionStart、PostToolUse、UserPromptSubmit、PreCompact、SessionEnd);GitHub 集成仓库位于 topoteretes/cognee-integrations。

总结

  1. 自动图谱同步的会话记忆——快速的临时上下文永远不会丢失
  2. 面向领域推理的本体论 grounding——超越向量相似性的结构化知识
  3. 通过共享图谱实现跨 Agent 知识共享——一个记忆层服务整个 Agent 舰队
  4. 多模态记忆摄入——PDF、代码和数据统一在一个图谱中
  5. 带生命周期钩子的 Claude Code 插件——零集成代码的 IDE 持久记忆

这五个技巧将 Cognee 从简单的记忆存储转变为 2026 年自主 Agent 所需的认知基础设施层。关键洞察:记忆不仅仅是存储过去——它是构建一个结构化的、不断进化的知识基础,让每个 Agent 随时间变得更智能。

如果你已经为自己的 AI Agent 构建了自定义记忆方案,我很想听听什么有效、什么无效。在评论中分享你的方法吧。


延伸阅读: