openclaw - 💡(How to fix) Fix [Bug]: Feishu oc_ (OpenChat) chats create duplicate group/direct sessions — outbound vs inbound chatType mismatch [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58536Fetched 2026-04-08 02:01:25
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1locked ×1

When OpenClaw proactively sends messages to a Feishu OpenChat (oc_ prefix) via message send or cron delivery, the outbound path creates a direct session key (e.g. agent:main:feishu:direct:oc_xxxx). However, when a user sends a message in the same chat, the inbound webhook path creates a group session key (agent:main:feishu:group:oc_xxxx). This results in two separate sessions for the same chat, with conversation context split between them.

Related: #52342 fixes the inbound isGroup detection for oc_ chats, but the outbound routing (buildChannelOutboundSessionRoute / resolveSessionKey) still uses the default chatType inference, which doesn't apply the same oc_ → group correction. Even after #52342 merges, the outbound path will continue creating direct sessions for oc_ chats.

Root Cause

When OpenClaw proactively sends messages to a Feishu OpenChat (oc_ prefix) via message send or cron delivery, the outbound path creates a direct session key (e.g. agent:main:feishu:direct:oc_xxxx). However, when a user sends a message in the same chat, the inbound webhook path creates a group session key (agent:main:feishu:group:oc_xxxx). This results in two separate sessions for the same chat, with conversation context split between them.

Related: #52342 fixes the inbound isGroup detection for oc_ chats, but the outbound routing (buildChannelOutboundSessionRoute / resolveSessionKey) still uses the default chatType inference, which doesn't apply the same oc_ → group correction. Even after #52342 merges, the outbound path will continue creating direct sessions for oc_ chats.

Fix Action

Workaround

Manually merge the duplicate session .jsonl files and update sessions.json to remove the stale key.

RAW_BUFFERClick to expand / collapse

[Bug]: Feishu oc_ (OpenChat) chats create duplicate group/direct sessions — outbound vs inbound chatType mismatch

Bug type

Bug

Summary

When OpenClaw proactively sends messages to a Feishu OpenChat (oc_ prefix) via message send or cron delivery, the outbound path creates a direct session key (e.g. agent:main:feishu:direct:oc_xxxx). However, when a user sends a message in the same chat, the inbound webhook path creates a group session key (agent:main:feishu:group:oc_xxxx). This results in two separate sessions for the same chat, with conversation context split between them.

Related: #52342 fixes the inbound isGroup detection for oc_ chats, but the outbound routing (buildChannelOutboundSessionRoute / resolveSessionKey) still uses the default chatType inference, which doesn't apply the same oc_ → group correction. Even after #52342 merges, the outbound path will continue creating direct sessions for oc_ chats.

Steps to reproduce

  1. Configure a Feishu OpenChat (话题群, chat_id starts with oc_)
  2. Have OpenClaw proactively send a message to the chat (e.g., via heartbeat, cron, or message send tool)
  3. Observe sessions.json — a feishu:direct:oc_xxxx entry is created
  4. Send a message as a user in the same chat
  5. Observe sessions.json — a feishu:group:oc_xxxx entry is created
  6. Now two sessions exist for the same chat, with different conversation histories

Expected behavior

A single session per chat_id, regardless of whether messages are inbound or outbound-initiated.

Actual behavior

Two sessions created:

  • agent:main:feishu:direct:oc_xxxx (from outbound/cron delivery)
  • agent:main:feishu:group:oc_xxxx (from inbound webhook)

The AI loses context between the two, and replies may route to the wrong session.

Suggested fix

  1. Apply #52342's isFeishuGroupChat logic to the outbound pathbuildChannelOutboundSessionRoute and related functions should use the same oc_ prefix check
  2. Session key dedup on creation — Before creating a new session, check if sessions.json already has an entry with the same chat_id (ignoring the group/direct prefix). If so, reuse the existing session instead of creating a duplicate
  3. Gateway restart reconciliation — On startup, scan for duplicate group/direct session keys pointing to the same chat_id and merge or deduplicate them

Environment

  • OpenClaw version: 2026.3.28
  • Channel: Feishu (WebSocket mode)
  • OS: Ubuntu on WSL2
  • Affected chat_ids: oc_ prefixed OpenChat/topic groups

Workaround

Manually merge the duplicate session .jsonl files and update sessions.json to remove the stale key.

extent analysis

TL;DR

Apply the isFeishuGroupChat logic from #52342 to the outbound path to ensure consistent session key creation for Feishu OpenChat sessions.

Guidance

  • Review the buildChannelOutboundSessionRoute function to apply the oc_ prefix check for Feishu OpenChat sessions, ensuring they are treated as group sessions.
  • Implement session key deduplication on creation by checking sessions.json for existing entries with the same chat_id, ignoring the group/direct prefix.
  • Consider adding a gateway restart reconciliation mechanism to scan for and merge duplicate session keys pointing to the same chat_id on startup.

Example

No explicit code example is provided, but the fix involves modifying the buildChannelOutboundSessionRoute function to include the isFeishuGroupChat logic, similar to the changes made in #52342.

Notes

The provided fix assumes that applying the isFeishuGroupChat logic to the outbound path will resolve the session key mismatch issue. However, additional testing and verification may be necessary to ensure the fix works as expected.

Recommendation

Apply the workaround by manually merging duplicate session files and updating sessions.json to remove stale keys, and then apply the suggested fix to prevent future occurrences. This approach ensures a temporary solution while working towards a permanent fix.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

A single session per chat_id, regardless of whether messages are inbound or outbound-initiated.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING