Skip to content

fix(agents): persist sender identity for direct-message turns - #124548

Merged
obviyus merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/control-ui-dm-sender-123393
Aug 27, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/control-ui-dm-sender-123393

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #123393

What Problem This Solves

External direct-message turns reached the model with channel sender identity, but transcript persistence dropped that identity. Control UI then rendered the operator fallback label, You.

Current main 71d4a8c3e305c623aa3ffe92696eec18f116cfc6 reproduces the loss in src/auto-reply/reply/get-reply-run-execute.ts: an admitted direct turn stores no senderId, senderName, or senderUsername.

Root cause

executePreparedReplyRun persisted sender metadata only for group and channel routes. The loss happened before buildPersistedUserTurnMetadata, so the existing Gateway and Control UI consumers had no durable identity to display.

Fix

  • Persist sender metadata for a direct route only when channel ingress admitted the turn and did not mark it as self-authored.
  • Carry the existing iMessage is_from_me and WhatsApp fromMe facts through the shared inbound context.
  • Keep group and channel behavior unchanged.
  • Keep gateway-local and from-me direct turns attributed to the operator.
  • Do not migrate old transcript rows.

Evidence

  • Pre-fix reproduction: the focused sender-attribution test fails on current main because the direct row has only owner and transport metadata.
  • Exact head 4f18e6ad12ffdf639b11c2731ec7e3e8aa58dc3f: 375 tests pass across reply persistence, shared inbound context, iMessage, WhatsApp, Gateway display projection, and Control UI normalization.
  • Sibling matrix: admitted external direct persists; from-me direct does not; gateway-local direct does not; group and channel still persist without channel-admission metadata.
  • Real Telegram direct-message run: one user message, two typing events, one bot reply, and one mock-provider request.
  • Ephemeral Gateway verdict from the same run: chat.history returned the user turn with senderId, senderName, and senderUsername; the production Control UI grouping and label resolver returned <redacted-peer-label> with renderedAsPeer: true.
  • Static proof: changed extension files pass Oxlint and the repository formatter.
  • Exact-head CI: openclaw/ci-gate passed in run 33040236918.
  • Exact-head local ClawSweeper: patch correct, zero findings, security cleared, no maintainer decision, and zero rank-up moves.
  • Contributor browser proof: external peer label and operator label.
{"externalDirectTurnFound":true,"gatewayHistoryRole":"user","storedSenderFields":["senderId","senderName","senderUsername"],"controlUiGroupRole":"user","renderedLabel":"<redacted-peer-label>","renderedAsPeer":true}

Change size

  • Production: +14/-3, net +11. The growth adds the self-origin fact and the admission-owned persistence decision.
  • Tests: +121/-24, net +97. The tests cover the producer boundary and all sibling attribution cases.

Compatibility

Future admitted external direct-message rows retain sender identifiers and names. This intentional display and transcript change is the feature. Existing rows and operator-authored rows stay unchanged.

AI assistance

  • AI-assisted repair and verification: Yes.
  • Human contributor intent and authorship are preserved.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@SunnyShu0925
SunnyShu0925 force-pushed the fix/control-ui-dm-sender-123393 branch from f6098b3 to 31ff72f Compare August 16, 2026 12:07
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 12:35 AM ET / 04:35 UTC.

ClawSweeper review

What this changes

The PR records sender identity for admitted external direct-message turns while retaining operator attribution for self-authored and gateway-local turns.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The patch restores sender metadata at the transcript boundary so existing Control UI logic can distinguish an external direct-message contact from the local operator. It remains necessary because it is not on current main; no blocking defect was identified.

Priority: P2
Reviewed head: 983421225526019f66e62547960d4d95aef825f6

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with meaningful regression coverage and concrete after-fix UI evidence.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied after-fix production-path output, DOM assertion, and UI screenshot show the external sender label; reviewer-side DNS prevented attachment download but does not weaken the supplied evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The supplied after-fix production-path output, DOM assertion, and UI screenshot show the external sender label; reviewer-side DNS prevented attachment download but does not weaken the supplied evidence.
Evidence reviewed 6 items Persistence-boundary repair: The PR changes the direct-message predicate at the reply executor and serializes sender metadata only for admitted external direct messages.
Existing UI consumer: Durable sender metadata is already converted to a sender label by chat-history normalization, so repairing persistence is preferable to a UI-specific workaround.
Ingress-owned self fact: The generic context builder carries the pre-existing sender self fact as an explicit ingress fact; iMessage and WhatsApp project their authoritative from-me fields into it.
Findings None None.
Security None None.

How this fits together

Channel ingress supplies sender facts to an admitted message context, which the reply runtime persists in the user-turn transcript. Chat history normalizes that metadata and the Control UI uses it to label messages.

flowchart LR
  A[Channel message] --> B[Ingress sender facts]
  B --> C[Admitted message context]
  C --> D[Reply runtime]
  D --> E[User-turn transcript]
  E --> F[Chat history normalization]
  F --> G[Control UI sender label]
Loading

Before merge

  • Resolve merge risk (P1) - Future externally admitted direct-message transcript rows will display the peer rather than the local operator; complete exact-head validation before landing this intentional UI-visible compatibility change.
  • Complete next step (P2) - No repair dispatch is needed: no patch defect was found, and the PR only awaits normal exact-head validation.
Agent review details

Security

None.

PR surface

Source +11, Tests +120. Total +131 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 14 3 +11
Tests 4 140 20 +120
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 154 23 +131

Review metrics

Metric Value Why it matters
Production and test delta production +14/-3; tests +140/-20 The added ingress fact and persistence predicate implement the self-message invariant, with coverage across the affected channel and transcript boundaries.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #123393
Summary: This PR is the open candidate fix for the direct-message sender-attribution bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Complete exact-head validation (recommended)
    Land after the required checks for the current commit complete successfully and confirm the intended direct-message label change.

Technical review

Best possible solution:

Land the focused persistence repair after required exact-head checks complete, retaining the ingress-owned self-message distinction.

Do we have a high-confidence way to reproduce the issue?

Yes—source proves the former group/channel-only persistence condition, and focused tests cover external and self-authored direct turns; the untrusted PR branch was not executed in this read-only review.

Is this the best way to solve the issue?

Yes—the defect originates at transcript persistence, while existing history normalization and Control UI rendering already consume durable sender metadata.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 71d4a8c3e305.

Labels

Label justifications:

  • P2: This corrects Control UI sender attribution for admitted external direct messages without an outage or data-loss signal.
  • merge-risk: 🚨 compatibility: Future direct-message transcripts will present the external peer identity instead of the local operator.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The supplied after-fix production-path output, DOM assertion, and UI screenshot show the external sender label; reviewer-side DNS prevented attachment download but does not weaken the supplied evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied after-fix production-path output, DOM assertion, and UI screenshot show the external sender label; reviewer-side DNS prevented attachment download but does not weaken the supplied evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame and recent history connect this contributor to the transcript sender-persistence boundary. (role: recent reply-runtime contributor; confidence: high; commits: 682ddcb28cbe; files: src/auto-reply/reply/get-reply-run-execute.ts)
  • joshavant: Recent history connects this contributor to channel context construction and auto-reply orchestration. (role: recent channel-context contributor; confidence: medium; commits: 0b859660, 97a53a9; files: src/channels/inbound-event/context.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-16T13:45:44.803Z sha a60e2405d6ddeca5e86d3ea2dcdc48fce003ff2e :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-16T15:03:48.231Z sha f9a04d3897285d82956b2dbd0fced6410b038c77 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-16T15:20:21.750Z sha f9a04d3897285d82956b2dbd0fced6410b038c77 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T15:42:22.849Z sha 1408eee0cae7d06dd5cb5909217ae15b5f648f32 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T23:38:57.536Z sha d365271cdfadb9129eb7d893972cc85253e3a83e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T17:20:57.340Z sha d365271cdfadb9129eb7d893972cc85253e3a83e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T03:31:06.730Z sha d365271cdfadb9129eb7d893972cc85253e3a83e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T18:14:25.356Z sha d365271cdfadb9129eb7d893972cc85253e3a83e :: needs maintainer review before merge. :: none

@SunnyShu0925
SunnyShu0925 force-pushed the fix/control-ui-dm-sender-123393 branch from 31ff72f to da1ceb2 Compare August 16, 2026 12:39
@openclaw-barnacle openclaw-barnacle Bot added the channel: imessage Channel integration: imessage label Aug 16, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 16, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/control-ui-dm-sender-123393 branch 2 times, most recently from f7caf30 to 7c5d894 Compare August 16, 2026 12:56
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 16, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/control-ui-dm-sender-123393 branch from 7c5d894 to 458cdbd Compare August 16, 2026 13:05
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@SunnyShu0925
SunnyShu0925 force-pushed the fix/control-ui-dm-sender-123393 branch from 458cdbd to 2e5dddd Compare August 16, 2026 13:13
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 16, 2026
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 16, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@SunnyShu0925
SunnyShu0925 force-pushed the fix/control-ui-dm-sender-123393 branch from f9a04d3 to 1408eee Compare August 16, 2026 15:32
@obviyus
obviyus force-pushed the fix/control-ui-dm-sender-123393 branch from d365271 to 9834212 Compare August 27, 2026 04:28
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Aug 27, 2026
Persist sender identity for admitted external direct messages at the user-turn transcript boundary. Keep from-me and gateway-local direct turns attributed to the operator.

Closes openclaw#123393

Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus
obviyus force-pushed the fix/control-ui-dm-sender-123393 branch from 9834212 to 4f18e6a Compare August 27, 2026 04:42
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 27, 2026
@obviyus

obviyus commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Thanks @SunnyShu0925!

@obviyus
obviyus merged commit 4a2b910 into openclaw:main Aug 27, 2026
272 of 273 checks passed
vincentkoc added a commit that referenced this pull request Aug 27, 2026
…-retirement-v13

* origin/main: (243 commits)
  fix: preserve Gateway error reasons in text logs (#130645)
  refactor(video): deduplicate generation contracts (#130635)
  fix(agents): preserve direct-message sender identity (#124548)
  fix(agents): preserve silent reply after settled tools (#130675)
  fix(talk): preserve replacement speech when an old utterance is canceled (#130687)
  fix(browser): preserve literal names and formatter-owned snapshot refs (#130599)
  fix(auth): reset only the profile replaced by a successful login (#124014)
  fix: bind session creation to admitted Gateway (#130686)
  refactor(qa-lab): reuse model reference splitter (#130317)
  docs(gateway): clarify independent HTTP endpoint switches (#130690)
  fix(ui): Control UI smooth scrolling ignores the reduced-motion preference (#130428)
  refactor(lmstudio): remove unreachable catalog merge (#130689)
  fix(crabbox): restore cloud machine CPU and RAM (#130684)
  fix(secrets): compare proxy bearer tokens directly (#127054)
  fix(matrix): show recovery key availability in text status (#128051)
  fix(ios): restore approval settings navigation and remove duplicate shell state (#130651)
  refactor(agents): use fixed tool-loop defaults directly (#130681)
  refactor(qa-lab): share process tree metric reader (#130419)
  refactor(models): simplify prepared owner access (#130683)
  fix(parallels): main install and update smoke cannot complete (#130658)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
Preserve admitted external direct-message sender metadata at the transcript boundary so Control UI can show the contact label while gateway-local and from-me turns stay attributed to the operator.

Co-authored-by: SunnyShu0925 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@obviyus Thanks for merging! Glad to help.

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

Labels

channel: imessage Channel integration: imessage channel: whatsapp-web Channel integration: whatsapp-web merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Control UI chat pane shows "You" instead of sender id/number for direct-message (1:1) inbound messages

2 participants