Skip to content

fix(im): keep the reply origin when a context note joins the turn - #1725

Closed
jiejiesks wants to merge 1 commit into
Fei2411:devfrom
jiejiesks:fix/1718-im-context-origin
Closed

jiejiesks wants to merge 1 commit into
Fei2411:devfrom
jiejiesks:fix/1718-im-context-origin

Conversation

@jiejiesks

@jiejiesks jiejiesks commented Nov 17, 2026 •

Copy link
Copy Markdown

Issue

Fixes #1718

What changed / 改了什么

ds-bot/src/host/im/index.js: a turn's reply origin is withdrawn whenever a user/message that is not the IM request joins the turn. DSH and plugins also put context into a running turn as user messages — the clock, memory, the skill catalog, model and job notices, plugin recalls. Those were treated as another source: dropOrigin() cleared the chat's claim and marked the Session mixed, so every reply in that turn stayed in the app and nothing was logged.

isContextNote() recognises that context by its form (snapshot, catalog, recall, instructions, notice), by the DSH/DS Bot context kinds (compact-checkpoint, runtime-context, skill-catalog, model-selection, time-context, ds-bot-time-context, ds-bot-memory-update) and by a plugin: kind prefix, and leaves the origin alone. A real message from the Web UI or phone (a user message with a non-IM rpcId), a peer Bot, a scheduled task, or an answer given elsewhere still withdraws it.

Two regression tests: a context note after the IM message and a context note before it both still answer the IM chat.

Changelog

IM replies no longer go missing when the turn also carries injected context, such as the clock, memory, the skill catalog or a plugin's recall.

How I checked it / 怎么验证的

  • npm test (in ds-bot/) — test/im.test.js passes 61/61, including the two new cases. The full run in this environment has 25 failures, all in test/connectors-engine.test.js and test/doctor.test.js, caused by This DSH cannot load connectors (upstream HTTP 502); they are unrelated to this change.
  • node scripts/build-client.mjs --check — no client change.
  • npm run lint
  • Smoke test, for changes to index.js or src/host/ — not run: this machine has no ../deepseek-harness checkout.
  • Screenshot attached — not an interface change.

Checklist / 检查

  • One issue, one subject. / 只做一件事。
  • src/client/ not changed. / 没改 src/client/。
  • No keys, tokens or personal data. / 没有密钥、token 或个人数据。
  • No AI tool as author or Co-authored-by. / 没有把 AI 工具写成作者或 Co-authored-by。

Devin Review

DSH and plugins put notes into a running turn as user messages: the clock,
memory, the skill catalog, model and job notices, and plugin recalls. The
reply-origin check treated every one of them as another source, withdrew the
chat's claim and marked the turn mixed, so the Bot's answer never reached the
IM chat and nothing was logged. Ignore the notes; a real message from the Web
UI, another Bot or a scheduled task still withdraws the claim.

Fixes Fei2411#1718

@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: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@Fei2411 Fei2411 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verdict: COMMENT — recommend closing in favour of #1750 (same bug, #1718/#1735).

The tests pass on dev a95e3af (2899/0) and the intent is right, but #1750's approach is safer:

  1. pendingReset is consumed by a context note. pendingReset.delete() runs before isContextNote() is checked, so in a group Session's late turn a lone context note uses up the pending reset without resetting the origin. If no classifying message follows, the previous turn's origin survives (fail-open). #1750 returns before pendingReset is touched.
  2. The classifier is too broad. Treating every plugin: kind as context can hide a real plugin-delivered request, which would then answer an IM chat that never asked. The extra forms (catalog, recall, instructions, notice) and kinds should only be added once DSH is confirmed to emit them into a running turn as user/message.

Suggestion: if any non-snapshot form really does appear in practice, a small follow-up on top of #1750 (same early-return position, an explicit list, no plugin: wildcard) would cover it. Your two tests (the multi-source loop and the note-before-IM-message case) are worth porting there.

@Fei2411

Fei2411 commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix, @jiejiesks! #1750 covers the same IM reply problem (#1718/#1735) in one change, so closing this one in its favor.

@Fei2411 Fei2411 closed this Nov 19, 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.

2 participants