Skip to content

fix: 默认关闭 A_Memorix 运行时#1623

Merged
A-Dawn merged 1 commit into
Mai-with-u:devfrom
A-Dawn:feature/a-memorix-disabled-by-default
May 3, 2026
Merged

fix: 默认关闭 A_Memorix 运行时#1623
A-Dawn merged 1 commit into
Mai-with-u:devfrom
A-Dawn:feature/a-memorix-disabled-by-default

Conversation

@A-Dawn
Copy link
Copy Markdown
Collaborator

@A-Dawn A-Dawn commented May 3, 2026

  • ✅ 接受:与main直接相关的Bug修复:提交到dev分支
  • 新增功能类pr需要经过issue提前讨论,否则不会被合并
  • 🌐 i18n 提醒:除 bootstrap 或紧急修复外,请不要把非 zh-CN 目标翻译作为常规 GitHub 编辑面;常规翻译以 Crowdin -> l10n_* PR 回流为准,详见 docs/i18n.md

请填写以下内容

(删除掉中括号内的空格,并替换为小写的x

    • main 分支 禁止修改,请确认本次提交的分支 不是 main 分支
    • 我确认我阅读了贡献指南
    • 本次更新类型为:BUG修复
    • 本次更新类型为:功能新增
    • 本次更新是否经过测试
    • 如果本次修改涉及 src/A_memorix,我确认已阅读 src/A_memorix/MODIFICATION_POLICY.md,不涉及则无需勾选
  1. 请填写破坏性更新的具体内容(如有):默认关闭记忆系统
  2. 请简要说明本次更新的内容和目的:

其他信息

  • 关联 Issue:Close #
  • 截图/GIF
  • 附加信息:

Summary by CodeRabbit

  • 配置变更

    • A_Memorix 插件默认设置已更改为禁用状态
  • 改进

    • 优化了插件禁用时的处理流程,当插件处于禁用状态时系统将跳过内核初始化,提高应用效率

Copilot AI review requested due to automatic review settings May 3, 2026 09:52
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1d17ced0-f253-45da-9762-13c67c38562e

📥 Commits

Reviewing files that changed from the base of the PR and between fe03b77 and 9090b72.

📒 Files selected for processing (2)
  • src/A_memorix/config_schema.json
  • src/A_memorix/host_service.py

概览

通过修改配置架构和宿主服务,实现了 A_Memorix 的禁用功能。配置默认值变更为禁用状态,服务层添加了启用状态检查逻辑,防止禁用时的初始化和内核操作。

变更

A_Memorix 启用/禁用功能

层级 / 文件 摘要
配置默认值
src/A_memorix/config_schema.json
plugin.enabled 字段默认值从 true 变更为 false
启用状态检测
src/A_memorix/host_service.py
添加 is_enabled() 方法和 _is_enabled_config() 静态方法,用于检查配置中的启用状态。
禁用响应负载
src/A_memorix/host_service.py
添加 _disabled_response() 静态方法,为 search_memoryingest_summaryingest_textget_person_profilememory_stats 等组件生成结构化的禁用响应。
生命周期管理
src/A_memorix/host_service.py
修改 start()reload() 在禁用时跳过内核初始化;修改 _ensure_kernel() 在禁用时抛出 RuntimeError
请求处理
src/A_memorix/host_service.py
修改 invoke() 方法在禁用时立即返回禁用响应,避免继续执行内核加载。

序列图

sequenceDiagram
    actor Client
    participant Service as AMemorixHostService
    participant Config as Config
    participant Kernel as Kernel

    Client->>Service: invoke(component)
    activate Service
    Service->>Service: is_enabled()
    Service->>Config: 检查 plugin.enabled
    Config-->>Service: false (禁用)
    Service->>Service: _disabled_response(component)
    Service-->>Client: {"status": "disabled", ...}
    deactivate Service
Loading

预估代码审查工作量

🎯 3 (中等复杂度) | ⏱️ ~25 分钟

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@A-Dawn A-Dawn merged commit 226868f into Mai-with-u:dev May 3, 2026
3 of 5 checks passed
@github-project-automation github-project-automation Bot moved this to 已完成 in MaiM to the GATE May 3, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 旨在让 A_Memorix 长期记忆运行时在默认情况下保持关闭,并在配置未启用时避免初始化与调用内核,从而降低首次使用/未配置 embedding 时的启动与运行成本。

Changes:

  • 在运行时启动、重载与调用入口处增加“未启用则跳过/短路返回”的逻辑
  • 新增统一的 is_enabled() / _is_enabled_config() 开关判定与禁用态响应
  • config_schema.jsonplugin.enabled 默认值改为 false,并补充 UI 提示

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/A_memorix/host_service.py 增加启用开关判断、禁用态短路与返回结构,避免在未启用时初始化 kernel
src/A_memorix/config_schema.json 将 A_Memorix 启用开关默认值改为关闭,并更新提示文案

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +105 to +106
return True
return bool(plugin_config.get("enabled", True))
Comment on lines +370 to +380
if component_name == "memory_stats":
return {
"success": True,
"enabled": False,
"disabled": True,
"reason": reason,
"message": message,
"paragraph_count": 0,
"relation_count": 0,
"episode_count": 0,
}
"disabled": True,
"reason": reason,
"stored_ids": [],
"skipped_ids": [reason],
Comment on lines 50 to +69
@@ -57,9 +60,13 @@ async def stop(self) -> None:
async def reload(self) -> None:
async with self._lock:
await self._shutdown_locked()
self._config_cache = self._read_config()
self._config_cache = None
config = self._read_config()

await self._ensure_kernel()
if self._is_enabled_config(config):
await self._ensure_kernel()
else:
logger.info("A_Memorix 配置为未启用,运行时保持关闭")
@coderabbitai coderabbitai Bot mentioned this pull request May 3, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants