Skip to content

fix: keep main session displayName on outbound sends#4693

Closed
ManojINaik wants to merge 2 commits into
openclaw:mainfrom
ManojINaik:fix/session-displayname-outbound
Closed

fix: keep main session displayName on outbound sends#4693
ManojINaik wants to merge 2 commits into
openclaw:mainfrom
ManojINaik:fix/session-displayname-outbound

Conversation

@ManojINaik

@ManojINaik ManojINaik commented Jan 30, 2026

Copy link
Copy Markdown

Summary

  • prevent outbound DM sends that resolve to the main session key from overwriting origin metadata, which was flipping sessions_list displayName to the last recipient
  • keep delivery context updates (lastTo, lastChannel, lastAccountId, lastThreadId) so routing remains accurate
  • leave per-peer session behavior unchanged so labels continue to reflect their peer

Context

Outbound sends call ensureOutboundSessionEntry, which previously used the inbound metadata pipeline even when DM scope collapsed to the main session key. That path derives the origin label from ctx.From, so the main session’s displayName became the last recipient. The fix skips origin updates for main-session routes and only persists delivery context in that case.

Testing

  • Not run (not requested)

Closes #4683

Greptile Overview

Greptile Summary

This PR updates ensureOutboundSessionEntry (src/infra/outbound/outbound-session.ts) to avoid updating origin-derived session metadata when an outbound DM route collapses to the agent’s main session key. For those “main-session” routes it now only persists delivery context (via updateLastRoute) so routing fields like lastTo/lastChannel/lastAccountId/lastThreadId remain accurate, while preventing the main session displayName from being overwritten by the most recent recipient. Per-peer session behavior continues to use the inbound metadata pipeline (recordSessionMetaFromInbound).

Confidence Score: 4/5

  • This PR is likely safe to merge; it’s a small, targeted behavior change in session metadata writes.
  • Change is narrowly scoped to ensureOutboundSessionEntry and only alters behavior when the outbound route collapses to the agent main session key. It uses existing store primitives (updateLastRoute) and keeps the previous behavior for non-main session routes. Main remaining risk is silent failure of session-store writes due to swallowed errors, which can mask operational issues.
  • src/infra/outbound/outbound-session.ts

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +841 to +843
if (params.route.baseSessionKey === mainSessionKey) {
try {
await updateLastRoute({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Swallowing session-store write errors makes debugging hard

The new try { await updateLastRoute(...) } catch {} intentionally avoids blocking outbound sends, but it also drops any signal that session store writes are failing (permissions, invalid store path, JSON parse errors, etc.). Consider at least logging at debug/warn level so failures don’t silently degrade routing/history.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/outbound/outbound-session.ts
Line: 841:843

Comment:
[P2] Swallowing session-store write errors makes debugging hard

The new `try { await updateLastRoute(...) } catch {}` intentionally avoids blocking outbound sends, but it also drops any signal that session store writes are failing (permissions, invalid store path, JSON parse errors, etc.). Consider at least logging at debug/warn level so failures don’t silently degrade routing/history.


How can I resolve this? If you propose a fix, please make it concise.

@steipete

Copy link
Copy Markdown
Contributor

Closing as AI-assisted stale-fix triage.

Linked issue #4683 ("Bug: Session displayName updates to last message recipient instead of session owner") is currently closed and was closed on 2026-02-03T20:02:35Z with state reason completed.
Given that issue is closed, this fix PR is no longer needed in the active queue and is being closed as stale.

If this specific implementation is still needed on current main, please reopen #4693 (or open a new focused fix PR) and reference #4683 for fast re-triage.

@steipete steipete closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Session displayName updates to last message recipient instead of session owner

2 participants