Skip to content

fix: 将 is_at/is_mentioned 标志位传入 Planner Prompt,修复 @消息 无法识别 - #1970

Open
Powdered-Delta wants to merge 2 commits into
Mai-with-u:devfrom
Powdered-Delta:fix/1969-planner-is-at-prompt
Open

Powdered-Delta wants to merge 2 commits into
Mai-with-u:devfrom
Powdered-Delta:fix/1969-planner-is-at-prompt

Conversation

@Powdered-Delta

@Powdered-Delta Powdered-Delta commented Aug 4, 2026

Copy link
Copy Markdown

在 build_planner_prefix 新增 is_at/is_mentioned 参数并写入 标签,同步更新 zh-CN prompt 模板的属性说明;en-US/ja-JP 等待 Crowdin 回流。

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

请填写以下内容

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

    • main 分支 禁止修改,请确认本次提交的分支 不是 main 分支
    • 我确认我阅读了贡献指南
    • 本次更新类型为:BUG修复
    • 本次更新类型为:功能新增
    • 本次更新是否经过测试
      (说明:AST 级逻辑验证通过,未跑完整 pytest 及部署测试)
    • 如果本次修改涉及 src/A_memorix,我确认已阅读 src/A_memorix/MODIFICATION_POLICY.md,不涉及则无需勾选
  1. 请填写破坏性更新的具体内容(如有):

  2. 请简要说明本次更新的内容和目的:

    适配器已正确检测 @ 消息(is_at=True),但该标志位未传入 LLM Prompt,
    导致 Planner 只能靠文本推理判断是否被 @,群名片/昵称与系统 bot 名称不一致时会误判"未被提及"从而不回复。

    本次在 build_planner_prefix 新增 is_at/is_mentioned 参数,写入 标签,
    并同步更新 zh-CN prompt 模板说明;en-US/ja-JP 由 Crowdin 回流,不在此 PR 中修改。

其他信息

Summary by CodeRabbit

  • 新功能
    • 聊天分析现可识别消息是否 @ 机器人或提及机器人。
    • 相关互动状态会被准确传递,帮助分析结果更完整地理解消息关系。
    • 更新消息格式说明,提升对 @ 和提及场景的识别准确性。

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cac51cd0-6c24-4402-adcc-882246d653a2

📥 Commits

Reviewing files that changed from the base of the PR and between 9638f85 and 7e5627f.

📒 Files selected for processing (4)
  • prompts/zh-CN/maisaka_chat.prompt
  • prompts/zh-CN/maisaka_chat_focus.prompt
  • pytests/maisaka/test_planner_messages.py
  • src/maisaka/context/planner_messages.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • prompts/zh-CN/maisaka_chat_focus.prompt
  • prompts/zh-CN/maisaka_chat.prompt
  • src/maisaka/context/planner_messages.py

Walkthrough

本次变更为 Planner 消息增加 is_atis_mentioned 属性。会话消息状态会透传到消息前缀。中文 Maisaka 提示模板补充对应属性说明,并新增组合测试。

Changes

Planner 消息元数据

Layer / File(s) Summary
提示消息属性说明
prompts/zh-CN/maisaka_chat.prompt, prompts/zh-CN/maisaka_chat_focus.prompt
两个提示模板说明 <message> 标签中的 is_atis_mentioned 属性。
Planner 前缀属性生成
src/maisaka/context/planner_messages.py
build_planner_prefix 新增两个可选布尔参数,并在状态为真时输出对应属性。相关参数文档同步更新。
会话消息状态透传与测试
src/maisaka/context/planner_messages.py, pytests/maisaka/test_planner_messages.py
包装函数从 SessionMessage 读取两个状态并传递给前缀构造函数。测试覆盖四种标记组合和透传行为。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了将 is_at 和 is_mentioned 传入 Planner Prompt 并修复 @ 消息识别的主要变更。
Description check ✅ Passed 描述覆盖变更目的、测试状态、分支确认、更新类型和关联 Issue,整体符合模板要求。
Linked Issues check ✅ Passed 代码实现新增并透传 is_at 和 is_mentioned 标志位,并更新 zh-CN Prompt 说明,符合 Issue #1969 的修复目标。
Out of Scope Changes check ✅ Passed 所有代码、测试和 zh-CN Prompt 修改均服务于 Issue #1969 的 @ 消息识别修复,未发现无关变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/maisaka/context/planner_messages.py (1)

148-149: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

为消息属性透传增加回归测试。

build_planner_prefix 按条件生成属性,build_planner_user_prefix_from_session_messageSessionMessage 透传两个字段。请覆盖仅 is_at 为真、仅 is_mentioned 为真、两个字段同时为真以及两个字段都为假的情况。测试还应确认会话消息字段不会被丢弃。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/maisaka/context/planner_messages.py` around lines 148 - 149, 为
build_planner_prefix 和 build_planner_user_prefix_from_session_message 增加回归测试,覆盖
is_at、is_mentioned 分别单独为真、同时为真及同时为假四种组合;同时验证从 SessionMessage 构建的结果保留并正确透传这两个字段。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@prompts/zh-CN/maisaka_chat.prompt`:
- Around line 17-20: 同步更新
prompts/en-US/maisaka_chat.prompt、prompts/ja-JP/maisaka_chat.prompt、prompts/en-US/maisaka_chat_focus.prompt
和 prompts/ja-JP/maisaka_chat_focus.prompt,在对应的 <message> 格式说明中补充 is_at="true" 与
is_mentioned="true" 属性及其含义;保持 prompts/zh-CN/maisaka_chat.prompt 和
prompts/zh-CN/maisaka_chat_focus.prompt 的现有说明不变,并确保三种语言模板内容对齐。

In `@src/maisaka/context/planner_messages.py`:
- Around line 76-79: Update the string literals appended in the is_at and
is_mentioned branches to use double quotes, escaping the embedded attribute
quotes as needed, consistent with the src/**/*.py Ruff string-formatting rule.

---

Nitpick comments:
In `@src/maisaka/context/planner_messages.py`:
- Around line 148-149: 为 build_planner_prefix 和
build_planner_user_prefix_from_session_message 增加回归测试,覆盖 is_at、is_mentioned
分别单独为真、同时为真及同时为假四种组合;同时验证从 SessionMessage 构建的结果保留并正确透传这两个字段。
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 52e318ad-da73-46e8-8db5-01ece740a76a

📥 Commits

Reviewing files that changed from the base of the PR and between dbcf807 and 57ec2ba.

📒 Files selected for processing (3)
  • prompts/zh-CN/maisaka_chat.prompt
  • prompts/zh-CN/maisaka_chat_focus.prompt
  • src/maisaka/context/planner_messages.py

Comment thread prompts/zh-CN/maisaka_chat.prompt
Comment thread src/maisaka/context/planner_messages.py Outdated
在 build_planner_prefix 新增 is_at/is_mentioned 参数并写入 <message> 标签,
同步更新 zh-CN prompt 模板的属性说明(en-US/ja-JP 将由 Crowdin 回流),
让 Planner 不再依赖文本推理判断是否被 @。

Closes Mai-with-u#1969
@Powdered-Delta
Powdered-Delta force-pushed the fix/1969-planner-is-at-prompt branch from 57ec2ba to 7e5627f Compare August 6, 2026 00:49
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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.

1 participant