Skip to content

fix(feishu): reply inside P2P thread instead of as standalone message#38996

Closed
alvinttang wants to merge 1 commit intoopenclaw:mainfrom
alvinttang:fix/38806-feishu-p2p-thread-reply
Closed

fix(feishu): reply inside P2P thread instead of as standalone message#38996
alvinttang wants to merge 1 commit intoopenclaw:mainfrom
alvinttang:fix/38806-feishu-p2p-thread-reply

Conversation

@alvinttang
Copy link
Copy Markdown
Contributor

Summary

Changes in extensions/feishu/src/bot.ts

  1. Added isDmThread detection: isDirect && Boolean(ctx.threadId)
  2. replyInThread now returns true for P2P threads (was hardcoded false)
  3. replyTargetMessageId uses root_id for P2P threads (was always messageId)
  4. skipReplyToInMessages is false for P2P threads so im.message.reply is used instead of im.message.create
  5. threadReply is true for P2P threads

Fixes #38806

Test plan

  • Open a P2P (direct) chat with the bot in Feishu
  • Create a thread on any message
  • Send a message inside the thread
  • Verify: bot replies inside the thread, not as a standalone message
  • Verify: normal P2P messages (outside threads) still work as before
  • Verify: group thread behavior is unchanged

🤖 Generated with Claude Code

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling channel: feishu Channel integration: feishu size: S labels Mar 7, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 7, 2026

Greptile Summary

This PR fixes a regression (#33789) where Feishu bot replies to messages inside P2P (direct message) threads were sent as standalone messages instead of staying inside the thread. It also includes a fix (#38757) that prevents resolved plaintext API key secrets from being persisted to models.json.

Feishu P2P thread fix (extensions/feishu/src/bot.ts)

  • Introduces isDmThread = isDirect && Boolean(ctx.threadId) to detect when a DM message is inside a thread (using the thread_id field per Feishu API docs)
  • Threads this flag through all four reply-control variables: replyInThread, replyTargetMessageId (ctx.rootId ?? ctx.messageId), threadReply, and skipReplyToInMessages (isDirect && !isDmThread)
  • Regular DMs and group thread behaviour are unchanged

API key plaintext prevention (src/agents/models-config.providers.ts)

  • Adds ENV_VAR_NAME_RE and a reverse-lookup block in normalizeProviders that detects when apiKey holds a resolved secret value and replaces it with the canonical env-var name before writing to models.json
  • New tests cover both the unit-level normalizeProviders behaviour and the end-to-end ensureOpenClawModelsJson path

No automated tests were added for the P2P thread fix in bot.ts; coverage relies on the manual test plan in the PR description.

Confidence Score: 5/5

  • This PR is safe to merge; the logic changes are narrow, well-scoped, and consistent across all affected call sites.
  • The Feishu change threads a single boolean (isDmThread) through four variables in a consistent, symmetric way. All group and regular-DM paths remain unchanged. The models-config reverse-lookup is guarded by ENV_VAR_NAME_RE to avoid double-processing and only activates when the env-var value matches the stored key. Both new code paths are covered by tests.
  • No files require special attention.

Last reviewed commit: 39b4532

When a user sends a message inside a thread in a P2P (direct message)
chat, the bot now correctly replies within that thread. Previously, all
thread-aware reply logic was gated behind isGroup checks, causing P2P
thread replies to be sent as standalone messages.

The fix detects P2P threads via the thread_id field (per Feishu API docs,
thread_id indicates a thread message vs root_id which indicates a quote
reply) and enables thread-aware replies for direct messages.

Fixes openclaw#38806

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alvinttang alvinttang force-pushed the fix/38806-feishu-p2p-thread-reply branch from 39b4532 to a2cc88b Compare March 8, 2026 09:08
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed agents Agent runtime and tooling size: S labels Mar 8, 2026
@lxu4net lxu4net mentioned this pull request Mar 8, 2026
20 tasks
@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 23, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 26, 2026

Closing this as duplicate or superseded after Codex automated review.

Close #38996 as duplicate/superseded. Current main still lacks the Feishu P2P thread reply fix, but open PR #38808 tracks the same #38806 regression and contains the same direct-thread routing change plus targeted P2P regression tests. PR #38814 was already closed in favor of #38808, making #38808 the established canonical item for this fix family.

Best possible solution:

Close #38996 as superseded by open PR #38808. Continue review or landing work on #38808, preserving its P2P thread and P2P plain-reply regression tests, and keep #38806 open until the fix reaches main.

What I checked:

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 46b9044c3f9d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: bot replies outside thread in P2P direct message thread

2 participants