fix(whatsapp): restore direct inbound metadata for relay agents#31969
fix(whatsapp): restore direct inbound metadata for relay agents#31969steipete merged 4 commits intoopenclaw:mainfrom
Conversation
ac53cb5 to
b3c4538
Compare
Greptile SummaryRestores conversation metadata (message IDs, sender info) for WhatsApp and other external direct channels while preserving the existing behavior of hiding metadata for webchat direct sessions. The change addresses relay agents losing critical sender attribution after the 2026.2.26 migration. Key changes:
Issue found:
Confidence Score: 3/5
Last reviewed commit: b3c4538 |
| const isDirect = !chatType || chatType === "direct"; | ||
| const directChannelValue = safeTrim(ctx.OriginatingChannel) ?? safeTrim(ctx.Surface); | ||
| const includeDirectConversationInfo = Boolean( | ||
| directChannelValue && directChannelValue !== "webchat", | ||
| ); |
There was a problem hiding this comment.
Inconsistent channel resolution - should use resolveInboundChannel(ctx) instead of manually checking only OriginatingChannel and Surface.
The PR extracted resolveInboundChannel to centralize channel resolution logic, but it's not being used here. This helper includes fallback to Provider (lines 34-42), which is missing from this manual check.
If OriginatingChannel and Surface are both undefined but Provider is "whatsapp", this code would fail to include metadata for a direct WhatsApp chat, which contradicts the PR's goal.
| const isDirect = !chatType || chatType === "direct"; | |
| const directChannelValue = safeTrim(ctx.OriginatingChannel) ?? safeTrim(ctx.Surface); | |
| const includeDirectConversationInfo = Boolean( | |
| directChannelValue && directChannelValue !== "webchat", | |
| ); | |
| const directChannelValue = resolveInboundChannel(ctx); | |
| const includeDirectConversationInfo = Boolean( | |
| directChannelValue && directChannelValue !== "webchat", | |
| ); | |
| const shouldIncludeConversationInfo = !isDirect || includeDirectConversationInfo; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/inbound-meta.ts
Line: 87-91
Comment:
Inconsistent channel resolution - should use `resolveInboundChannel(ctx)` instead of manually checking only `OriginatingChannel` and `Surface`.
The PR extracted `resolveInboundChannel` to centralize channel resolution logic, but it's not being used here. This helper includes fallback to `Provider` (lines 34-42), which is missing from this manual check.
If `OriginatingChannel` and `Surface` are both undefined but `Provider` is "whatsapp", this code would fail to include metadata for a direct WhatsApp chat, which contradicts the PR's goal.
```suggestion
const directChannelValue = resolveInboundChannel(ctx);
const includeDirectConversationInfo = Boolean(
directChannelValue && directChannelValue !== "webchat",
);
const shouldIncludeConversationInfo = !isDirect || includeDirectConversationInfo;
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fe7c2f7cd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const directChannelValue = resolveInboundChannel(ctx); | ||
| const includeDirectConversationInfo = Boolean( | ||
| directChannelValue && directChannelValue !== "webchat", |
There was a problem hiding this comment.
Gate direct metadata on source surface, not route channel
For webchat-originated direct turns that are linked to an external delivery route, gateway/server-methods/chat.ts sets Provider/Surface to webchat but OriginatingChannel to the routed channel (for example whatsapp). Because this new logic derives directChannelValue from OriginatingChannel first, includeDirectConversationInfo becomes true and the direct Conversation info block (message/sender identifiers) is emitted, which reintroduces metadata in internal webchat sessions that were meant to stay hidden.
Useful? React with 👍 / 👎.
60d9d19 to
43e8dcf
Compare
…claw#31969) * fix(whatsapp): restore direct inbound metadata for relay agents * fix(auto-reply): use shared inbound channel resolver for direct metadata * chore(ci): retrigger checks after base update * fix: add changelog attribution for inbound metadata relay fix (openclaw#31969) (thanks @Lucenx9) --------- Co-authored-by: Simone <simone@example.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
…claw#31969) * fix(whatsapp): restore direct inbound metadata for relay agents * fix(auto-reply): use shared inbound channel resolver for direct metadata * chore(ci): retrigger checks after base update * fix: add changelog attribution for inbound metadata relay fix (openclaw#31969) (thanks @Lucenx9) --------- Co-authored-by: Simone <simone@example.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
…claw#31969) * fix(whatsapp): restore direct inbound metadata for relay agents * fix(auto-reply): use shared inbound channel resolver for direct metadata * chore(ci): retrigger checks after base update * fix: add changelog attribution for inbound metadata relay fix (openclaw#31969) (thanks @Lucenx9) --------- Co-authored-by: Simone <simone@example.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
…claw#31969) * fix(whatsapp): restore direct inbound metadata for relay agents * fix(auto-reply): use shared inbound channel resolver for direct metadata * chore(ci): retrigger checks after base update * fix: add changelog attribution for inbound metadata relay fix (openclaw#31969) (thanks @Lucenx9) --------- Co-authored-by: Simone <simone@example.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
Summary
2026.2.26migration/restart, WhatsApp direct messages routed to relay agents could lose theConversation info (untrusted metadata)block (missing sender/message identifiers).#29972).whatsapp) inbuildInboundUserContextPrefix.webchatdirect sessions to preserve the prior UX/privacy behavior.webchat(hidden) vs direct external channel (included).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
openai-completionsstyle)whatsappSteps
Conversation info (untrusted metadata)block includes sender/message ids.Expected
Actual
Evidence
Commands run locally:
pnpm vitest run src/auto-reply/reply/inbound-meta.test.ts src/auto-reply/reply/strip-inbound-meta.test.ts(pass)pnpm check(pass)pnpm build(pass)pnpm protocol:check(pass)pnpm lint:ui:no-raw-window-open(pass)Human Verification (required)
What you personally verified (not just CI), and how:
webchatstill suppresses conversation metadata block.whatsappnow includesmessage_id,message_id_full,sender.conversation_labelremains omitted for direct chats.Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
src/auto-reply/reply/inbound-meta.ts,src/auto-reply/reply/inbound-meta.test.ts.Risks and Mitigations
webchatbehavior unchanged; new tests cover both paths.AI-Assisted Contribution