Skip to content

fix(feishu): post into existing topic thread when reply_to is absent#16603

Closed
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/feishu-topic-thread-create-path
Closed

fix(feishu): post into existing topic thread when reply_to is absent#16603
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/feishu-topic-thread-create-path

Conversation

@konsisumer

Copy link
Copy Markdown
Contributor

What changed and why

When a user sends a message inside a Feishu topic thread, the inbound event carries a thread_id. Hermes stored it in metadata and used it correctly when reply_to was set (via reply_in_thread=True on the message.reply API). However, the create path — reached when reply_to is None (progress/thinking messages, approval cards, or after the withdrawn-message fallback) — called message.create with receive_id_type="chat_id", completely ignoring thread_id. This caused every such message to start a brand-new topic instead of replying within the current one.

Fix in _send_raw_message (gateway/platforms/feishu.py):

  • When reply_to is None and thread_id is present in metadata, use receive_id_type="thread_id" with thread_id as receive_id.
  • The Feishu API accepts thread_id as a receive-id type and delivers the message inside the existing thread.
  • This also covers the fallback path (withdrawn message → active_reply_to = None) since metadata is forwarded unchanged.

How to test

  1. Set up Hermes with a Feishu enterprise account and a topic group.
  2. Open an existing topic thread and send a message to Hermes.
  3. Verify that all Hermes responses (including intermediate thinking/progress messages and any approval cards) appear inside the same topic thread, not as new top-level topics.
  4. Run the regression test: pytest tests/gateway/test_feishu.py::FeishuAdapterSendTests::test_send_uses_thread_id_receive_type_when_no_reply_to -v

What platforms tested on

  • macOS (unit tests only; Feishu enterprise tenant required for live verification)

Fixes #7734

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #11433 — same root cause: Feishu create path ignores thread_id when reply_to is absent.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main. Local run of tests/gateway/test_feishu.py is green (190 passed). The 60 failing checks in CI are all in files outside this PR's scope (discord, slack, tui, hermes_cli, run_agent, tools) and appear to be pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from cbc3fbf to 5ee633d Compare April 27, 2026 22:22
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (3 new upstream commits since last push). Rebase completed with no conflicts — our two files (gateway/platforms/feishu.py, tests/gateway/test_feishu.py) were untouched by upstream. Local run of tests/gateway/test_feishu.py confirms 190 passed. The 21 CI failures from the previous run are all in files outside this PR's scope (hermes_cli, tui_gateway, run_agent, tools) and appear to be pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from 5ee633d to 1c3cca1 Compare April 28, 2026 03:13
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (2 new upstream commits since last push: ec8243fe chore/release, 8081425a feat/security-redact). No conflicts — neither touches gateway/platforms/feishu.py or tests/gateway/test_feishu.py. Local run of tests/gateway/test_feishu.py confirmed 190 passed. The 19 CI failures from the previous run are all in files outside this PR's scope (hermes_cli, tui_gateway, run_agent, tools, other gateway tests) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from 1c3cca1 to 7472b87 Compare April 28, 2026 07:20
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (5 new upstream commits since last push). No conflicts — neither gateway/platforms/feishu.py nor tests/gateway/test_feishu.py were touched by upstream. Local run of tests/gateway/test_feishu.py confirmed 190 passed. The 23 CI failures from the previous run are all in files outside this PR's scope (agent, hermes_cli, tui_gateway, run_agent, tools, and unrelated gateway tests) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from 7472b87 to a8ef800 Compare April 28, 2026 11:55
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (44 new upstream commits since last push). No conflicts — neither gateway/platforms/feishu.py nor tests/gateway/test_feishu.py were touched by upstream. Local run of tests/gateway/test_feishu.py confirmed 190 passed. The 23 CI failures from the previous run are all in files outside this PR's scope (agent, hermes_cli, tui_gateway, run_agent, tools, and unrelated gateway tests) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from a8ef800 to 91cbf10 Compare April 28, 2026 16:13
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (5 new upstream commits since last push). No conflicts — neither gateway/platforms/feishu.py nor tests/gateway/test_feishu.py were touched by upstream. Local run of tests/gateway/test_feishu.py confirmed 190 passed. The CI failures are all in files outside this PR's scope (agent, hermes_cli, tui_gateway, tools, and unrelated gateway tests) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from 91cbf10 to 28e65be Compare April 28, 2026 20:26
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main. All 190 feishu tests pass locally (tests/gateway/test_feishu.py). The failing CI checks (test, nix, nix-lockfile-check) are pre-existing upstream issues: test_session.py imports normalize_whatsapp_identifier which does not exist in gateway/session.py on main, and the nix lockfile failures are infrastructure issues — neither is caused by this PR.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from 28e65be to ea3db18 Compare April 29, 2026 01:04
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (52 new upstream commits since last push). No conflicts — neither gateway/platforms/feishu.py nor tests/gateway/test_feishu.py was touched by upstream. Local run of tests/gateway/test_feishu.py confirmed 190 passed. The CI failures are all in files outside this PR’s scope (agent, hermes_cli, tui_gateway, run_agent, tools, and unrelated gateway tests) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from ea3db18 to df0c82a Compare April 29, 2026 08:55
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main. No conflicts — neither gateway/platforms/feishu.py nor tests/gateway/test_feishu.py were touched by upstream. Local run of tests/gateway/test_feishu.py confirmed 190 passed. The CI failures are all in files outside this PR's scope (agent, hermes_cli, tui_gateway, run_agent, tools, and unrelated gateway tests) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from df0c82a to e179810 Compare April 29, 2026 13:23
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (41 new upstream commits since last push). No conflicts — neither gateway/platforms/feishu.py nor tests/gateway/test_feishu.py was touched by upstream. Local run of tests/gateway/test_feishu.py confirmed 190 passed. The CI failures are all in files outside this PR's scope (agent, hermes_cli, tui_gateway, run_agent, tools, and unrelated gateway tests) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (323 commits ahead). Rebase applied cleanly with no conflicts — upstream had also touched feishu.py in two commits but they didn't conflict with our change. All 195 feishu tests pass locally including the new test_send_uses_thread_id_receive_type_when_no_reply_to test.

The nix and nix-lockfile-check CI failures are unrelated to this PR (they affect infrastructure files not in our changeset) and appear to be pre-existing upstream issues.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (26 new upstream commits since last push). Rebase applied cleanly with no conflicts — the upstream feishu commit (38dd057e9) touched a different function and did not interact with our change. Local run of tests/gateway/test_feishu.py confirmed 196 passed. The 10 CI failures are all in files outside this PR's scope (tests/acp/test_server.py, tests/gateway/test_teams.py, tests/run_agent/test_concurrent_interrupt.py, tests/hermes_cli/test_update_gateway_restart.py, tests/test_tui_gateway_server.py, tests/tools/test_dockerfile_pid1_reaping.py) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch 2 times, most recently from d12d79d to a16fc4f Compare May 2, 2026 19:07
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (1 new upstream commit: 5d3be898a docs(tts): mention xAI custom voice support). No conflicts — the upstream commit only touches hermes_cli/config.py, hermes_cli/setup.py, and TTS docs; neither gateway/platforms/feishu.py nor tests/gateway/test_feishu.py was affected. Local run of tests/gateway/test_feishu.py confirmed 196 passed. The 15 CI failures from the previous run are all in files outside this PR's scope (tests/acp/test_server.py, tests/gateway/test_teams.py, tests/hermes_cli/, tests/run_agent/, tests/test_tui_gateway_server.py, tests/tools/) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from a16fc4f to 887cc39 Compare May 2, 2026 23:14
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto latest origin/main (already current — 0 commits behind). Local run of tests/gateway/test_feishu.py confirms 196 passed. The 16 CI failures are all in files outside this PR's scope (tests/acp/test_server.py, tests/gateway/test_teams.py, tests/hermes_cli/, tests/run_agent/, tests/test_tui_gateway_server.py, tests/tools/) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto latest origin/main (already current — 0 commits behind). Local run of tests/gateway/test_feishu.py confirms 196 passed. The 15 CI failures are all in files outside this PR's scope (tests/acp/test_server.py, tests/gateway/test_teams.py, tests/hermes_cli/, tests/run_agent/, tests/test_tui_gateway_server.py, tests/tools/) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from 887cc39 to 11d118c Compare May 3, 2026 03:18
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (already current — 0 commits behind). Local run of tests/gateway/test_feishu.py confirmed 196 passed. The 15 CI failures are all in files outside this PR’s scope (tests/acp/test_server.py, tests/gateway/test_teams.py, tests/hermes_cli/, tests/run_agent/, tests/test_tui_gateway_server.py, tests/tools/) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch 2 times, most recently from f195451 to a9cc626 Compare May 3, 2026 07:59
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (2 new upstream commits: fix(tools): reconfigure enabled unconfigured toolsets and fix(model): avoid bedrock credential probe in provider picker). No conflicts — neither touched gateway/platforms/feishu.py or tests/gateway/test_feishu.py. Local run of tests/gateway/test_feishu.py confirmed 196 passed. The 17 CI failures are all in files outside this PR’s scope (tests/acp/test_server.py, tests/gateway/test_teams.py, tests/hermes_cli/, tests/run_agent/, tests/test_tui_gateway_server.py, tests/tools/) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (10 new upstream commits since last push). No conflicts — neither gateway/platforms/feishu.py nor tests/gateway/test_feishu.py was touched by upstream. Local run of tests/gateway/test_feishu.py confirmed 196 passed. The 15 CI failures are all in files outside this PR's scope (tests/acp/test_server.py, tests/gateway/test_teams.py, tests/hermes_cli/, tests/run_agent/, tests/test_tui_gateway_server.py, tests/tools/) and are pre-existing upstream failures unrelated to the Feishu threading fix.

@konsisumer konsisumer force-pushed the fix/feishu-topic-thread-create-path branch from a9cc626 to 9b94e88 Compare May 3, 2026 08:59
@konsisumer

Copy link
Copy Markdown
Contributor Author

Closing — deferring to #11433 by @youttiao which addresses the same. Reopen if that PR stalls.

@konsisumer konsisumer closed this May 3, 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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Title: Two issues with the Feishu plugin

2 participants