Repository navigation
Preset Crates
本页面是 MemoryCenter 特配 Crate 配置参考的 Wiki 源页面,仓库内
docs/preset-crates-inventory.md为镜像副本。
MemoryCenter 通过 5 个特配 crate 提供配置能力,覆盖 Agent、场景、技能、窗口、模型 5 个维度。这些维度最终由 memory-center-presets 组合层统一装配成 CombinedProfile,驱动归档、检索、评分等行为。
本文档列出 5 个特配 crate 的全部内置项、预设值与字段定义,供用户查阅与定制参考。
适用读者:
- 想了解 MemoryCenter 默认配置的使用者
- 想扩展或自定义特配的开发者
- 想为社区贡献新 Agent / 场景 / 型号的贡献者
文档版本:2026-07-15 v1(基于源码同步)
5 个维度的组合通过 memory-center-presets::PresetBuilder 完成:
use memory_center_presets::PresetBuilder;
use memory_center_agents::{AgentFamily, AgentProfile};
use memory_center_scenarios::{Scenario, ScenarioProfile};
use memory_center_models::ModelVariant;
let combined = PresetBuilder::new()
.with_agent(AgentProfile::from_family(AgentFamily::Trae))
.with_scenario(ScenarioProfile::from_scenario(Scenario::Coding))
.with_model(ModelVariant::claude_opus_4_8())
.build()?;也可通过以下方式以字符串参数构建:
-
MCP 工具:
preset_build(推荐 LLM 使用) -
HTTP 端点:
POST /api/v1/presets/build -
Python 绑定:
memory_center.presets.build_from_strings(...)
优先级链(高 → 低):
用户显式参数 > Scenario > Model > Window > Skill > Agent > 默认
联动规则:Agent 已设但 Window 未设时,自动从 Agent 推导 Window(如 ClaudeCode → 180K、Cursor → 150K、Trae → 120K、Codex → 100K)。
识别当前使用 MemoryCenter 的 Agent 工具(如 Claude Code / Cursor / Trae / Codex 等),提供 Agent 维度的默认配置。
源码:crates/memory-center-agents/
is_mainstream() 判定 4 主流;supports_real_hook 与 is_opensource 语义一致。
| 变体名 | display_name | 是否主流(4) | supports_real_hook | is_opensource | default_session_prefix |
|---|---|---|---|---|---|
| ClaudeCode | Claude Code | 是 | true | true | claude-code |
| Cursor | Cursor | 是 | false | false | cursor |
| Trae | Trae | 是 | false | false | trae |
| Codex | Codex | 是 | false | false | codex |
| Zcode | Zcode | 否 | false | false | zcode |
| OpenCode | OpenCode | 否 | true | true | opencode |
| Qoder | Qoder | 否 | false | false | qoder |
| WorkBuddy | WorkBuddy | 否 | false | false | workbuddy |
| CatPaw | CatPaw | 否 | false | false | catpaw |
| OpenClaw | OpenClaw | 否 | false | false | openclaw |
| Marvis | Marvis | 否 | false | false | marvis |
| Custom(String) | 用户传入字符串 | 否 | false | false | custom |
备注:
OpenCode虽不在 4 主流之列,但因开源属性归入 Real Hook 阵营。
4 主流通过 claude_code() / cursor() / trae() / codex() 构造;其他 family 走 generic() 路径(has_native_compression=false)。
| family | supports_tool_calls | has_native_compression | archive_to_memory_center | session_prefix | 注释里的压缩比与保留轮次 |
|---|---|---|---|---|---|
| ClaudeCode | true | true | true | claude-code | /compact 10:1 压缩 + 摘要 |
| Cursor | true | true | true | cursor | chat 5:1 压缩 + 摘要 |
| Trae | true | true | true | trae | conversation 5:1 压缩 + 摘要 |
| Codex | true | true | true | codex | rolling 3:1 压缩,无摘要 |
备注:
generic(family)预设supports_tool_calls=true、has_native_compression=false、archive_to_memory_center=true,session_prefix取family.default_session_prefix()。
3 层信号融合识别:MCP client_info → 父进程名 → 环境变量前缀。
| family | client_info_keywords | parent_process_keywords | env_var_prefixes |
|---|---|---|---|
| ClaudeCode | claude-code, claude_code, claudecode | claude, claude-code | CLAUDE_CODE_, CLAUDE_ |
| Cursor | cursor | cursor | CURSOR_ |
| Trae | trae | trae | TRAE_ |
| Codex | codex, openai-codex | codex | CODEX_ |
备注:其他 7 个 generic family 与 Custom 均返回
AgentFingerprint::generic(),三个字段均为空数组&[],is_empty()返回 true,不参与自动识别。
HookModeResolver::resolve(family) 根据 supports_real_hook() 决定模式。
| family | HookMode(Real/Pseudo) | 说明 |
|---|---|---|
| OpenCode | Real | 开源,sidecar 监听 compaction 消息自动归档 |
| ClaudeCode | Real | 开源 CLI,可适配 /compact 命令 |
| Cursor | Pseudo | 闭源,LLM 自感知 token 主动调 archive |
| Trae | Pseudo | 闭源,LLM 自感知 token 主动调 archive |
| Codex | Pseudo | 闭源,LLM 自感知 token 主动调 archive |
| Zcode / Qoder / WorkBuddy / CatPaw / OpenClaw / Marvis | Pseudo | 闭源,LLM 自感知 |
| Custom | Pseudo | 默认降级为伪钩子(HookMode::default() == Pseudo) |
备注:
HookMode::as_str返回"real"/"pseudo",from_str反向解析;HookModeResolver::family_from_session_id可从 session_id 前缀反解 family。
| 扩展方向 | 说明 |
|---|---|
| 7 个 generic 预设补专属 AgentProfile | Zcode/OpenCode/Qoder/WorkBuddy/CatPaw/OpenClaw/Marvis 当前走 generic(family),可补专属压缩比与保留轮次 |
| 7 个 generic family 补专属指纹 | 当前返回空指纹无法被 detect_agent_client 自动识别,需补 client_info / 父进程 / 环境变量前缀 |
| 7 个 generic family 补 HookMode 分类 | 当前全部走 Pseudo 默认,OpenCode 已支持 Real 但未体现 |
| AgentProfile 增加 variant 约束 | variant 当前为 Option<String>,可对 4 主流版本格式加枚举或正则约束 |
识别 Agent 工作场景,为不同场景提供针对化记忆工作流程配置。每个场景对应 5 维特配:摘要焦点、评分权重、标签优先级、检索策略、归档阈值。
源码:crates/memory-center-scenarios/
默认为 Daily。
| 变体名 | display_name | 是否内置 |
|---|---|---|
| Coding | 编码场景 | 是 |
| Writing | 写作场景 | 是 |
| Research | 科研场景 | 是 |
| Daily | 日常场景 | 是 |
| Finance | 金融场景 | 是 |
| Design | 设计场景 | 是 |
| OfficeWork | 工作场景 | 是 |
| AgentCollaboration | Agent协作场景 | 是 |
| KnowledgeBase | 知识库场景 | 是 |
| LongProject | 长项目场景 | 是 |
| Custom(String) | 用户传入字符串 | 否 |
10 个场景一对一映射,Custom 降级为 General。
| scenario | SummaryFocus 变体 | focus_dimensions(用逗号分隔) |
|---|---|---|
| Coding | Coding | 代码片段, 技术决策, bug 修复, 架构变更, 依赖变更 |
| Writing | Writing | 核心观点, 论据, 素材, 文章结构, 风格 |
| Research | Research | 假设, 研究方法, 实验数据, 结论, 引用文献 |
| Daily | Daily | 事件, 地点, 人物, 时间, 情感 |
| Finance | Finance | 交易明细, 金额, 时间, 风险, 收益, 标的 |
| Design | Design | 设计决策, 用户反馈, 迭代版本, 视觉要素, 交互流程 |
| OfficeWork | OfficeWork | 会议决议, 待办事项, 文档变更, 责任人, 截止日期 |
| AgentCollaboration | AgentCollaboration | Agent决策, 工具调用, 上下文迁移, 协作流程, 会话边界 |
| KnowledgeBase | KnowledgeBase | 知识主题, 定义, 分类, 引用, 标签 |
| LongProject | LongProject | 项目阶段, 里程碑, 决策, 风险, 待办 |
| Custom | General(降级) | 主题, 关键事实, 关键实体 |
4 维权重(recency / access_frequency / topic_relevance / user_marked)之和应为 1.0,validate() 容差 0.01。
| scenario | recency | access_frequency | topic_relevance | user_marked | 备注(设计原则) |
|---|---|---|---|---|---|
| Coding | 0.15 | 0.15 | 0.50 | 0.20 | 主题相关性最高(代码相关性) |
| Writing | 0.15 | 0.15 | 0.40 | 0.30 | 主题相关性 + 用户标记 |
| Research | 0.10 | 0.20 | 0.50 | 0.20 | 主题相关性最高(研究主题稳定) |
| Daily | 0.50 | 0.20 | 0.15 | 0.15 | 时效性最高(近期事件重要) |
| Finance | 0.20 | 0.15 | 0.35 | 0.30 | 主题相关性 + 用户标记(交易决策关键) |
| Design | 0.15 | 0.15 | 0.35 | 0.35 | 用户标记最高(设计迭代主观性强) |
| OfficeWork | 0.35 | 0.25 | 0.20 | 0.20 | 时效性 + 访问频率(近期待办重要) |
| AgentCollaboration | 0.15 | 0.40 | 0.30 | 0.15 | 访问频率最高(跨 Agent 频繁访问) |
| KnowledgeBase | 0.10 | 0.35 | 0.25 | 0.30 | 访问频率最高(常用知识重要) |
| LongProject | 0.35 | 0.15 | 0.20 | 0.30 | 时效性 + 用户标记(近期里程碑) |
| Custom | 0.25 | 0.25 | 0.25 | 0.25 | balanced 均衡权重(ScoreWeights::balanced()) |
从高到低用 > 连接,不在列表中的标签优先级分值为 0.0。
| scenario | 优先级标签序列(从高到低) |
|---|---|
| Coding | CodeBlock > ToolCall > Thinking > Plan > Url > FileAttachment |
| Writing | Text > Citation > Url > Plan > FileAttachment |
| Research | Citation > Url > Text > Plan > Thinking > FileAttachment |
| Daily | Text > Image > Voice > Url > Video |
| Finance | CodeBlock > Text > Url > Status > Citation |
| Design | Image > Text > FileAttachment > Ui > Video |
| OfficeWork | FileAttachment > Text > Plan > Status > Url > Citation |
| AgentCollaboration | ToolCall > Thinking > CodeBlock > Text > Plan |
| KnowledgeBase | Citation > Text > Url > CodeBlock > FileAttachment |
| LongProject | Plan > Status > FileAttachment > Text > CodeBlock |
| Custom | (空 Vec) |
备注:Custom 场景
priority_tags_for返回空 Vec,tag_priority_score直接返回 0.0,不优先任何标签。
Hybrid 权重之和应为 1.0。
| scenario | 策略类型 | bm25_weight | semantic_weight | requires_embedder |
|---|---|---|---|---|
| Coding | Hybrid | 0.45 | 0.55 | true |
| Writing | BM25Only | — | — | false |
| Research | Hybrid | 0.45 | 0.55 | true |
| Daily | BM25Only | — | — | false |
| Finance | Hybrid | 0.3 | 0.7 | true |
| Design | Hybrid | 0.3 | 0.7 | true |
| OfficeWork | Hybrid(default_hybrid) | 0.4 | 0.6 | true |
| AgentCollaboration | Hybrid | 0.3 | 0.7 | true |
| KnowledgeBase | Semantic | — | — | true |
| LongProject | Hybrid(default_hybrid) | 0.4 | 0.6 | true |
| Custom | Hybrid(default_hybrid) | 0.4 | 0.6 | true |
备注:
default_hybrid()常量返回 BM25 0.4 + 语义 0.6。未配置 Embedder 时,Semantic/Hybrid 由 search 层降级为 BM25Only。
范围 200K-500K token。
| scenario | 阈值(token 数) |
|---|---|
| Coding | 500,000 |
| Research | 500,000 |
| Writing | 400,000 |
| Design | 400,000 |
| Daily | 200,000 |
| Finance | 400,000 |
| OfficeWork | 400,000 |
| AgentCollaboration | 400,000 |
| KnowledgeBase | 500,000 |
| LongProject | 500,000 |
| Custom | 400,000 |
| 扩展方向 | 说明 |
|---|---|
| Custom 场景降级链 | SummaryFocus 降级 General、ScoreWeights 用 balanced、priority_tags 返回空、RetrievalStrategy 用 default_hybrid、archive_threshold 用 400K(设计本就如此,可按需覆盖) |
| 清理冗余依赖 |
Cargo.toml 声明 thiserror / tracing 但源码未实际使用 |
| 场景自动识别能力 | 当前由调用方决定场景,未来可补充基于对话内容的场景探测(已部分由 presets::HybridScenarioDetector 实现) |
识别 Agent 内置技能(Read / Write / Edit / Bash 等),提供技能输出的记忆链接策略。
源码:crates/memory-center-skills/
produces_artifact 仅 Write/Edit 为 true;is_destructive 含 Bash。
| 变体名 | display_name | category | produces_artifact | is_destructive | default_memory_link |
|---|---|---|---|---|---|
| Read | 读取文件 | FileOps | false | false | AttachedToTurn |
| Write | 写入文件 | FileOps | true | true | AttachedToTurn |
| Edit | 编辑文件 | FileOps | true | true | AttachedToTurn |
| Glob | 文件匹配 | FileOps | false | false | AttachedToTurn |
| Grep | 内容搜索 | FileOps | false | false | AttachedToTurn |
| LS | 列出目录 | FileOps | false | false | AttachedToTurn |
| Bash | 执行命令 | Execution | false | true | AttachedToTurn |
| Task | 子 Agent | Execution | false | false | AttachedToTurn |
| WebSearch | 网页搜索 | Web | false | false | AttachedToTurn |
| WebFetch | 抓取网页 | Web | false | false | AttachedToTurn |
| SearchCodebase | 语义搜索 | Search | false | false | AttachedToTurn |
| AskUserQuestion | 询问用户 | Interaction | false | false | AttachedToTurn |
| TodoWrite | 任务列表 | Planning | false | false | AttachedToTurn |
| Schedule | 定时任务 | Planning | false | false | SkipArchive |
| Skill | 执行技能 | Meta | false | false | AttachedToTurn |
| Custom(String) | 用户传入字符串 | Custom | false | false | AttachedToTurn |
备注:
default_memory_link_for(Schedule)返回 SkipArchive,其余 14 个内置技能 + Custom 均返回 AttachedToTurn。
| 变体名 | 包含的 BuiltinSkill |
|---|---|
| FileOps | Read, Write, Edit, Glob, Grep, LS |
| Execution | Bash, Task |
| Web | WebSearch, WebFetch |
| Search | SearchCodebase |
| Interaction | AskUserQuestion |
| Planning | TodoWrite, Schedule |
| Meta | Skill |
| Custom | Custom(String) |
MVP 仅 2 种变体。
| 变体名 | display_name | archives() | as_str | 说明 |
|---|---|---|---|---|
| AttachedToTurn | 附加到轮次 | true | "AttachedToTurn" | 技能输出附加到 MessageTurn.tool_calls,随轮次归档(默认) |
| SkipArchive | 不归档 | false | "SkipArchive" | 技能输出仅在当前会话窗口使用,不写入记忆文件 |
备注:
from_str同时接受 PascalCase 与 snake_case(如 "attached_to_turn")。Default为 AttachedToTurn。
| 字段名 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| skill | BuiltinSkill | 技能标识 |
BuiltinSkill::default() = Custom("unknown") |
| memory_link | MemoryLink | 记忆链接策略 | 由 default_memory_link_for(&skill) 推导 |
| enabled | bool | 是否启用(禁用的技能不调用) | true |
| note | Option | 用户自定义备注 | None |
备注:
SkillProfile::new(skill)自动按映射表设置 memory_link;validate()当前永远返回 Ok。
| 扩展方向 | 说明 |
|---|---|
| 完善 validate() 校验逻辑 | 注释标注"预留扩展点:未来可加 skill+link 兼容性校验",当前无任何校验逻辑 |
| MemoryLink v2 扩展 | 源码注释明确可扩展 StandaloneMemory(独立记忆,不绑定轮次)/ LinkedToProject(项目级记忆,跨 session 共享) |
| destructive 技能强制 AttachedToTurn | 在 validate() 中约束 Write/Edit/Bash 不可设为 SkipArchive |
| 清理冗余依赖 |
Cargo.toml 声明 thiserror / tracing 但源码未实际使用 |
适配不同 Agent 工具自身的上下文压缩机制(注意:"windows" 指记忆窗口,非操作系统)。
源码:crates/memory-center-windows/
Default 为 GenericSliding { keep_recent_turns: 5, summary_on_compress: true }。
| 变体名 | display_name | 压缩比 | keep_recent_turns | summary_on_compress | compresses | 默认触发阈值 |
|---|---|---|---|---|---|---|
| ClaudeCodeCompact | Claude Code /compact | 10.0 | 5 | true | true | 180,000 |
| CursorChat | Cursor Chat 压缩 | 5.0 | 3 | true | true | 150,000 |
| TraeConversation | Trae 对话压缩 | 5.0 | 4 | true | true | 120,000 |
| CodexRolling | Codex 滚动窗口 | 3.0 | 10 | false | true | 100,000 |
| GenericSliding | 通用滑动窗口 | 4.0 | 可配(默认 5) | 可配(默认 true) | true | 100,000 |
| NoCompression | 无压缩 | 1.0 | usize::MAX | false | false | usize::MAX |
备注:GenericSliding 的
keep_recent_turns/summary_on_compress为构造时传入字段,默认值 5/true;NoCompression 触发阈值设为usize::MAX表示永不触发。
MVP 仅 Independent 可用。
| 变体名 | display_name | is_supported | 说明 |
|---|---|---|---|
| Independent | 独立模式 | true | Agent 工具独立管理上下文,MemoryCenter 被动接收归档 |
| Cooperative | 协作模式(v2) | false | Agent 工具与 MemoryCenter 协同管理上下文,双向通信,未实现 |
所有预设均通过 from_scheme 构造,archive_to_memory_center 默认 true。
| 预设方法 | scheme | trigger_threshold | archive_to_memory_center | 说明 |
|---|---|---|---|---|
| claude_code() | ClaudeCodeCompact | 180,000 | true | Claude Code 200K 窗口的 90% |
| cursor() | CursorChat | 150,000 | true | Cursor 约 150K |
| trae() | TraeConversation | 120,000 | true | Trae 约 120K |
| codex() | CodexRolling | 100,000 | true | Codex 约 100K |
| no_compression() | NoCompression | usize::MAX | true | 由 MemoryCenter 归档阈值控制 |
| from_scheme(default) | GenericSliding(5, true) | 100,000 | true | 默认通用滑动窗口 |
备注:
WindowProfile::default()走from_scheme(CompressionScheme::default()),即 GenericSliding 默认配置。
| 字段名 | 类型 | 说明 |
|---|---|---|
| scheme | CompressionScheme | 压缩方式 |
| cooperation_mode | CooperationMode | 协作模式(MVP 仅 Independent) |
| trigger_threshold | usize | 触发压缩的阈值(token 数) |
| archive_to_memory_center | bool | 压缩时是否归档到 MemoryCenter |
备注:
validate()校验cooperation_mode.is_supported()与trigger_threshold != 0(NoCompression 除外)。
| 扩展方向 | 说明 |
|---|---|
| Cooperative 协作模式实现 | 主动通知 MemoryCenter 压缩事件 + MemoryCenter 建议保留记忆 + 双向通信触发压缩 |
| 清理冗余依赖 |
Cargo.toml 声明 memory-center-core / thiserror / tracing 但源码未实际使用 |
| 动态探测触发阈值 | 当前阈值静态硬编码,未来可根据 Agent 工具窗口大小动态调整 |
模型家族识别、型号参数描述、Tokenizer 抽象与实现;重依赖 tiktoken-rs 隔离于此 crate,不污染其他轻量 crate。
源码:crates/memory-center-models/
家族稳定,新型号只需新增 ModelVariant 构造器。
| 变体名 | display_name | default_tokenizer |
|---|---|---|
| Claude | Anthropic Claude | ClaudeApprox |
| Gpt | OpenAI GPT | O200kBase |
| Gemini | Google Gemini | CharacterBased |
| DeepSeek | DeepSeek | DeepSeekApprox |
| Qwen | 阿里 Qwen | CharacterBased |
| Llama | Meta Llama | CharacterBased |
| Grok | xAI Grok | O200kBase |
| Local | 本地模型 | CharacterBased |
| Custom | 自定义模型 | CharacterBased |
备注:Gemini/Qwen/Llama 因 sentencepiece 需额外依赖,先用 CharacterBased 兜底。
15 个构造器逐个提取,数据 100% 来自源码。
| 构造器名 | name | family | context_window | tokenizer | supports_thinking | supports_vision | supports_audio | tool_call_format | archive_strategy | summary_max_tokens |
|---|---|---|---|---|---|---|---|---|---|---|
| claude_opus_4_6 | claude-opus-4.6 | Claude | 1,000,000 | ClaudeApprox | true | true | false | Anthropic | LargeWindow(400,000) | 1024 |
| claude_opus_4_8 | claude-opus-4.8 | Claude | 200,000 | ClaudeApprox | true | true | false | Anthropic | Standard(80,000) | 1024 |
| claude_sonnet_5 | claude-sonnet-5 | Claude | 200,000 | ClaudeApprox | true | true | false | Anthropic | Standard(80,000) | 1024 |
| claude_fable_5 | claude-fable-5 | Claude | 200,000 | ClaudeApprox | true | true | false | Anthropic | Standard(80,000) | 1024 |
| claude_mythos_5 | claude-mythos-5 | Claude | 200,000 | ClaudeApprox | true | true | false | Anthropic | Standard(80,000) | 1024 |
| gpt_5_2 | gpt-5.2 | Gpt | 128,000 | O200kBase | false | true | false | OpenAI | Standard(60,000) | 1024 |
| gpt_5_codex | gpt-5-codex | Gpt | 128,000 | O200kBase | false | true | false | OpenAI | Standard(60,000) | 1024 |
| gemini_3_1_pro | gemini-3.1-pro | Gemini | 1,000,000 | CharacterBased | true | true | true | Gemini | LargeWindow(400,000) | 1024 |
| deepseek_v4_pro | deepseek-v4-pro | DeepSeek | 1,000,000 | DeepSeekApprox | true | false | false | OpenAI | LargeWindow(200,000) | 1024 |
| deepseek_v4_flash | deepseek-v4-flash | DeepSeek | 1,000,000 | DeepSeekApprox | false | false | false | OpenAI | LargeWindow(200,000) | 1024 |
| qwen_3_coder | qwen-3-coder | Qwen | 256,000 | CharacterBased | false | false | false | OpenAI | Standard(100,000) | 1024 |
| llama_4_scout | llama-4-scout | Llama | 1,000,000 | CharacterBased | false | true | false | OpenAI | LargeWindow(200,000) | 1024 |
| llama_4_maverick | llama-4-maverick | Llama | 1,000,000 | CharacterBased | false | true | false | OpenAI | LargeWindow(200,000) | 1024 |
| grok_4_1 | grok-4.1 | Grok | 128,000 | O200kBase | false | true | false | OpenAI | Standard(60,000) | 1024 |
| local_default | local-default | Local | 8,000 | CharacterBased | false | false | false | None | SmallWindow(4,000) | 512 |
备注:
claude_opus_4_6上下文 1M 为 Beta 版,正式版 200K。llama_4_scout理论支持 10M,保守取 1M(API 实际部署多为 1M)。local_default是唯一summary_max_tokens=512的型号,且tool_call_format=None。gemini_3_1_pro是唯一supports_audio=true的型号。ModelVariant::custom不在上表中,其archive_strategy按context_window动态推导:≥200K → LargeWindow(ctx/5),≥32K → Standard(ctx/4),否则 SmallWindow(ctx/4)。
hard_limit = threshold × 1.5。
| 变体名 | threshold 示例 | hard_limit(1.5x) | 说明 |
|---|---|---|---|
| LargeWindow | 400,000 | 600,000 | 长窗口模型(≥200K),阈值高,单次归档多内容 |
| Standard | 80,000 | 120,000 | 标准窗口(32K-128K),标准归档 |
| SmallWindow | 4,000 | 6,000 | 小窗口(≤16K),频繁归档,摘要更精炼 |
| 变体名 | 说明 |
|---|---|
| OpenAI | OpenAI function calling 格式(JSON),GPT/DeepSeek/Qwen/Llama/Grok 等使用 |
| Anthropic | Anthropic tool_use content block 格式,Claude 系列使用 |
| Gemini | Gemini function call 格式,Gemini 系列使用 |
| Xml | XML 标签格式,部分开源模型使用 |
| None | 无工具调用能力,local_default 使用 |
序列化时只存类型名称。
| 变体名 | type_name | 说明 | 系数 |
|---|---|---|---|
| O200kBase | "o200k_base" | GPT-4o/5 系列分词器 | 1.0 |
| Cl100kBase | "cl100k_base" | GPT-4/3.5 系列分词器(向后兼容) | 1.0 |
| ClaudeApprox | "claude_approx" | Claude 近似(cl100k + 系数 1.05) | 1.05 |
| DeepSeekApprox | "deepseek_approx" | DeepSeek 近似(cl100k + 系数 1.1) | 1.1 |
| CharacterBased | "character_based" | 字符级兜底(无依赖) | — |
| Custom(Arc) | "custom" | 用户注入实现,不可序列化(反序列化回退 CharacterBased) | — |
备注:
build()在 tiktoken-rs 初始化失败时降级为 CharTokenizer;from_type_name("custom")也回退为 CharacterBased。
default_variant(family) 返回家族最新主流型号。
| family | default_variant 名称 |
|---|---|
| Claude | claude-opus-4.8 |
| Gpt | gpt-5.2 |
| Gemini | gemini-3.1-pro |
| DeepSeek | deepseek-v4-pro |
| Qwen | qwen-3-coder |
| Llama | llama-4-scout |
| Grok | grok-4.1 |
| Local | local-default |
| Custom | custom(custom("custom", Custom, 32_000)) |
备注:Claude 默认选 Opus 4.8 而非 Fable 5/Mythos 5,原因:Fable 5 曾因出口管制暂停,Mythos 5 面向特定合作方,Opus 4.8 为 API 普遍可用的稳定旗舰。
无依赖兜底实现。
| 字符类型 | 系数 | 说明 |
|---|---|---|
| CJK(中文/日文/韩文) | 1.5 | BPE 通常将 1 个 CJK 字符拆为 1-2 token |
| 拉丁文(英文/拉丁字母数字) | 1.3 | 按空格分词,1 词 ≈ 1.3 token |
| 标点/数字/其他非空白 | 0.5 | 1 字符 ≈ 0.5 token |
备注:CJK 判定覆盖 U+4E00-U+9FFF、CJK 扩展 A (U+3400-U+4DBF)、日文平假名 (U+3040-U+309F)、日文片假名 (U+30A0-U+30FF)、韩文谚文音节 (U+AC00-U+D7AF)。空白字符不计 token。
CharTokenizer::with_coefficients支持自定义系数。
| 扩展方向 | 说明 |
|---|---|
| Tokenizer 接入 archive-core 主链路 | 当前归档链路用 chars/3 简化估算,未来可用 ModelVariant::count_tokens 替换以提升归档阈值触发精度 |
| 集成 sentencepiece | 为 Gemini/Qwen/Llama 提供精确 tokenizer,替换 CharacterBased 兜底 |
| Custom Tokenizer 序列化保留 | 当前 TokenizerKind::Custom 序列化为 "custom",反序列化回退为 CharacterBased,丢失原始实现 |
| 启用 Cl100kBase | 当前仅作为 ClaudeApprox/DeepSeekApprox 的基础,无独立型号引用 |
5 个特配 crate 均依赖 memory-center-core;models 额外引入 tiktoken-rs 重依赖。被依赖次数基于 Cargo.toml 实际引用统计。
| crate | 依赖 core | 依赖其他特配 | 被哪些 crate 依赖 |
|---|---|---|---|
| memory-center-agents | 是 | 无 | adapter, archive-core, mcp, presets, sidecar, server, python(7 个) |
| memory-center-scenarios | 是 | 无 | mcp, presets, server, python(4 个) |
| memory-center-skills | 是 | 无 | presets, server, python(3 个) |
| memory-center-windows | 是 | 无 | presets, server, python(3 个) |
| memory-center-models | 是 | 无(tiktoken-rs 为外部依赖) | mcp, presets, server, python(4 个) |
备注:所有特配 crate 均仅依赖
memory-center-core,相互之间无直接依赖(通过 presets 层组合)。models 是唯一引入重依赖(tiktoken-rs 0.6)的特配 crate。
汇总前 5 个章节的扩展方向,便于贡献者按优先级规划工作。
| crate | 扩展方向 | 说明 | 建议优先级 |
|---|---|---|---|
| agents | 7 个 generic family 补专属指纹 | 当前返回空指纹无法被 detect_agent_client 自动识别 |
高(影响 MCP 启动自动识别) |
| agents | OpenCode 补专属 AgentProfile | generic 预设未体现其开源 / 可适配 sidecar 的特性 | 高 |
| models | Tokenizer 接入 archive-core 主链路 | 实际用 chars/3 简化估算 | 高(影响归档阈值精度) |
| agents | 7 个 generic 预设补专属 AgentProfile | 走 generic 路径,has_native_compression 统一为 false | 中(按使用频率逐步补) |
| agents | 7 个 generic family 补 HookMode 分类 | 全部走 Pseudo 默认,OpenCode 已支持 Real 但未体现 | 中 |
| skills | 完善 validate() 校验逻辑 | 无 skill+link 兼容性校验 | 中 |
| skills | MemoryLink v2 扩展 | 新增 StandaloneMemory / LinkedToProject | 中 |
| windows | Cooperative 协作模式实现 | validate 会拒绝 Cooperative | 中(v2 路线) |
| models | 集成 sentencepiece | 为 Gemini/Qwen/Llama 提供精确 tokenizer | 中 |
| scenarios | 场景自动识别能力 | 当前由调用方决定场景 | 低(已部分由 HybridScenarioDetector 实现) |
| scenarios | 清理冗余依赖 | thiserror / tracing 声明但未使用 | 低 |
| windows | 清理冗余依赖 | memory-center-core / thiserror / tracing 声明但未使用 | 低 |
| models | Custom Tokenizer 序列化保留 | 反序列化回退为 CharacterBased | 低 |
| crate | 扩展点 | 说明 |
|---|---|---|
| skills | MemoryLink v2 扩展 | 新增 StandaloneMemory(独立记忆,不绑定轮次)/ LinkedToProject(项目级记忆,跨 session 共享) |
| windows | Cooperative 模式实现 | 主动通知 MemoryCenter 压缩事件 + MemoryCenter 建议保留记忆 + 双向通信触发压缩 |
| models | Tokenizer 接入主链路 | 用 ModelVariant::count_tokens 替换 chars/3 估算,提升归档阈值触发精度 |
| agents | 7 个 generic 预设补专属配置 | 为 OpenCode/Qoder 等开源或可适配 Agent 补 AgentProfile + Fingerprint + HookMode |
| agents | AgentProfile 增加 variant 约束 | 对 4 主流的版本格式做枚举或正则约束 |
| scenarios | 场景自动识别 | 当前由调用方决定场景,可补充基于对话内容的场景探测能力 |
| models | sentencepiece 集成 | 为 Gemini/Qwen/Llama 提供精确 tokenizer,替换 CharacterBased 兜底 |
| skills | destructive 技能强制 AttachedToTurn | 在 validate() 中约束 Write/Edit/Bash 不可设为 SkipArchive |
如需新增 Agent family、场景、技能、压缩方式或模型型号,请按以下步骤贡献:
-
修改对应 crate 的枚举定义:在
BuiltinSkill/Scenario/AgentFamily/CompressionScheme/ModelFamily中新增变体 -
添加预设构造器:如
AgentProfile::xxx()/ModelVariant::xxx()/WindowProfile::xxx() -
更新映射表:如
from_scenario()/default_memory_link_for()/default_archive_threshold()等场景映射 - 更新本文档对应表格:保持文档与源码同步
-
提交 PR:标题使用
feat(preset-xxx): 新增 YYY格式(如feat(preset-agents): 新增 Windsurf family)
详细贡献流程参见 CONTRIBUTING.md。
- Crate 选择指南 — 各 Crate 的整体定位与选择决策
- Architecture — 整体架构设计
-
MCP Integration — MCP 工具列表(含
preset_build/preset_list_*) -
API Reference — REST API 文档(含
POST /api/v1/presets/build)
本文档由源码同步,如配置变更请同步更新。最后更新:2026-07-15。