Skip to content

[codex] 修复角色评论回复归属#81

Merged
utopiafar merged 1 commit into
memex-lab:mainfrom
utopiafar:codex/issue-78-comment-reply-routing
May 15, 2026
Merged

[codex] 修复角色评论回复归属#81
utopiafar merged 1 commit into
memex-lab:mainfrom
utopiafar:codex/issue-78-comment-reply-routing

Conversation

@utopiafar
Copy link
Copy Markdown
Collaborator

@utopiafar utopiafar commented May 14, 2026

背景

修复 #78。用户回复某个角色评论后,后续角色自动回复有概率显示成“角色回复自己”。

关联:Fixes #78

根因

用户评论会正确保存 reply_to_id,但 process_ai_reply 任务没有把“本次用户评论 id”固定传给 SaveComment 工具。评论 agent 只能从已有评论上下文里看到用户是在回复某个角色评论,因此模型可能把 AI 回复的 reply_to_id 也填成那条原始角色评论 id,最终 UI 展示成同一个角色指向自己。

改动

  • 为评论保存工具增加系统固定回复目标 forcedReplyToId
  • 在处理用户评论触发的 AI 回复时,将 AI 回复强制挂到本次用户评论 id 上。
  • 在 agent 任务消息里补充回复路由说明,降低模型误选旧评论 id 的概率。
  • 保留没有固定目标时的原行为,角色之间仍然可以显式互相回复。
  • 新增 CommentToolFactory 单元测试,覆盖固定回复目标、空目标归一化、保留角色间回复目标等场景。

验证

  • flutter pub get --offline
  • dart format --set-exit-if-changed lib/agent/skills/comment_agent/tools/comment_tools.dart lib/agent/skills/character_tools_factory.dart lib/agent/skills/comment_agent/comment_agent_skill.dart lib/agent/comment_agent/comment_agent.dart lib/data/repositories/post_comment.dart test/agent/comment_tool_factory_test.dart
  • flutter test --no-pub test/agent/comment_tool_factory_test.dart
  • flutter analyze --no-pub lib/agent/skills/comment_agent/tools/comment_tools.dart lib/agent/skills/character_tools_factory.dart lib/agent/skills/comment_agent/comment_agent_skill.dart lib/agent/comment_agent/comment_agent.dart lib/data/repositories/post_comment.dart test/agent/comment_tool_factory_test.dart
  • git diff --check upstream/main...HEAD

@utopiafar utopiafar marked this pull request as ready for review May 15, 2026 06:28
@utopiafar utopiafar merged commit 5aacd0c into memex-lab:main May 15, 2026
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.

[Bug]角色可能回复给自己

1 participant