arXiv:2606.06337cs.AI2026-06

用知识图谱管理长对话记忆,让大模型记住决策过程和文件变更。

TokenMizer: Graph-Structured Session Memory for Long-Horizon LLM Context Management

论文配图:TokenMizer: Graph-Structured Session Memory for Long-Horizon LLM Context Management
图 1 · 摘自论文原文
  • 将对话历史建模为带类型的知识图谱,保留决策与理由的结构化信息。
  • 任务召回率85.0%、文件召回率100%,优于传统摘要基线。
  • 支持断点续传,适合需要长期状态跟踪的智能体系统使用。

长时序大模型会话超出上下文窗口限制,现有方法如截断、摘要、检索均将历史视为扁平文本,丢失了会话可恢复的关键信息——决策及其依据、任务状态、文件修改记录。本文提出 TokenMizer,一个开源透明代理,将会话历史以类型化知识图谱形式维护,并在上下文边界处用令牌预算化的状态序列替代原始文本。图谱包含14种节点类型和7种边类型,支持8种生命周期状态,允许决策被覆盖或显式作废;双时间有效性区间支持时间旅行查询;首类决策转移记录保留每项决策替换前因后果(触发条件、理由、证据)。版本0.3.1在生产级服务层集成内存核心——支持SSE流式传输、安全中间件、九种提供者适配器、监控仪表盘及图谱导出(D3 JSON、自包含交互式HTML、Obsidian Canvas),并通过模型上下文协议工具暴露断点续传能力。评估极为简洁且完全可追溯:三个合成会话,纯启发式提取,仅一个普通摘要基线,所有数据可追踪至单一版本结果文件。图谱提取在任务召回上持平基线(75.6%),决策召回(85.0% vs. 70.0%)与文件召回(100% vs. 91.7%)全面领先,每次会话的恢复块大小为201-302令牌,提取耗时8.1-529.9毫秒。n=3时结果具方向性;天花板效应与基线弱点已明确分析。代码、基准测试器与精确结果文件均以MIT许可发布。

原文摘要 · Abstract (English)

Long-horizon LLM sessions outlive their context windows, and the standard mitigations - truncation, summarization, retrieval - share a structural flaw: they treat history as flat text, discarding precisely the content that makes a session resumable: decisions and their rationales, task status, and file modification history. We present TokenMizer, an open-source transparent proxy that maintains session history as a typed knowledge graph and, at context boundaries, replaces the raw transcript with a token-budgeted serialization of session state. The schema comprises 14 node types and 7 edge types under an 8-state lifecycle in which decisions can be superseded or explicitly invalidated; bitemporal validity intervals support time-travel queries; and first-class decision-transition records preserve why each decision replaced its predecessor (trigger, reason, evidence). Version 0.3.1 embeds this memory core in a production-shaped serving layer - SSE streaming, security middleware, nine provider adapters, a monitoring dashboard, graph exports (D3 JSON, self-contained interactive HTML, Obsidian Canvas) - and exposes checkpoint/resume to agents as Model Context Protocol tools. The evaluation is deliberately minimal and fully provenanced: three synthetic sessions, heuristic-only extraction, one plain-summary baseline, every value traceable to a single versioned results file. Graph extraction ties the baseline on task recall (75.6%) and exceeds it on decision recall (85.0% vs. 70.0%) and file recall (100% vs. 91.7%), with 201-302-token resume blocks extracted in 8.1-529.9 ms per session. At n=3 these results are directional; ceiling effects and baseline weaknesses are analyzed explicitly. Code, benchmark runner, and the exact results file are released under the MIT licence.

知识图谱长对话智能体

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。