Repository navigation
Keep IM replies when an IM message event is redelivered - #1908
Merged
Merged
Conversation
Keep a bounded process-local record of admitted IM RPC IDs so repeated events cannot withdraw an active origin or reclaim a later turn. Preserve unknown-request and mixed-turn isolation, and warn once when mixed-origin output is withheld.
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Fei2411
commented
Nov 20, 2026
Fei2411
left a comment
Owner
Author
There was a problem hiding this comment.
Code Reaper review (comments only): ready for the maintainer. No blocking issues.
Does what it says
- On
dev, a seconduser/messagewith an already-usedim:rpcId hitsrequests.get() === undefined → dropOrigin(), setsmixed, and the rest of the turn's replies are silently dropped. The newconsumedRequestscheck returns before classification, so a duplicate no longer claims, drops or consumespendingReset. A truly unknown rpcId (after a restart) still fails closed. - No false collisions: every IM rpcId is
im:<platform>:<randomUUID>(rememberRequest, the card-answer path), so the 200-entry set cannot match a different message. - The warning fires only when an origin really was withdrawn or a claim was refused in this turn (
withheldOriginsis set fromdropOriginonly when an origin existed, and from a refusedclaimOrigin), and it is cleared byresetOriginat turn start/end. A plain Web turn after an IM turn does not warn, becauseturn/startresets the origin first. No message text or ids are logged.
Verified on 73a98202
npm test: 3480 pass, 0 fail, 4 skipped (Windows-only).test/im.test.js: 78/78.npm run lintexits 0 (warnings only).build-client --checkOK.- PR body has
Agent: Devin (Cognition)andFixes #1904. I did not rerun the bench smoke test.
Non-blocking notes
- The code comment says consumed ids are ignored "including redelivery after their turn ended". In that case
turn/starthas already reset the origin and clearedwithheldOrigins, so that new turn's replies are withheld without the new warning. Not sending a second answer to IM for a duplicate is reasonable, but the log gap is exactly the case #1904 wants to see. Consider warning (or a debug line) when a consumed rpcId is ignored, so the next production trace shows whether a redelivery happened. - The fix is defensive: nothing in DS Bot re-sends an IM rpcId (
retryTurnbuilds a fresh source;carryOriginSourcein parts.js stripsrpcId), so the duplicate would have to come from DSH. The PR body says this honestly; keep #1904 open until the warning confirms the cause, or close it on merge with that caveat.
Overlap with #1750
- Both add an early
returnas the first line of theuser/messagebranch insession/event, so they conflict textually (one hunk). Resolution is to keep both lines; they are independent becauseisAttachedContextSource()excludes any source with anrpcId. I resolved it that way locally and re-rantest/im.test.js(1908 + 1750 combined: 90/90 pass). - Suggested order: land #1750 first (older, already re-reviewed, wider impact on every IM turn with a context snapshot), then bring this branch up to date with
scripts/merge-dev.sh. - Other open PRs touching
im/index.js(#1817, #1302, #1201) already conflict withdev; no new overlap from this PR.
8 of 9 tasks
Owner
Author
|
Review: approved Independent first-principles review passed:
|
8 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #1904
Refs #1869, #1886 (these wait on a maintainer decision, see below)
What changed / 改了什么
Bug: when the same IM
user/messageevent (sameim:rpcId) arrived a second time,requestshad already dropped that rpcId. The classifier then tookasked === undefined → dropOrigin(), which setmixedand silently stopped the whole turn's replies from going to IM.ds-bot/src/host/im/index.js: keep the last 200 rpcIds this process has already used. A repeated event for one of them is ignored: it does not claim, drop, or touchpendingReset. A truly unknown rpcId (e.g. after a restart) still fails closed, as before.ds-bot: IM reply withheld: turn origin was dropped or mixedonce per turn (no message text or ids), for both chats and groups. Before this, that path had no log at all.REPLY_KIND(desktop card answers, [Bug] 同一轮里先在桌面端答了 ask_user 卡片,微信消息的答复被静默丢弃(0.3.8) #1869) and mixed-turn rules ([Bug] IM 端只收到 Agent 的第一条回复,同一回合后续多条消息全部丢失 #1886) are not changed.docs/plans/2026-11-04-im.md("什么发回聊天软件") decides that a mixed turn stops sending to IM and that a web or phone card answer does not keep the IM origin. Changing that needs the maintainer; it will be added to this PR if approved.Overlap with #1750: same classifier in
session/event, just before these branches. #1750 skips attached-context sources and explicitly excludesREPLY_KINDand rpcId sources, so it does not cover this path. The two changes don't conflict in meaning, but because they edit nearby lines, the second to merge may needscripts/merge-dev.sh.Changelog
Replies to an IM message are no longer lost when the platform delivers the same message twice.
How I checked it / 怎么验证的
npm test(inds-bot/): 3480 pass, 0 fail, 4 skipped. The 4 new redelivery and warning tests fail on the unfixed code and pass with the fix; a 5th test checks the 200-id limit.node scripts/build-client.mjs --checknpm run lint(0 errors)dsh-v0.2.2-rc.1, mock model, all 56 steps passedAlso ran the leak scan (
scripts/scan.mjs): must fix 0. Not verified: a real WeChat redelivery. The issue's production trace doesn't prove one happened.Checklist / 检查
src/client/changed →npm run buildran andclient.jsis committed. / 改了src/client/就已重新 build 并提交client.js。 (not changed)Co-authored-by. / 没有把 AI 工具写成作者或Co-authored-by。Agent: Devin (Cognition)
Implemented in session Fix IM replies dropped by dropOrigin
Review with Devin · Open in Devin Desktop