-
-
Notifications
You must be signed in to change notification settings - Fork 69.1k
Feishu: Sub-agent replies create new topics instead of replying in the original topic thread #10773
Description
Problem
When using Feishu topic groups (话题群), sub-agents spawned via sessions_spawn send their results as new messages in the group instead of replying within the original topic thread. This breaks the conversation context for users.
Root Cause
The Feishu channel plugin does not propagate topic thread context (rootId) through the OpenClaw pipeline. Specifically:
1. threads: false in channel capabilities (extensions/feishu/src/channel.ts:54)
The plugin declares it does not support threads, which causes the core to skip thread-aware routing.
2. No MessageThreadId in inbound context (extensions/feishu/src/bot.ts:813-835)
The plugin correctly parses rootId from Feishu events (line 489: rootId: event.message.root_id || undefined), but never passes it as MessageThreadId when constructing the inbound context payload:
const ctxPayload = core.channel.reply.finalizeInboundContext({
Body: combinedBody,
// ... other fields ...
// Missing: MessageThreadId: ctx.rootId,
});3. No threadId in outbound (extensions/feishu/src/outbound.ts)
The outbound adapter does not accept or pass threadId to sendMessageFeishu. When replies need to be routed back, there is no mechanism to target a specific topic thread.
4. No topic-aware session routing (src/infra/outbound/outbound-session.ts:826-871)
resolveFeishuSession does not consider threadId when building session keys, so all topics in the same group share a single session — mixing conversation contexts.
5. sendMessageFeishu lacks topic thread support (extensions/feishu/src/send.ts)
The send function uses im.message.create without any topic thread parameter. Feishu's API does not use reply_in_thread but topic threads are identified by the root_id in the conversation.
Impact on Sub-Agents
The sessions_spawn tool captures requesterOrigin.threadId at spawn time (see sessions-spawn-threadid.test.ts). However, since the Feishu plugin never provides threadId, requesterOrigin.threadId is always undefined. When runSubagentAnnounceFlow sends the result back, it has no topic context and the message appears outside the original thread.
Expected Behavior
- When a user sends a message in a Feishu topic thread, the bot should reply in the same topic thread
- Sub-agent results should be announced back in the original topic thread
- Different topic threads should have isolated session contexts
Proposed Fix
- Set
threads: truein Feishu channel capabilities - Pass
ctx.rootIdasMessageThreadIdin the inbound context - Add threadId support to
sendMessageFeishu(usingroot_idparameter or the Feishu reply-in-thread API) - Update
resolveFeishuSessionto include topic threadId in session keys (similar to Telegram's topic handling) - Update
feishuOutboundadapter to accept and forwardthreadId
Environment
- OpenClaw: latest main branch
- Feishu plugin:
@openclaw/feishuv2026.2.6 - Feishu SDK:
@larksuiteoapi/node-sdk^1.56.1
Related Code
extensions/feishu/src/bot.ts— inbound message handlingextensions/feishu/src/send.ts— message sendingextensions/feishu/src/outbound.ts— outbound adapterextensions/feishu/src/channel.ts— capability declarationsrc/agents/tools/sessions-spawn-tool.ts— sub-agent spawnsrc/agents/subagent-announce.ts— sub-agent result announcementsrc/infra/outbound/outbound-session.ts— session routing