Skip to content

chore: add diagnostic logging for history dedup pipeline - #140

Merged
lishuceo merged 1 commit into
mainfrom
diag/history-dedup-logging
Mar 11, 2026
Merged

chore: add diagnostic logging for history dedup pipeline#140
lishuceo merged 1 commit into
mainfrom
diag/history-dedup-logging

Conversation

@lishuceo

Copy link
Copy Markdown
Owner

Summary

  • fetchRecentMessages 中添加诊断日志:API 返回条数、类型过滤跳过原因(deleted / unsupported_type / parse_error / empty_content)、最终解析的消息 ID 和类型列表
  • buildDirectTaskHistory 中添加诊断日志:afterMsgId 值、currentMessageId 过滤前后计数、dedup 过滤前后计数、最终消息 ID 列表
  • executeDirectTask 中添加诊断日志:afterMsgId 来源(conversationId + _historyDedup 状态)、history 结果概要

目的

追踪 pm-bot 在群聊中无法看到紧挨着的 merge_forward 消息的根因。当前日志只有 promptLength 无法定位消息在哪个环节被丢弃。

日志级别

全部使用 logger.debug,不影响正常日志输出。需要时通过 LOG_LEVEL=debug 或在 .env 中临时启用。

Test plan

  • 合并部署后,在群聊中转发一条聊天记录,然后引用回复 @土豆儿
  • 检查 debug 日志,确认 merge_forward 在哪个环节被过滤

🤖 Generated with Claude Code

在 fetchRecentMessages 和 buildDirectTaskHistory 中添加详细的诊断日志,
用于追踪 merge_forward 消息在历史上下文注入过程中被过滤的确切原因。

记录的关键数据点:
- fetchRecentMessages: API 返回条数、类型过滤、解析失败、空内容跳过
- buildDirectTaskHistory: afterMsgId 值、各阶段消息计数、最终消息列表
- executeDirectTask: afterMsgId 来源和 history 结果概要

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude

claude Bot commented Mar 11, 2026

Copy link
Copy Markdown

Claude finished @lishuceo's task in 54s —— View job


PR #140 Review: Diagnostic logging for history dedup pipeline

  • Check for previous review comments — none found
  • Read changed files in full context
  • Review diff for issues
  • Post review summary

✅ Approved

Clean diagnostic logging PR. All changes are logger.debug, no runtime behavior changes, no sensitive data leakage (only IDs, types, and content lengths — not actual message content).

Minor observation (confidence ~60, not filing inline):
The foundIdx field at event-handler.ts:1858 is named like an index but emits 'found'/'not_found' strings. The inference logic (messages.length !== beforeDedupFilter) works correctly in all cases, but renaming to something like afterMsgIdMatch would be slightly clearer. Not blocking.

Summary: Well-scoped diagnostic change that should help trace the merge_forward filtering issue. No bugs, no security concerns, no architectural issues.

@lishuceo
lishuceo merged commit a7a5c7b into main Mar 11, 2026
4 checks passed
@lishuceo
lishuceo deleted the diag/history-dedup-logging branch March 11, 2026 13:21
lishuceo added a commit that referenced this pull request Apr 8, 2026
在 fetchRecentMessages 和 buildDirectTaskHistory 中添加详细的诊断日志,
用于追踪 merge_forward 消息在历史上下文注入过程中被过滤的确切原因。

记录的关键数据点:
- fetchRecentMessages: API 返回条数、类型过滤、解析失败、空内容跳过
- buildDirectTaskHistory: afterMsgId 值、各阶段消息计数、最终消息列表
- executeDirectTask: afterMsgId 来源和 history 结果概要

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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