hermes - 💡(How to fix) Fix Feishu: card callback resolves wrong chat_type for p2p chats, breaking session model overrides [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14615Fetched 2026-04-24 06:15:58
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×4

In the Feishu adapter, when a user clicks a button on the interactive /MODEL picker card in a p2p (DM) chat, _resolve_source_chat_type() returns "group" instead of "dm". This causes the session key built from the card callback to differ from the session key used by the regular message handler, so the model override stored by the card callback is never applied.

Root Cause

In gateway/platforms/feishu.py, the card action handler (~line 2390) calls _resolve_source_chat_type() which uses get_chat_info API. For p2p chats, this API returns type "p2p" which gets normalized to "group" by _resolve_source_chat_type().

Meanwhile, the regular message handler receives the chat type directly from the message event, which correctly resolves to "dm".

Result:

  • Card callback builds session key: agent:main:feishu:group:oc_xxx:ou_yyy
  • Message handler looks up: agent:main:feishu:dm:oc_xxx
  • Override stored under the wrong key → never found

Code Example

# 1. Try ms field from card action value (model picker includes session_key)
_ms = str(action_value.get("ms", "") or "")
_ms_chat_type = ""
if _ms:
    _ms_parts = _ms.split(":")
    if len(_ms_parts) >= 4:
        _ms_chat_type = _ms_parts[3]

# 2. Fallback to model picker state (stores correct session_key from creation time)
if _ms_chat_type not in ("dm", "group", "forum"):
    _picker_state = (
        self._model_picker_state.get(str(card_message_id or ""))
        or self._model_picker_state.get(str(chat_id))
    )
    if _picker_state and _picker_state.get("session_key"):
        _sk_parts = _picker_state["session_key"].split(":")
        if len(_sk_parts) >= 4:
            _ms_chat_type = _sk_parts[3]

if _ms_chat_type in ("dm", "group", "forum"):
    resolved_chat_type = _ms_chat_type
else:
    resolved_chat_type = self._resolve_source_chat_type(...)
RAW_BUFFERClick to expand / collapse

Summary

In the Feishu adapter, when a user clicks a button on the interactive /MODEL picker card in a p2p (DM) chat, _resolve_source_chat_type() returns "group" instead of "dm". This causes the session key built from the card callback to differ from the session key used by the regular message handler, so the model override stored by the card callback is never applied.

Reproduction

  1. Set up Hermes with Feishu channel in websocket mode
  2. In a p2p DM with the bot, send /model
  3. Click a model button on the interactive card
  4. Send any message — the model is NOT switched, still uses the default

Root Cause

In gateway/platforms/feishu.py, the card action handler (~line 2390) calls _resolve_source_chat_type() which uses get_chat_info API. For p2p chats, this API returns type "p2p" which gets normalized to "group" by _resolve_source_chat_type().

Meanwhile, the regular message handler receives the chat type directly from the message event, which correctly resolves to "dm".

Result:

  • Card callback builds session key: agent:main:feishu:group:oc_xxx:ou_yyy
  • Message handler looks up: agent:main:feishu:dm:oc_xxx
  • Override stored under the wrong key → never found

Suggested Fix

In the card action handler, before calling _resolve_source_chat_type(), try extracting the correct chat_type from alternative sources:

# 1. Try ms field from card action value (model picker includes session_key)
_ms = str(action_value.get("ms", "") or "")
_ms_chat_type = ""
if _ms:
    _ms_parts = _ms.split(":")
    if len(_ms_parts) >= 4:
        _ms_chat_type = _ms_parts[3]

# 2. Fallback to model picker state (stores correct session_key from creation time)
if _ms_chat_type not in ("dm", "group", "forum"):
    _picker_state = (
        self._model_picker_state.get(str(card_message_id or ""))
        or self._model_picker_state.get(str(chat_id))
    )
    if _picker_state and _picker_state.get("session_key"):
        _sk_parts = _picker_state["session_key"].split(":")
        if len(_sk_parts) >= 4:
            _ms_chat_type = _sk_parts[3]

if _ms_chat_type in ("dm", "group", "forum"):
    resolved_chat_type = _ms_chat_type
else:
    resolved_chat_type = self._resolve_source_chat_type(...)

Impact

High — the interactive /MODEL card is completely non-functional for p2p chats on Feishu. The model selection appears to succeed (card updates) but the override is lost.

Environment

  • Hermes agent version: 1acf81fd (Apr 13, 2026)
  • Platform: Feishu websocket mode, p2p DM chats

extent analysis

TL;DR

Modify the card action handler in gateway/platforms/feishu.py to correctly resolve the chat type for p2p chats.

Guidance

  • Extract the correct chat type from the ms field in the card action value or the model picker state before calling _resolve_source_chat_type().
  • Verify that the ms field or model picker state contains the correct session key with the chat type.
  • Update the resolved_chat_type variable with the extracted chat type if it is either "dm", "group", or "forum".
  • Test the interactive /MODEL card in a p2p DM chat on Feishu to ensure the model selection is applied correctly.

Example

_ms = str(action_value.get("ms", "") or "")
_ms_chat_type = ""
if _ms:
    _ms_parts = _ms.split(":")
    if len(_ms_parts) >= 4:
        _ms_chat_type = _ms_parts[3]

Notes

The suggested fix relies on the presence of the ms field in the card action value or the model picker state. If these fields are not available, an alternative solution may be needed.

Recommendation

Apply the suggested workaround to modify the card action handler, as it directly addresses the root cause of the issue and provides a clear solution for resolving the chat type in p2p chats on Feishu.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING