Skip to content

Feishu: Sub-agent replies create new topics instead of replying in the original topic thread #10773

@4ier

Description

@4ier

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

  1. When a user sends a message in a Feishu topic thread, the bot should reply in the same topic thread
  2. Sub-agent results should be announced back in the original topic thread
  3. Different topic threads should have isolated session contexts

Proposed Fix

  1. Set threads: true in Feishu channel capabilities
  2. Pass ctx.rootId as MessageThreadId in the inbound context
  3. Add threadId support to sendMessageFeishu (using root_id parameter or the Feishu reply-in-thread API)
  4. Update resolveFeishuSession to include topic threadId in session keys (similar to Telegram's topic handling)
  5. Update feishuOutbound adapter to accept and forward threadId

Environment

  • OpenClaw: latest main branch
  • Feishu plugin: @openclaw/feishu v2026.2.6
  • Feishu SDK: @larksuiteoapi/node-sdk ^1.56.1

Related Code

  • extensions/feishu/src/bot.ts — inbound message handling
  • extensions/feishu/src/send.ts — message sending
  • extensions/feishu/src/outbound.ts — outbound adapter
  • extensions/feishu/src/channel.ts — capability declaration
  • src/agents/tools/sessions-spawn-tool.ts — sub-agent spawn
  • src/agents/subagent-announce.ts — sub-agent result announcement
  • src/infra/outbound/outbound-session.ts — session routing

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions