Skip to content

fix(im): resend only the undelivered chunks when a QQ reply is retried - #1871

Merged
Fei2411 merged 4 commits into
devfrom
fix/qq-retry-delivered-chunks
Nov 20, 2026
Merged

Fei2411 merged 4 commits into
devfrom
fix/qq-retry-delivered-chunks

Conversation

@Fei2411

@Fei2411 Fei2411 commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Issue

No issue filed. Devin Review found it on #1866 (finding); the bug is older than that PR.

What changed / 改了什么

Bug: QQ sends a long reply as several posts. When a later post failed, the IM queue kept the whole job, and Try again (or a backoff retry after a 5xx) sent it again from the first chunk. The recipient got the chunks that were already delivered a second time.

  • The QQ adapter now remembers, per job, how many chunks QQ accepted and the last message id (a module-level WeakMap keyed by the job, so it also works when Try again reconnects and gets a new handle). A retry of the same job continues after those chunks. If the job's text changed, or the job already finished, it starts again from the first chunk.
  • This depends on the IM queue passing the same job object back on Try again, which it already does. A new test in im.test.js checks that.
  • No change to the shared IM queue or to other platforms.

Overlap with #1866: that PR changes api() in the same file, and this one changes the send loop. The two branches merge with no conflicts, and im-qq.test.js passes with both applied (20/20). #1866 sends 2xx err_code refusals into the same retained-failure path, so after both merge, those refusals also retry only the remaining chunks.

Changelog

Using Try again on a long QQ reply that partly failed now sends only the parts that did not arrive, so the recipient no longer gets the earlier parts twice.

How I checked it / 怎么验证的

  • npm test (in ds-bot/): 3094 tests, 0 fail, 4 skipped. The new QQ test fails on dev (posts a, b, a, b, c instead of a, b, b, c).
  • node scripts/build-client.mjs --check
  • npm run lint
  • Smoke test against DSH dsh-v0.2.2-rc.1: all 52 steps pass
  • Screenshot attached, for interface changes (no interface change)

Checklist / 检查

  • One issue, one subject. / 只做一件事。
  • src/client/ changed → npm run build ran and client.js is committed. (src/client/ not changed)
  • No keys, tokens or personal data, also in screenshots. / 没有密钥、token 或个人信息,截图里也没有。
  • No AI tool as author or Co-authored-by. / 没有把 AI 工具写成作者或 Co-authored-by。

Agent: Devin (Cognition)


Product Engineer opened this PR for Lulu
Implemented in session Stop QQ Try again resending delivered chunks
Review with Devin · Open in Devin Desktop


A long QQ reply goes out as several posts. When a later post failed, the
IM queue kept the whole job and Try again (or a backoff retry) sent it
from the first chunk, so the recipient got the delivered chunks twice.
The QQ adapter now remembers, per job, how many chunks QQ took and
resumes after them.
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T17:49:59.281908Z d0b3eb4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@Fei2411 Fei2411 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Code Reaper review (comments only).

Verdict: ready for lulu, after one body fix.

What I checked

  • The resume logic is right for the queue as it is: drain sends queue.jobs[0] (index.js:589), a backoff retry re-runs the same object, retainFailed keeps it, and im-retry puts it back with enqueue(conn, chatKey, job) (index.js:1353). The replay onto a new runner (index.js:607) also moves the same object. So the WeakMap keyed by the job holds in every retry path, and the new im.test.js case pins that contract.
  • The text check and delivered.delete on success mean an edited or finished job starts from chunk 1. A failed markdown→plain fallback leaves the chunk uncounted, so it is retried, which is correct.
  • With #1866 merged in (git merge of both heads, no conflicts): im-qq.test.js + im.test.js 80/80 pass. #1866's 304023/304024 "awaiting audit" return has no id, so messageId keeps the last real id and count still moves on. That's correct: the audited chunk is not sent again.

Needs fixing

  • The PR body has no Agent: Devin (Cognition) line (AGENTS.md PR rule).

Not a blocker, for the record

  • A timeout or 5xx on a chunk that QQ actually accepted is still sent twice on retry. The client can't tell that case apart, so this PR doesn't cover it and doesn't have to.

Overlaps

  • #1866: separate hunks, merges cleanly. Fine in either order.
  • #1862 (QQ/DingTalk/WeChat inbound media) conflicts with this PR in qq.js. Both add top-level declarations after INTENTS: this PR's delivered WeakMap and #1862's IMAGE_EXTS/attachment helpers. Keep both blocks. Whichever lands second needs scripts/merge-dev.sh and that one-line resolution.

@Fei2411
Fei2411 merged commit 792f0cb into dev Nov 20, 2026
15 checks passed
@Fei2411
Fei2411 deleted the fix/qq-retry-delivered-chunks branch November 20, 2026 13:43
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