openclaw/extensions
Brian Qu 8a607d7553
fix(feishu): fetch thread context so AI can see bot replies in topic threads (#45254)
* fix(feishu): fetch thread context so AI can see bot replies in topic threads

When a user replies in a Feishu topic thread, the AI previously could only
see the quoted parent message but not the bot's own prior replies in the
thread. This made multi-turn conversations in threads feel broken.

- Add `threadId` (omt_xxx) to `FeishuMessageInfo` and `getMessageFeishu`
- Add `listFeishuThreadMessages()` using `container_id_type=thread` API
  to fetch all messages in a thread including bot replies
- In `handleFeishuMessage`, fetch ThreadStarterBody and ThreadHistoryBody
  for topic session modes and pass them to the AI context
- Reuse quoted message result when rootId === parentId to avoid redundant
  API calls; exclude root message from thread history to prevent duplication
- Fall back to inbound ctx.threadId when rootId is absent or API fails
- Fetch newest messages first (ByCreateTimeDesc + reverse) so long threads
  keep the most recent turns instead of the oldest

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(feishu): skip redundant thread context injection on subsequent turns

Only inject ThreadHistoryBody on the first turn of a thread session.
On subsequent turns the session already contains prior context, so
re-injecting thread history (and starter) would waste tokens.

The heuristic checks whether the current user has already sent a
non-root message in the thread — if so, the session has prior turns
and thread context injection is skipped entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(feishu): handle thread_id-only events in prior-turn detection

When ctx.rootId is undefined (thread_id-only events), the starter
message exclusion check `msg.messageId !== ctx.rootId` was always
true, causing the first follow-up to be misclassified as a prior
turn. Fall back to the first message in the chronologically-sorted
thread history as the starter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(feishu): bootstrap topic thread context via session state

* test(memory): pin remote embedding hostnames in offline suites

* fix(feishu): use plugin-safe session runtime for thread bootstrap

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
2026-03-14 18:01:59 -05:00
..
acpx build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
bluebubbles build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
copilot-proxy build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
device-pair refactor: share device pair ipv4 parsing 2026-03-13 23:35:27 +00:00
diagnostics-otel build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
diffs build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
discord Fix configure startup stalls from outbound send-deps imports (#46301) 2026-03-14 09:58:03 -07:00
feishu fix(feishu): fetch thread context so AI can see bot replies in topic threads (#45254) 2026-03-14 18:01:59 -05:00
google-gemini-cli-auth build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
googlechat build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
imessage Fix configure startup stalls from outbound send-deps imports (#46301) 2026-03-14 09:58:03 -07:00
irc build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
line build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
llm-task build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
lobster build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
matrix Fix configure startup stalls from outbound send-deps imports (#46301) 2026-03-14 09:58:03 -07:00
mattermost fix(mattermost): carry thread context to non-inbound reply paths (#44283) 2026-03-14 12:23:23 +05:30
memory-core build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
memory-lancedb build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
minimax-portal-auth build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
msteams Fix configure startup stalls from outbound send-deps imports (#46301) 2026-03-14 09:58:03 -07:00
nextcloud-talk build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
nostr build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
ollama build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
open-prose build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
phone-control test: share plugin api test harness 2026-03-14 02:40:27 +00:00
qwen-portal-auth refactor(extensions): reuse shared helper primitives 2026-03-07 10:41:05 +00:00
sglang build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
shared fix(ci): repair helper typing regressions 2026-03-14 03:22:53 +00:00
signal fix(ci): update vitest configs after channel move to extensions/ (openclaw#46066) 2026-03-14 13:23:25 -05:00
slack fix(ci): update vitest configs after channel move to extensions/ (openclaw#46066) 2026-03-14 13:23:25 -05:00
synology-chat build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
talk-voice fix(discord): avoid native plugin command collisions 2026-03-07 21:59:44 +00:00
telegram fix(ci): update vitest configs after channel move to extensions/ (openclaw#46066) 2026-03-14 13:23:25 -05:00
test-utils fix(ci): repair helper typing regressions 2026-03-14 03:22:53 +00:00
thread-ownership test: dedupe thread ownership send checks 2026-03-13 23:35:27 +00:00
tlon build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
twitch build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
vllm build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
voice-call build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
whatsapp Fix configure startup stalls from outbound send-deps imports (#46301) 2026-03-14 09:58:03 -07:00
zalo build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
zalouser build: sync plugins for 2026.3.14 2026-03-14 06:05:39 +00:00
.npmignore fix: harden windows npm runtime path 2026-03-12 23:03:19 +00:00