openclaw/scripts
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
..
dev refactor: remove channel shim directories, point all imports to extensions (#45967) 2026-03-14 03:43:07 -07:00
docker docker: add apt-get upgrade to all Dockerfiles (#45384) 2026-03-13 16:23:02 -07:00
docs-i18n
e2e test: harden parallels beta smoke flows 2026-03-14 05:54:49 +00:00
k8s docs: add Kubernetes install guide, setup script, and manifests (#34492) 2026-03-12 07:28:21 -04:00
lib refactor: extract bundled extension manifest parser 2026-03-08 18:26:36 +00:00
podman fix(run-openclaw-podman): add SELinux :Z mount option on enforcing/permissive hosts (#39449) 2026-03-08 18:53:09 -04:00
pre-commit
repro
shell-helpers
systemd
auth-monitor.sh
bench-cli-startup.ts
bench-model.ts
build-and-run-mac.sh
build-docs-list.mjs
build_icon.sh
bundle-a2ui.sh fix(feishu): fetch thread context so AI can see bot replies in topic threads (#45254) 2026-03-14 18:01:59 -05:00
canvas-a2ui-copy.ts
changelog-to-html.sh
check-channel-agnostic-boundaries.mjs
check-composite-action-input-interpolation.py
check-ingress-agent-owner-context.mjs refactor: remove channel shim directories, point all imports to extensions (#45967) 2026-03-14 03:43:07 -07:00
check-no-monolithic-plugin-sdk-entry-imports.ts
check-no-pairing-store-group-auth.mjs
check-no-random-messaging-tmp.mjs
check-no-raw-channel-fetch.mjs refactor: remove channel shim directories, point all imports to extensions (#45967) 2026-03-14 03:43:07 -07:00
check-no-raw-window-open.mjs
check-no-register-http-handler.mjs
check-pairing-account-scope.mjs
check-plugin-sdk-exports.mjs
check-ts-max-loc.ts
check-webhook-auth-body-order.mjs
ci-changed-scope.d.mts
ci-changed-scope.mjs ci: speed up scoped workflow lanes 2026-03-13 19:53:40 +00:00
claude-auth-status.sh
clawlog.sh
clawtributors-map.json
codesign-mac-app.sh
codespell-dictionary.txt
codespell-ignore.txt
committer fix: retry git lock in committer 2026-03-08 00:28:37 +00:00
copy-export-html-templates.ts build: reduce build log noise 2026-03-08 04:12:32 +00:00
copy-hook-metadata.ts build: reduce build log noise 2026-03-08 04:12:32 +00:00
copy-plugin-sdk-root-alias.mjs
create-dmg.sh
cron_usage_report.ts
debug-claude-usage.ts
docs-link-audit.mjs
docs-list.js
docs-spellcheck.sh
firecrawl-compare.ts
generate-config-doc-baseline.ts Docs: add config drift baseline statefile (#45891) 2026-03-14 14:23:30 -07:00
generate-host-env-security-policy-swift.mjs fix(exec): block dangerous override-only env pivots 2026-03-07 19:18:05 +00:00
generate-secretref-credential-matrix.ts
ghsa-patch.mjs
install.ps1
install.sh fix: improve onboarding install diagnostics 2026-03-13 21:44:29 +00:00
ios-asc-keychain-setup.sh
ios-beta-archive.sh feat(ios): add local beta release flow (#42991) 2026-03-11 12:32:28 +02:00
ios-beta-prepare.sh feat(push): add iOS APNs relay gateway (#43369) 2026-03-12 18:15:35 +02:00
ios-beta-release.sh feat(ios): add local beta release flow (#42991) 2026-03-11 12:32:28 +02:00
ios-configure-signing.sh
ios-team-id.sh
ios-write-version-xcconfig.sh chore: bump version to 2026.3.13 2026-03-13 04:38:32 +00:00
label-open-issues.ts
make_appcast.sh
mobile-reauth.sh
notarize-mac-artifact.sh
openclaw-npm-publish.sh ci: switch npm release workflow to trusted publishing 2026-03-14 13:45:40 +01:00
openclaw-npm-release-check.ts ci: allow fallback npm correction tags (#46486) 2026-03-14 19:38:14 +01:00
package-mac-app.sh macOS: default release app builds to universal binaries 2026-03-08 14:14:36 +00:00
package-mac-dist.sh
pr Revert "feat: add --no-test flag to prepare-gates" 2026-03-12 16:37:50 -07:00
pr-merge
pr-prepare Revert "feat: add --no-test flag to prepare-gates" 2026-03-12 16:37:50 -07:00
pr-review
protocol-gen-swift.ts
protocol-gen.ts
readability-basic-compare.ts
recover-orphaned-processes.sh
release-check.ts fix: harden windows npm runtime path 2026-03-12 23:03:19 +00:00
restart-mac.sh
run-node.d.mts
run-node.mjs
run-openclaw-podman.sh fix(run-openclaw-podman): add SELinux :Z mount option on enforcing/permissive hosts (#39449) 2026-03-08 18:53:09 -04:00
sandbox-browser-entrypoint.sh
sandbox-browser-setup.sh
sandbox-common-setup.sh Docker: improve build cache reuse (#40351) 2026-03-08 17:57:46 -07:00
sandbox-setup.sh
setup-auth-system.sh
sparkle-build.ts
sqlite-vec-smoke.mjs
sync-labels.ts
sync-moonshot-docs.ts
sync-plugin-versions.ts
termux-auth-widget.sh
termux-quick-auth.sh
termux-sync-widget.sh
test-cleanup-docker.sh
test-force.ts
test-hotspots.mjs
test-install-sh-docker.sh
test-install-sh-e2e-docker.sh
test-live-gateway-models-docker.sh fix: use build-stage image for docker live tests 2026-03-13 02:59:36 +00:00
test-live-models-docker.sh fix: use build-stage image for docker live tests 2026-03-13 02:59:36 +00:00
test-parallel.mjs fix(ci): update vitest configs after channel move to extensions/ (openclaw#46066) 2026-03-14 13:23:25 -05:00
test-perf-budget.mjs
test-shell-completion.ts
tsdown-build.mjs build: reduce build log noise 2026-03-08 04:12:32 +00:00
ui.js
update-clawtributors.ts
update-clawtributors.types.ts
watch-node.d.mts
watch-node.mjs
write-build-info.ts
write-cli-compat.ts
write-cli-startup-metadata.ts
write-plugin-sdk-entry-dts.ts refactor: move WhatsApp channel implementation to extensions/ (#45725) 2026-03-14 02:44:55 -07:00
zai-fallback-repro.ts