Skip to content

fix(feishu): keep group_topic message-tool replies inside the topic - #77151

Merged
hxy91819 merged 6 commits into
openclaw:mainfrom
ai-hpc:fix/deepseek-v4-thinking-policy-surface
May 9, 2026
Merged

hxy91819 merged 6 commits into
openclaw:mainfrom
ai-hpc:fix/deepseek-v4-thinking-policy-surface

Conversation

@ai-hpc

@ai-hpc ai-hpc commented May 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #74903.

When a Feishu group chat message lands in a group_topic-scoped session, the assistant's message(action="send") reply was posting at the group root instead of inside the topic (话题). Auto-thread send against the inbound trigger when the active session scope is group_topic or group_topic_sender, and propagate the topic-thread decision uniformly through text, card, and media sends. Plain group sessions stay unthreaded.

Root cause

extensions/feishu/src/channel.ts only set replyToMessageId / replyInThread for explicit action: "thread-reply"; a topic-scoped send left both unset, so Feishu posted to the chat root. The runtime sendMedia adapter in extensions/feishu/src/outbound.ts likewise forwarded only replyToMessageId to sendMediaFeishu, dropping the thread-mode flag for media sends.

Changes

  • extensions/feishu/src/channel.ts — add isFeishuGroupTopicSessionKey() plus typed helpers (resolveFeishuTopicAutoThreadAnchor, buildFeishuSendReplyAnchor) so the action handler derives { replyToMessageId, replyInThread } once and forwards it uniformly to text, card, and media sends.
  • extensions/feishu/src/outbound.ts — extend sendOutboundText to accept and forward replyInThread; the runtime sendMedia adapter resolves { replyToMessageId, replyInThread } via a new resolveFeishuMediaReplyMode() helper and propagates replyInThread to every sendMediaFeishu / sendOutboundText sub-call (mainline, post-voice fallback, catch fallback, no-media branch).
  • Tests:
    • extensions/feishu/src/channel.test.ts — six new cases: text/card/media auto-thread in group_topic, group_topic_sender variant, no auto-thread for plain group, no auto-thread when currentMessageId is missing.
    • extensions/feishu/src/outbound.test.ts — threadId → replyInThread=true, and replyToId precedence over threadId.

Real behavior proof

Behavior or issue addressed: Feishu group_topic sessions where the assistant uses message(action="send") were posting visible replies at the group root instead of inside the topic thread (话题), as described in #74903. After the fix, topic-scoped send actions auto-thread against the inbound trigger and the visible reply lands inside the topic. Plain group send actions remain unthreaded so they continue to post at the chat root.

Real environment tested: Local macOS Mac mini gateway (launchctl gui/$(id -u)/ai.openclaw.gateway) running the patch on top of upstream main (ba675d8964 test: clarify secrets warning assertion), bundled extensions/feishu channel in WebSocket mode, real Lark tenant bot cli_a972e47287b8de17 joined to a Lark group with groupSessionScope: "group_topic". Agent runtime: openai-codex/gpt-5.5 via @openai/[email protected]. Live HTTPS calls to open.larksuite.com/open.feishu.cn returned real messageId values (om_x100b50…).

Exact steps or command run after this patch:

  1. cd /Users/a1111/openclaw && pnpm install && pnpm build (rebuilds dist/index.js with the patched feishu sources)
  2. launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway (restart gateway)
  3. Send Lark message inside a topic: long-press an existing message → Reply → @speedy_lark_bot thread test again
  4. Send Lark message at root (no topic): @speedy_lark_bot root test again
  5. Tail gateway runtime logs and Codex rollout: tail -F /Users/a1111/.openclaw/logs/gateway.log /tmp/openclaw/openclaw-2026-05-08.log and inspect /Users/a1111/.openclaw/agents/main/agent/codex-home/sessions/2026/05/08/rollout-*.jsonl

Evidence after fix:

Topic send — runtime log excerpt and Codex rollout terminal output captured live from the running gateway:

[feishu] feishu[main]: received message from ou_5b28…7087 in oc_02de…e754 (group)
[feishu] feishu[main]: group session scope=group_topic, peer=oc_02de…e754:topic:om_x100b50ec1c0c2c…
[feishu] feishu[main]: dispatching to agent (session=agent:main:feishu:group:oc_02de…e754:topic:om_x100b50ec1c0c2c…)
[feishu] feishu[main]: dispatch complete (queuedFinal=false, replies=0)

Codex rollout (rollout-2026-05-08T17-01-30-…jsonl, captured directly from disk after the live turn ran on the patched build):

CALL message: {"accountId":"main","action":"send","target":"chat:oc_02de…e754","threadId":"om_x100b50ec1c0c2c…","message":"hi 👋"}
OUT:          {"ok":true,"channel":"feishu","action":"send","messageId":"om_x100b50ecebef50a8ee8209cfac962bd","chatId":"oc_02de…e754",…}

Root send — runtime log excerpt and rollout terminal output from the same live setup:

[feishu] feishu[main]: received message from ou_5b28…7087 in oc_02de…e754 (group)
[feishu] feishu[main]: group session scope=group_topic, peer=oc_02de…e754      ← no :topic: segment
[feishu] feishu[main]: dispatching to agent (session=agent:main:feishu:group:oc_02de…e754)
[feishu] feishu[main]: dispatch complete (queuedFinal=false, replies=0)
CALL message: {"accountId":"main","action":"send","message":"got it, root message received ✅"}
OUT:          {"ok":true,"channel":"feishu","action":"send","messageId":"om_x100b50edbffa34b0ee762157221c95d",…}

Observed result after fix:

  • Topic test: isFeishuGroupTopicSessionKey() returned true on the :topic: session key, the action handler set replyInThread=true and replyToMessageId=<inbound message id>, the Lark Open API send returned ok:true with messageId=om_x100b50ecebef50a8ee8209cfac962bd, and the bot reply was visible inside the topic thread in the Lark client. (Pre-fix on the same setup: same Codex tool call landed at the group root.)
  • Root test: session key had no :topic: segment, the handler left replyInThread=false and replyToMessageId=undefined, the send returned ok:true with messageId=om_x100b50edbffa34b0ee762157221c95d, and the bot reply was visible at the top of the group (no regression).
  • No errors in /Users/a1111/.openclaw/logs/gateway.err.log during either turn.

What was not tested: Card and media auto-thread paths were not exercised on the live Lark group during this run because the bundled Codex agent on this gateway only emits text replies; their behavior is covered by the new unit tests in channel.test.ts (auto-threads send cards… and auto-threads send media…). group_topic_sender scope was likewise covered by unit test only.

Test plan

  • Unit: pnpm vitest run extensions/feishu/src/channel.test.ts extensions/feishu/src/outbound.test.ts (90/90 passing)
  • Live Lark group with groupSessionScope: "group_topic": topic reply lands inside the topic
  • Live Lark group with groupSessionScope: "group_topic": root message reply lands at top of group (no regression)

@clawsweeper

clawsweeper Bot commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR auto-threads Feishu message(action="send") replies for group_topic and group_topic_sender sessions, propagates replyInThread through text/card/media paths, and adds focused tests plus a changelog entry.

Reproducibility: yes. Current main is source-reproducible: the group prompt leads agents to message(action=send), while Feishu action dispatch only threads explicit thread-reply; the PR also supplies live Lark after-fix proof.

Real behavior proof
Sufficient (logs): The PR body and comment include live Lark setup details, redacted logs/rollout output with message IDs, and inspected before/after screenshots showing the fixed topic-thread behavior.

Next step before merge
No ClawSweeper repair lane is needed; latest head addresses the prior normalization finding and should proceed through normal maintainer review and CI.

Security
Cleared: The diff is limited to Feishu channel runtime, tests, and changelog; it does not add dependencies, workflows, install scripts, secret handling, or new third-party execution paths.

Review details

Best possible solution:

Land the Feishu-owned runtime fix after normal maintainer CI and mergeability checks, keeping topic threading in channel/outbound delivery code rather than relying on prompt guidance.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main is source-reproducible: the group prompt leads agents to message(action=send), while Feishu action dispatch only threads explicit thread-reply; the PR also supplies live Lark after-fix proof.

Is this the best way to solve the issue?

Yes. Runtime auto-threading from Feishu session scope is narrower and more reliable than asking the model to choose thread-reply, and latest head also normalizes the outbound text/media reply-mode decision.

What I checked:

  • current-main source reproduction: Current main only assigns replyToMessageId for explicit thread-reply and sets replyInThread from ctx.action === "thread-reply", so a topic-scoped send leaves both unset. (extensions/feishu/src/channel.ts:757, a99729fd2148)
  • message-tool prompt path: Group message-tool-only context tells the agent to use message(action=send) for visible group output, matching the linked bug path. (src/auto-reply/reply/groups.ts:235, a99729fd2148)
  • PR channel fix: The PR head detects Feishu topic-scoped session keys, derives one reply anchor, and forwards replyInThread through text/card/media action sends. (extensions/feishu/src/channel.ts:355, c6bc044af140)
  • PR outbound normalization: Latest head uses a normalized reply-mode helper for outbound text and media paths, including the whitespace-only replyToId fallback case that the earlier review flagged. (extensions/feishu/src/outbound.ts:416, c6bc044af140)
  • regression coverage: The PR adds topic auto-thread tests for text, cards, media, group_topic_sender, plain group non-threading, missing inbound IDs, and outbound threadId/replyToId precedence. (extensions/feishu/src/channel.test.ts:581, c6bc044af140)
  • real behavior proof: The PR body and proof comment provide a live Lark setup, redacted gateway/rollout logs with returned message IDs, and inspected before/after screenshots showing the after-fix bot reply inside the topic thread. (c6bc044af140)

Likely related people:

  • guoqunabc: Commit 63ce7c7 added Feishu outbound replyToId forwarding and topic-aware reply targeting across bot, outbound, send, and tests, which is the closest predecessor to this reply-mode path. (role: introduced adjacent reply targeting behavior; confidence: high; commits: 63ce7c74bdc0; files: extensions/feishu/src/bot.ts, extensions/feishu/src/outbound.ts, extensions/feishu/src/send.ts)
  • yfge: Commit 36d69d0 added Feishu sender/topic-scoped group session routing, including group_topic and group_topic_sender behavior used by this fix. (role: introduced topic-scoped session routing; confidence: medium; commits: 36d69d05e212; files: extensions/feishu/src/bot.ts, extensions/feishu/src/channel.ts, extensions/feishu/src/config-schema.ts)
  • steipete: Recent Feishu channel and outbound refactors, including the message lifecycle migration and filesystem/media safety extraction, touched the current code paths this PR builds on. (role: recent maintainer; confidence: high; commits: 05eda57b3c72, 538605ff44d2; files: extensions/feishu/src/channel.ts, extensions/feishu/src/outbound.ts, extensions/feishu/src/media.ts)
  • vincentkoc: Recent merged work split Feishu runtime seams and added native interactive card payload sends, which overlap with the card/runtime send surfaces changed here. (role: adjacent Feishu runtime owner; confidence: medium; commits: 2161b46032e0, a05daaa83229, e4cc8cd97513; files: extensions/feishu/src/channel.ts, extensions/feishu/src/outbound.ts)

Remaining risk / open question:

  • Latest head only shows lightweight GitHub checks and the Real behavior proof gate; the PR body reports targeted unit tests, but normal maintainer CI/mergeability should still gate merge.

Codex review notes: model gpt-5.5, reasoning high; reviewed against a99729fd2148.

@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-policy-surface branch from fc8e757 to 0a5a902 Compare May 4, 2026 07:46
@ai-hpc ai-hpc changed the title fix(deepseek): expose V4 xhigh/max thinking levels through bundled provider-policy-api surface fix(channels): do not mark optional-with-default fields as required in channel config json schema May 4, 2026
@ai-hpc ai-hpc closed this May 4, 2026
@ai-hpc
ai-hpc deleted the fix/deepseek-v4-thinking-policy-surface branch May 4, 2026 07:51
@ai-hpc
ai-hpc restored the fix/deepseek-v4-thinking-policy-surface branch May 4, 2026 07:52
@ai-hpc ai-hpc reopened this May 4, 2026
@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-policy-surface branch from 0a5a902 to be3c4c8 Compare May 4, 2026 08:05
@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-policy-surface branch from be3c4c8 to 7ba4254 Compare May 5, 2026 06:13
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 5, 2026
@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-policy-surface branch from 7ba4254 to af2c21d Compare May 6, 2026 07:24
@openclaw-barnacle openclaw-barnacle Bot added size: S proof: supplied External PR includes structured after-fix real behavior proof. and removed size: M labels May 6, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-policy-surface branch from af2c21d to 0edd614 Compare May 6, 2026 09:47
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-policy-surface branch from 0edd614 to b44a2f1 Compare May 6, 2026 11:42
@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-policy-surface branch from b44a2f1 to 5e2b68f Compare May 6, 2026 12:12
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@hxy91819 hxy91819 self-assigned this May 9, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@hxy91819

hxy91819 commented May 9, 2026

Copy link
Copy Markdown
Member

@clawsweeper review

@clawsweeper

clawsweeper Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@hxy91819

hxy91819 commented May 9, 2026

Copy link
Copy Markdown
Member

@clawsweeper review

@clawsweeper

clawsweeper Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@hxy91819
hxy91819 force-pushed the fix/deepseek-v4-thinking-policy-surface branch from c6bc044 to 55575ee Compare May 9, 2026 14:41
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@hxy91819
hxy91819 force-pushed the fix/deepseek-v4-thinking-policy-surface branch from 55575ee to 91d480b Compare May 9, 2026 14:47
ai-hpc and others added 6 commits May 9, 2026 22:48
When a Feishu group_topic-scoped session triggers `message(action="send")`,
the channel handler previously left replyToMessageId/replyInThread unset for
non-thread-reply actions, so the visible reply fell out of the topic and
posted at the group root.

Auto-thread `send` against the inbound trigger when the active session scope
is `group_topic` or `group_topic_sender`, and propagate the topic-thread
decision uniformly through text, card, and media sends. Plain group sessions
remain unthreaded.

Fixes openclaw#74903.
@hxy91819
hxy91819 force-pushed the fix/deepseek-v4-thinking-policy-surface branch from 91d480b to 3a47a09 Compare May 9, 2026 14:50
@hxy91819
hxy91819 merged commit aecd4fb into openclaw:main May 9, 2026
95 checks passed
@hxy91819

hxy91819 commented May 9, 2026

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @ai-hpc!

woodygreen pushed a commit to woodygreen/openclaw that referenced this pull request May 18, 2026
…penclaw#77151)

Merged via squash.

Prepared head SHA: 3a47a09
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
t2wei pushed a commit to t2wei/openclaw that referenced this pull request May 21, 2026
…outing)

Consolidated fork module §4 from iteration/fork-features:

- Streaming card: panel/history support, accepts upstream nested streaming
  config schema (streaming: { mode, chunkMode, preview, progress, block }).
- Reply dispatcher: onBlockNotify wiring for history panel narration,
  onItemEvent subscription for upstream's parallel item lifecycle, panel
  gate loosened to include item-only flows.
- Outbound: replyInThread forced for omt_* topic scopes (upstream PR openclaw#77151
  regression).
- Bot inbound: topicScope (rootId ?? threadId ?? messageId) for thread id,
  effectiveThreadId hydration for topic-creating messages.
- Channel resolveAutoThreadId: fallback to toolContext.currentMessageId
  when threadId is omt_*.
- config-schema: historyPanel, historyPanelScope, account-level streaming
  overrides.
- bundled-channel-config-metadata.generated.ts regenerated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu proof: supplied External PR includes structured after-fix real behavior proof. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [Feishu] group_topic session: assistant uses action=send instead of thread-reply, reply not posted in topic thread

2 participants