Skip to content

feat(gateway): Feishu auto-thread and topic-based session routing - #9118

Closed
keenlin wants to merge 2 commits into
NousResearch:mainfrom
keenlin:feat/feishu-topic-session-routing
Closed

feat(gateway): Feishu auto-thread and topic-based session routing#9118
keenlin wants to merge 2 commits into
NousResearch:mainfrom
keenlin:feat/feishu-topic-session-routing

Conversation

@keenlin

@keenlin keenlin commented Apr 13, 2026

Copy link
Copy Markdown

What does this PR do?

Closes #9154

Problem: Discord is inaccessible in China, leaving users without a thread-isolated gateway
option. This PR implements auto-thread and topic-based session isolation,
filling that gap.

Platform adaptation note: Feishu lacks Discord's explicit thread creation API. We
use a placeholder message as a compensating pattern — sending "🔄 Thinking..." with
reply_in_thread=true forces topic creation, allowing the first message to route into
the correct thread session.

Key Features:

  • FEISHU_AUTO_THREAD: Auto-create topics for group mentions (like
    DISCORD_AUTO_THREAD)
  • Topic session isolation: Each Feishu topic has independent conversation context
    (intrinsic, no toggle)
  • FEISHU_THREAD_REQUIRE_MENTION: Control mention requirements in bot-participated
    topics
  • Placeholder bootstrap: Sends "🔄 Thinking..." first, edits with actual response

Discord Alignment:

Feature Discord Feishu (this PR)
Auto-thread env DISCORD_AUTO_THREAD FEISHU_AUTO_THREAD
Exclusion list DISCORD_NO_THREAD_CHANNELS FEISHU_NO_THREAD_GROUPS
Thread tracking _bot_participated_threads Same pattern
Session isolation Thread = isolated session Topic = isolated session

Changes Made

  • gateway/platforms/feishu.py: Auto-thread bootstrap, root_id session routing,
    thread tracking persistence
  • hermes_cli/config.py: Register new env vars
  • tests/gateway/test_feishu.py: Thread routing tests
  • website/docs/user-guide/messaging/feishu.md: Thread Routing documentation

How to Test

# 1. Auto-thread flow
export FEISHU_AUTO_THREAD=true
hermes gateway --platform feishu
# Mention bot in group → should create topic with placeholder → edit with response

# 2. Topic isolation
# Messages in same topic share context, different topics are isolated

# 3. Run tests
pytest tests/gateway/test_feishu.py -v -k "thread"

Type of Change

  • ✨ New feature

Checklist

  • Follows Conventional Commits
  • Added tests
  • Updated documentation
  • Zero gateway layer changes (adapter-only)

@keenlin
keenlin force-pushed the feat/feishu-topic-session-routing branch from 445f684 to 9da6063 Compare April 14, 2026 02:35
@keenlin
keenlin marked this pull request as draft April 14, 2026 04:26
@keenlin

keenlin commented Apr 14, 2026

Copy link
Copy Markdown
Author

Latest version broke this PR—converting to draft while investigating regression.


GatewayStreamConsumer/interim messages could send with thread_id but no reply_to, which fell back to CreateMessage and posted to the parent group. This follow-up fix routes those thread-context sends through the Reply API so they stay inside the topic.

@keenlin
keenlin marked this pull request as ready for review April 14, 2026 05:53
keenlin added 2 commits April 14, 2026 14:03
Add automatic topic creation and thread-level session isolation for Feishu
  group chats:

- Auto-thread: when enabled, creates a topic for qualifying top-level group
  messages by sending a placeholder reply ("Thinking..."), then editing
  it with the actual response once processing completes
- Topic session isolation: messages within a Feishu topic automatically
  carry their own independent conversation context
- Thread tracking: persistent _bot_participated_threads set for mention
  policy management in bot-participated topics
- Configurable via FEISHU_AUTO_THREAD, FEISHU_NO_THREAD_GROUPS, and
  FEISHU_THREAD_REQUIRE_MENTION with per-group overrides
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the detailed adapter work and the follow-up addressing interim thread-context sends.

This automated hermes-sweeper review is closing the PR under the standing configuration policy:

  • The diff introduces FEISHU_AUTO_THREAD, FEISHU_NO_THREAD_GROUPS, and FEISHU_THREAD_REQUIRE_MENTION as user-facing behavioral controls (hermes_cli/config.py, PR head a79920f47569).
  • AGENTS.md:102-107 requires non-secret behavior settings to use config.yaml, rather than new HERMES_*/environment-variable configuration.
  • The current gateway already has a plugin-owned YAML configuration bridge (gateway/config.py:1252-1287; Feishu registers it at plugins/platforms/feishu/adapter.py:5618-5654).

Please re-scope any follow-up around platforms.feishu.extra configuration through that YAML path. It should also preserve thread_id as the topic identity rather than prioritizing root_id; related report #20548 documents why those fields can diverge.


Closed as not-planned per standing maintainer policy (env-var-for-config). This is a design-direction decision, not a code-quality judgment — see the Contribution Rubric in AGENTS.md for what the project is looking for. If you believe this policy was misapplied to your change, comment here and a maintainer will take a look.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added the sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: feishu/lark auto-thread with topic-level session isolation (like Discord)

3 participants