feat(gateway): feishu thread participation tracking (involved mode)#744
feat(gateway): feishu thread participation tracking (involved mode)#744wangyuyan-agent wants to merge 4 commits intoopenabdev:mainfrom
Conversation
Once the bot replies in a thread, subsequent messages in that thread bypass @mention gating — matching Discord's default 'involved' mode. - Add participated_threads cache (HashMap<thread_id, Instant>) - Bypass mention gating when message is in a participated thread - Record participation on successful reply to a thread - TTL controlled by FEISHU_SESSION_TTL_HOURS (default 24h) - Cache eviction at 1000 entries (oldest-half strategy) - 3 new tests for participation logic
OpenAB PR ScreeningThis is auto-generated by the OpenAB project-screening flow for context collection and reviewer handoff.
Screening report## IntentPR #744 adds Feishu thread participation tracking so the bot can continue responding inside a Feishu topic/thread after it has already been explicitly mentioned there. The operator-visible problem is that Feishu currently behaves more strictly than Discord: every follow-up message requires an FeatFeature. The PR introduces an “involved mode” behavior for Feishu group chat threads:
Who It ServesPrimary beneficiaries: Feishu end users. Secondary beneficiaries: deployers and agent runtime operators who want Feishu behavior to better match Discord’s default involved-thread experience without requiring persistent storage or expensive Feishu history scans. Rewritten PromptImplement Feishu thread “involved mode” participation tracking. In Add a configurable TTL via Update Feishu docs with the new env var, behavior, restart limitation, and known multi-bot caveat. Add or update tests for mention gating, TTL-disabled behavior, restart/cache-miss behavior, and thread/non-thread distinction. Merge PitchThis is worth advancing because it closes a concrete usability gap between Discord and Feishu: once a bot is part of a thread, users should not need to repeatedly mention it. Risk profile is moderate. The main behavioral risk is over-response, especially in multi-bot Feishu threads where multiple bots may consider themselves involved. The likely reviewer concern is whether in-memory participation is acceptable and whether the mention-bypass logic is scoped tightly enough to Feishu thread IDs, bot identity, TTL, and group chat semantics. Best-Practice ComparisonOpenClaw principles that are relevant:
Hermes Agent principles that are relevant:
The most applicable best-practice principle is explicit, bounded routing: the bypass should be narrow, observable, and easy to disable. Implementation OptionsConservative option: strict in-memory involved mode Balanced option: in-memory involved mode plus stronger observability and config shape Ambitious option: persisted participation state with multi-bot policy Comparison Table
RecommendationAdvance the balanced option. The core behavior is useful and mergeable, but the next review should focus on tightening operational clarity: ensure the bypass decision is logged or otherwise inspectable, config behavior is explicit, and tests cover TTL-disabled, cache-miss, threaded, and non-threaded cases. Keep persistence and multi-bot policy out of this PR unless the current implementation already makes them unavoidable. Those are legitimate follow-ups, but splitting them preserves a clean first merge: Feishu gets Discord-like involved-thread behavior with bounded in-memory state and a clear escape hatch. |
🟢 PR #744 — feat(gateway): feishu thread participation tracking (involved mode)Verdict: Approve with minor nits What problem does it solve?Feishu group chats require @mention for every message. Once the bot has replied in a thread, users expect it to keep responding without re-mentioning — matching Discord's How does it solve it?Adds an in-memory What was considered?
Is this the best approach?Yes. It mirrors the proven Discord pattern with appropriate adaptation for Feishu's API constraints. The implementation is clean and well-tested. Detailed notes🟢 INFO — Well done
🟡 NIT — Non-blocking suggestions
🔴 SUGGESTED CHANGES — NoneNo blocking issues found. |
- Extract check_thread_participated() helper to reduce duplication - Add comments explaining intentional poisoned-mutex recovery - Improve eviction: drop TTL-expired entries first, then oldest half
|
Thanks for the review! All three nits addressed in 15f16d8:
|
|
LGTM ✅ — Clean implementation of Discord-style "involved" mode for Feishu threads. Solid foundation for the multibot-mentions follow-up (#746). 📋 Review — Four Questions1. What problem does this solve?In Feishu group chats, the bot requires @mention for every message. Once a user starts a conversation in a thread, having to @mention every follow-up is friction. This PR makes the bot remember threads it has replied in and auto-respond without @mention — matching Discord's default 2. How does it solve it?
3. What alternatives were considered?PR documents:
Pure in-memory cache chosen as pragmatic middle ground. 4. Is this the best approach?Yes. The design is minimal and correct. 🟢 INFO — Well done:
🟡 NIT — Non-blocking:
🔍 Baseline Check (Step 0)
|
|
Let's fix the NITs #744 (comment) @wangyuyan-agent |
- Add comment clarifying session_ttl_secs=0 disables participation tracking - Update bot_turns comment: remove TODO, note existing eviction pattern
|
Second-round nits addressed in cb6a56e:
|
chaodu-agent
left a comment
There was a problem hiding this comment.
All NITs addressed ✅ — helper extracted, mutex comments added, TTL=0 documented, bot_turns comment updated. CI green. Ready to merge.
Skip cache insertion entirely when session_ttl_secs is 0 (feature disabled), avoiding unnecessary mutex lock and cache accumulation.
obrutjack
left a comment
There was a problem hiding this comment.
LGTM ✅ — Clean implementation, all nits addressed, CI green. Approved.
Summary
Adds thread participation tracking to the Feishu adapter. Once the bot replies in a thread (topic), subsequent messages in that thread no longer require @mention — matching Discord's default
allow_user_messages: "involved"behavior.Prior Art
Feishu API Fact-Check
Feishu's
GET /im/v1/messagesreturns all messages in a chat with no per-thread filter (root_idmust be matched client-side). Rebuilding participation state after restart would require scanning entire chat histories — impractical for active groups. This is why we use pure in-memory cache (same as Discord's data structure, minus the API rebuild path).Changes
gateway/src/adapters/feishu.rssession_ttl_secsconfig,participated_threadscache, participation check in mention gating,record_participationon replydocs/feishu.mdFEISHU_SESSION_TTL_HOURSenv var + Thread Participation docsTesting
cargo test— 99 passed, 0 failedKnown Limitations
involveddefault). Follow-up:multibot-mentionsmode./leave: Bot stays involved until TTL expires.Follow-up Plan
multibot-mentionsmode — require @mention when multiple bots are in a thread/leavecommandNew Environment Variable
FEISHU_SESSION_TTL_HOURS240to disable.Discord Discussion URL
https://discord.com/channels/1491295327620169908/1500160821567684660