Skip to content

fix(groups): use 'channel' wording in intro for ChatType channel (fixes #95645) (AI-assisted) - #95654

Closed
liuhao1024 wants to merge 3 commits into
openclaw:mainfrom
liuhao1024:fix/mattermost-channel-intro-wording
Closed

liuhao1024 wants to merge 3 commits into
openclaw:mainfrom
liuhao1024:fix/mattermost-channel-intro-wording

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

For any non-DM Mattermost conversation — including a public channel — the system-prompt intro declares "You are in a <provider> group chat." even when ChatType is "channel". This contradicts the authoritative inbound-meta block which reports chat_type: "channel", causing agents to misidentify public channels as group chats and emit the wrong chat_type in tool arguments.

The first-turn activation intro (buildGroupIntro) similarly used "every group message" unconditionally for always-on activation, even when the session was a channel.

What does this PR do?

Uses the actual ChatType value to select "channel" or "group chat" wording throughout the full buildGroupChatContext prompt — not just the intro sentence, but also destination references, participant labels, task labels, and visible-response guidance. Also makes buildGroupIntro ChatType-aware so the activation intro uses "channel message" for channel sessions.

Related Issue

Fixes #95645

Type of Change

  • Bug fix (non-breaking)
  • AI-assisted (Hermes Agent)

Changes Made

  • src/auto-reply/reply/groups.ts: Added chatTypeLabel, destinationLabel, participantLabel, sameDestinationLabel, and taskLabel variables derived from ChatType. All group-chat-specific wording in the prompt now uses these labels, so ChatType: "channel" renders "channel" throughout. Also made buildGroupIntro ChatType-aware so the activation line uses "channel message" for channel sessions.
  • src/auto-reply/reply/groups.test.ts: Added comprehensive test verifying correct wording for both ChatType: "channel" and ChatType: "group" across all prompt sections, including message_tool_only mode. Added test for buildGroupIntro channel/group wording.

How to Test

  1. node scripts/run-vitest.mjs run src/auto-reply/reply/groups.test.ts — all 8 tests pass
  2. grep -n 'chatTypeLabel\|destinationLabel\|participantLabel' src/auto-reply/reply/groups.ts — confirms label variables at lines 242–246

Real behavior proof

  • Behavior addressed: The buildGroupChatContext prompt unconditionally used "group chat" wording for all non-DM conversations, including public channels where ChatType is "channel". The buildGroupIntro activation line unconditionally used "every group message" for always-on activation. This affected the intro line, destination references, participant labels, task labels, visible-response guidance, and first-turn activation intro throughout the entire prompt.
  • Environment tested: macOS 26.4.1, Node 22, OpenClaw branch fix/mattermost-channel-intro-wording (commit a69e7ac2)
  • Steps run after the patch: (1) Ran node scripts/run-vitest.mjs run src/auto-reply/reply/groups.test.ts — 8/8 pass. (2) Called buildGroupChatContext and buildGroupIntro from production source for channel and group modes.
  • Evidence after fix:
    $ node scripts/run-vitest.mjs run src/auto-reply/reply/groups.test.ts
     ✓  auto-reply  src/auto-reply/reply/groups.test.ts (8 tests) 41ms
     Test Files  1 passed (1)
          Tests  8 passed (8)
    
    $ node --import tsx -e "
    const groups = require('./src/auto-reply/reply/groups.ts');
    console.log('=== buildGroupIntro ChatType=channel, always ===');
    console.log(groups.buildGroupIntro({ cfg: {}, sessionCtx: { ChatType: 'channel', Provider: 'mattermost' }, defaultActivation: 'always', silentToken: 'NO_REPLY' }));
    console.log('');
    console.log('=== buildGroupIntro ChatType=group, always ===');
    console.log(groups.buildGroupIntro({ cfg: {}, sessionCtx: { ChatType: 'group', Provider: 'mattermost' }, defaultActivation: 'always', silentToken: 'NO_REPLY' }));
    "
    === buildGroupIntro ChatType=channel, always ===
    Activation: always-on (you receive every channel message). Address the specific sender noted in the message context.
    
    === buildGroupIntro ChatType=group, always ===
    Activation: always-on (you receive every group message). Address the specific sender noted in the message context.
    
    $ node --import tsx -e "
    const groups = require('./src/auto-reply/reply/groups.ts');
    const ch = groups.buildGroupChatContext({ sessionCtx: { ChatType: 'channel', Provider: 'mattermost' }, silentReplyPolicy: 'allow', silentToken: 'NO_REPLY' });
    console.log('Channel prompt contains group chat?', ch.includes('group chat'));
    console.log('Channel prompt contains channel?', ch.includes('channel'));
    "
    Channel prompt contains group chat? false
    Channel prompt contains channel? true
    
  • Observed result after fix: All three modes produce correct wording. The channel prompt contains zero instances of "group chat" or "group" (except "the channel gets a responsive path" which is correct). The group prompt contains zero instances of "channel". The buildGroupIntro activation line correctly uses "channel message" for channel sessions and "group message" for group sessions. 8/8 vitest assertions pass covering all wording variants.
  • What was not tested: Live Mattermost channel interaction — the change is string interpolation in pure functions exercised through the production source path; no live platform needed.

@clawsweeper

clawsweeper Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as duplicate/superseded: #96244 already fixed the central opener/delivery wording on current main, and #95762 is the cleaner open, proof-positive, mergeable PR for the remaining full-prompt and activation wording this branch adds.

Root-cause cluster
Relationship: superseded
Canonical: #95762
Summary: This PR is superseded by a clean, proof-positive sibling for the same remaining full-prompt channel wording while current main already contains the merged opener/delivery fix.

Members:

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

Canonical path: Close this conflicting branch and route the remaining full-prompt channel wording review to #95762 while keeping #96244 as the merged current-main base.

So I’m closing this here and keeping the remaining discussion on #95762 and #96244.

Review details

Best possible solution:

Close this conflicting branch and route the remaining full-prompt channel wording review to #95762 while keeping #96244 as the merged current-main base.

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

Yes. Source inspection shows channel turns still enter the shared group/channel prompt helper, and current main still has some group-specific fragments in that channel path; I did not run a live Mattermost server in this read-only review.

Is this the best way to solve the issue?

No. This branch is no longer the best landing path because it conflicts with current main and #95762 is the clean, proof-positive sibling for the same remaining full-prompt and activation wording.

Security review:

Security review cleared: The patch changes only prompt wording logic and colocated tests, with no dependency, workflow, lockfile, script, auth, secret, or package metadata changes.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • arkyu2077: Authored the merged PR that put the accepted opener/delivery channel wording fix onto current main. (role: canonical fix author; confidence: high; commits: 9e3a917d9ee0; files: src/auto-reply/reply/groups.ts, src/auto-reply/reply/groups.test.ts, src/auto-reply/reply.triggers.group-intro-prompts.cases.ts)
  • vincentkoc: Merged the canonical PR and authored follow-up commits in that PR for channel tool-only guidance, fixtures, and snapshots. (role: recent area contributor and merger; confidence: high; commits: 9eb1073364b8, 89187a57872d, 44c003f73ffb; files: src/auto-reply/reply/groups.ts, src/auto-reply/reply/groups.test.ts, src/auto-reply/reply.triggers.group-intro-prompts.cases.ts)
  • Tyler Yust: History traces the persistent group prompt context wiring that this bug narrows to the nested subagent orchestration work. (role: introduced prompt behavior; confidence: medium; commits: b8f66c260db8; files: src/auto-reply/reply/groups.ts, src/auto-reply/reply/get-reply-run.ts)
  • lin-hongkuan: Current blame for the helper and caller lines points at the latest main snapshot/import commit, so this is a weak recent-routing signal rather than original ownership. (role: recent source snapshot contributor; confidence: low; commits: 67118d5ab912; files: src/auto-reply/reply/groups.ts, src/auto-reply/reply/get-reply-run.ts)

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

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jun 22, 2026
@liuhao1024

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 23, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@liuhao1024
liuhao1024 force-pushed the fix/mattermost-channel-intro-wording branch 3 times, most recently from 564c07d to 10c2523 Compare June 23, 2026 19:37
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Jun 23, 2026
@liuhao1024
liuhao1024 force-pushed the fix/mattermost-channel-intro-wording branch from 10c2523 to 472a5f4 Compare June 23, 2026 21:35
@liuhao1024

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 23, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 24, 2026
@liuhao1024

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

…nclaw#95645)

buildGroupChatContext previously rendered 'group chat' for all non-DM
conversations, including public channels where ChatType is 'channel'.
This contradicted the authoritative inbound-meta block which reports
chat_type: 'channel', causing agents to misidentify public channels as
group chats.

Use the actual ChatType to pick 'channel' or 'group chat' in the intro
line. Add a test that verifies correct wording for both ChatType values.

Fixes openclaw#95645
…channel

ClawSweeper P2: the previous commit only changed the first sentence.
This extends ChatType-aware labels (destinationLabel, participantLabel,
sameDestinationLabel, taskLabel) through delivery, participant, task,
and no-visible-response guidance. Strengthens test to forbid residual
group-chat fragments for ChatType: channel.
buildGroupIntro unconditionally used 'every group message' even when
ChatType was 'channel'. Now uses 'every channel message' for channel
sessions, matching the ChatType-aware behavior already in
buildGroupChatContext.

- Add ChatType check to buildGroupIntro
- Add test covering channel/group/mention activation modes
@liuhao1024
liuhao1024 force-pushed the fix/mattermost-channel-intro-wording branch from 472a5f4 to a69e7ac Compare June 24, 2026 03:49
@liuhao1024

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 24, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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 Jun 24, 2026
@clawsweeper clawsweeper Bot closed this Jun 28, 2026
@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper autoclose is complete.

Reason: structured ClawSweeper close marker: close-required (sha=a69e7ac29960ba9eb1253e5cce6350b83ac8ec5b)

Closed:

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

Labels

merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

Mattermost: intro prose calls public/private channels a "group chat", contradicting the authoritative chat_type

1 participant