Skip to content

fix: identify Mattermost channels as channels in prompts - #96186

Closed
samrusani wants to merge 2 commits into
openclaw:mainfrom
samrusani:fix-mattermost-channel-prompt
Closed

samrusani wants to merge 2 commits into
openclaw:mainfrom
samrusani:fix-mattermost-channel-prompt

Conversation

@samrusani

@samrusani samrusani commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #95645

What Problem This Solves

Fixes an issue where users in a Mattermost public channel would get prompt guidance that called the conversation a group chat even though OpenClaw's trusted metadata identifies it as chat_type: "channel".

Why This Change Was Made

The shared group/channel prompt context now derives its destination, participant, task, visible-response, and activation wording from the normalized ChatType, so channel contexts consistently say channel while actual group chats keep the existing group-chat wording. The deeper Mattermost target-inference/session-routing work from #95646 is intentionally left out of scope.

User Impact

Agents in Mattermost public channels get a consistent channel signal across the system prompt, reducing the chance that they choose group when a tool or response path needs the current chat type.

Evidence

  • Direct local production-helper probe:

    node --import tsx --input-type=module -e 'const { buildGroupChatContext, buildGroupIntro } = await import("./src/auto-reply/reply/groups.ts"); const sessionCtx = { ChatType: "channel", Provider: "mattermost" }; const combined = [buildGroupChatContext({ sessionCtx }), buildGroupChatContext({ sessionCtx, sourceReplyDeliveryMode: "message_tool_only" }), buildGroupIntro({ cfg: {}, sessionCtx, defaultActivation: "always", silentToken: "NO_REPLY" })].join("\n"); console.log(combined); for (const fragment of ["Mattermost group chat", "this group chat", "same group", "group participant", "group response", "group message"]) console.log(`${fragment}=${combined.includes(fragment)}`);'

    Key output:

    You are in a Mattermost channel.
    If no visible channel response is needed, do not call message(action=send).
    Your normal final answer stays private and will not be posted to this channel.
    Activation: always-on (you receive every channel message).
    Mattermost group chat=false
    this group chat=false
    same group=false
    group participant=false
    group response=false
    group message=false
    
  • Rebased onto current origin/main at 3811001d27 and force-pushed head 431d38d9a0.

  • Resolved the outdated Codex review thread after verifying the current channel prompt no longer contains the reported group wording.

  • node scripts/run-vitest.mjs src/auto-reply/reply/groups.test.ts src/auto-reply/reply.triggers.group-intro-prompts.test.ts - 2 Vitest shards passed, 13 tests passed.

  • CI=true pnpm prompt:snapshots:gen - wrote 7 prompt snapshot files during conflict resolution.

  • CI=true pnpm prompt:snapshots:check - prompt snapshots are current, 7 files.

  • ./node_modules/.bin/oxfmt --check --threads=1 src/auto-reply/reply/groups.ts src/auto-reply/reply/groups.test.ts src/auto-reply/reply.triggers.group-intro-prompts.test.ts src/auto-reply/reply.triggers.group-intro-prompts.cases.ts - passed.

  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.json src/auto-reply/reply/groups.ts src/auto-reply/reply/groups.test.ts src/auto-reply/reply.triggers.group-intro-prompts.test.ts src/auto-reply/reply.triggers.group-intro-prompts.cases.ts - passed.

  • git diff --check - passed.

Not tested: live Mattermost server. The issue was source-reproduced, and the generated prompt output was verified locally after the patch.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c816ff50e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/auto-reply/reply/groups.ts Resolved
@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 30, 2026, 9:29 PM ET / 01:29 UTC.

Summary
The branch makes shared group/channel prompt wording derive labels from ChatType and updates Mattermost channel prompt tests plus one Codex prompt snapshot.

PR surface: Source +42, Tests +38. Total +80 across 5 files.

Reproducibility: yes. Source inspection shows Mattermost public channels map to ChatType: "channel", get-reply-run sends channel contexts through the shared group prompt helpers, and current main still has residual group-only participant/task/activation wording on that path.

Review metrics: 1 noteworthy metric.

  • Prompt label fields: 9 fields introduced. The new helper drives model-facing conversation, delivery target, participant, task, visibility, destination, and activation wording, so maintainers should notice the breadth before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #95645
Summary: This PR is a candidate broader follow-up for the Mattermost prompt wording issue; a merged sibling fixed the opener/delivery subset, while this branch and an open sibling cover broader participant/task/activation wording.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Maintainers should choose this PR or an equivalent sibling as the canonical wording branch before merge.

Risk before merge

  • [P1] The diff changes model-facing delivery, visibility, delegated-task, and activation guidance for every trusted ChatType: "channel" surface that uses the shared helper, not only Mattermost.
  • [P1] Open sibling fix(mattermost): channel prompts describe rooms as group chats #95762 targets the same residual prompt wording, so maintainers should choose one canonical branch before landing more overlapping prompt copy changes.

Maintainer options:

  1. Land one canonical wording branch
    Choose this clean rebased branch or an equivalent sibling as the canonical prompt wording follow-up, then close the remaining overlapping PRs.
  2. Accept the broader channel wording
    If maintainers want all shared channel prompt fragments to follow trusted ChatType, merge after normal CI and owner review.
  3. Stop at the merged subset
    If the opener and delivery subset from the merged PR is the desired product boundary, close this PR and same-root siblings without landing broader prompt copy changes.

Next step before merge

  • [P2] No automated code repair remains; the next action is maintainer selection of the canonical wording branch among overlapping prompt PRs.

Security
Cleared: The diff changes prompt strings, tests, and a markdown prompt snapshot only; it does not touch dependencies, workflows, lockfiles, scripts, auth, secrets, or package metadata.

Review details

Best possible solution:

Land one canonical ChatType-aware shared-chat prompt helper that preserves true group wording for group chats and channel wording for trusted channel contexts, then close the overlapping sibling PRs against that landed path.

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

Yes. Source inspection shows Mattermost public channels map to ChatType: "channel", get-reply-run sends channel contexts through the shared group prompt helpers, and current main still has residual group-only participant/task/activation wording on that path.

Is this the best way to solve the issue?

Yes, with a maintainer-selection caveat. Deriving all shared prompt labels from trusted ChatType in the source helper is narrow and maintainable, but maintainers should choose one canonical branch among the overlapping PRs before merge.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority Mattermost/channel prompt correctness fix with limited blast radius but real user-visible channel guidance impact.
  • merge-risk: 🚨 message-delivery: The diff changes model-facing instructions for visible channel replies, private finals, message-tool use, and channel-visible updates.
  • merge-risk: 🚨 session-state: The prompt wording influences whether agents preserve the trusted channel chat type instead of choosing a wrong group namespace for downstream tool/session behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes terminal-style output from a production-helper prompt probe showing after-fix Mattermost channel wording and negative checks for former group fragments.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal-style output from a production-helper prompt probe showing after-fix Mattermost channel wording and negative checks for former group fragments.
Evidence reviewed

PR surface:

Source +42, Tests +38. Total +80 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 59 17 +42
Tests 3 46 8 +38
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 105 25 +80

What I checked:

  • Current main still has residual group wording: buildGroupChatContext on current main already uses channel for the opener and destination subset, but still emits group participant, group-chat task, group-visible updates, and group message for channel contexts. (src/auto-reply/reply/groups.ts:264, 1241885db6ad)
  • Shared caller routes channels through the group helpers: get-reply-run treats both ChatType === "group" and ChatType === "channel" as shared chats, then calls buildGroupChatContext and buildGroupIntro. (src/auto-reply/reply/get-reply-run.ts:568, 1241885db6ad)
  • Mattermost public channels map to channel metadata: Mattermost channel type O maps to channel, and the inbound websocket test asserts a public channel event dispatches ChatType equal to channel. (extensions/mattermost/src/mattermost/monitor-gating.ts:4, 1241885db6ad)
  • PR head centralizes the prompt labels: The PR head replaces the noun-only helper with resolveSharedChatPromptLabels, carrying channel/group labels through conversation, reply target, attachment target, participant, delegated task, visible update, visible response, destination, and activation message wording. (src/auto-reply/reply/groups.ts:224, 431d38d9a027)
  • PR regression coverage checks the full channel path: The added test combines normal, message-tool-only, and first-turn intro output for a Mattermost channel and rejects the former group-specific fragments. (src/auto-reply/reply/groups.test.ts:119, 431d38d9a027)
  • Latest release still has the residual wording: The latest release tag v2026.6.11 points at a tree that still contains the residual group participant, delegated-task, and activation wording, so the broader fix has not shipped. (src/auto-reply/reply/groups.ts:264, e085fa1a3ffd)

Likely related people:

  • tyler6204: Commit history for the shared group-chat prompt context points to the nested-subagent orchestration work that added persistent group chat context to the system prompt. (role: introduced prompt behavior; confidence: high; commits: b8f66c260db8; files: src/auto-reply/reply/groups.ts, src/auto-reply/reply/get-reply-run.ts)
  • vincentkoc: Vincent co-authored the current-main partial channel wording fix and has recent release/main activity in the same prompt helper and tests. (role: recent area contributor; confidence: high; commits: 9e3a917d9ee0, 89187a57872d, 9eb1073364b8; files: src/auto-reply/reply/groups.ts, src/auto-reply/reply/groups.test.ts, src/auto-reply/reply.triggers.group-intro-prompts.cases.ts)
  • arkyu2077: Opened the merged same-surface PR that current main carries for the opener and delivery subset of the Mattermost channel prompt wording fix. (role: recent adjacent contributor; confidence: medium; commits: 9e3a917d9ee0; files: src/auto-reply/reply/groups.ts, src/auto-reply/reply/groups.test.ts)
  • steipete: Commit history ties the Mattermost private-channel-as-group routing semantics to adjacent Mattermost chat-type work, which explains the nearby group versus channel distinction this prompt fix depends on. (role: adjacent Mattermost chat-type contributor; confidence: medium; commits: 355b4c62bcc2, ea018a68ccb9; files: extensions/mattermost/src/mattermost/monitor.ts, src/auto-reply/reply/get-reply-run.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@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. P2 Normal backlog priority with limited blast radius. 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. labels Jun 24, 2026
@samrusani

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Pushed 21418a1615 with the channel wording carried through the shared prompt helper and first-turn intro. I also updated the PR body with the focused validation and direct prompt-output probe.

@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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed 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
@samrusani
samrusani force-pushed the fix-mattermost-channel-prompt branch from 21418a1 to d93714f Compare June 24, 2026 18:45
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Jun 24, 2026
@samrusani

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased on current main and force-pushed d93714f46e. The PR body now has the rerun validation and current prompt-output probe for the full channel wording fix.

@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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 24, 2026
@samrusani
samrusani force-pushed the fix-mattermost-channel-prompt branch from 06bd3a1 to 431d38d Compare June 30, 2026 22:32
@samrusani

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main and force-pushed head 431d38d. I also resolved the outdated Codex review thread after verifying the current channel prompt carries channel wording through the shared prompt helper and first-turn intro.

Validation:

  • node scripts/run-vitest.mjs src/auto-reply/reply/groups.test.ts src/auto-reply/reply.triggers.group-intro-prompts.test.ts - 2 Vitest shards passed, 13 tests passed
  • CI=true pnpm prompt:snapshots:gen - regenerated prompt snapshots during the rebase conflict resolution
  • CI=true pnpm prompt:snapshots:check - prompt snapshots are current, 7 files
  • ./node_modules/.bin/oxfmt --check --threads=1 src/auto-reply/reply/groups.ts src/auto-reply/reply/groups.test.ts src/auto-reply/reply.triggers.group-intro-prompts.test.ts src/auto-reply/reply.triggers.group-intro-prompts.cases.ts
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.json src/auto-reply/reply/groups.ts src/auto-reply/reply/groups.test.ts src/auto-reply/reply.triggers.group-intro-prompts.test.ts src/auto-reply/reply.triggers.group-intro-prompts.cases.ts
  • git diff --check

The PR body evidence section is updated with this refresh.

@clawsweeper

clawsweeper Bot commented Jun 30, 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: 🐚 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 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. labels Jun 30, 2026
@vincentkoc vincentkoc self-assigned this Jul 2, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Thanks for tightening the remaining shared-chat wording and for refreshing the proof. The reported #95645 contradiction was fixed by #96244 in 9e3a917d9ee0032b89c425cb1847825930c4df63: the authoritative conversation declaration and delivery destination now follow ChatType, so a Mattermost public channel no longer says You are in a Mattermost group chat.

I rechecked current main with the production prompt helpers and the focused unit/e2e owners: the channel declaration/destination probe passes, and 28/28 tests pass. This branch goes further by changing participant, delegated-task, update, and activation copy across every trusted channel surface. #95645 explicitly treated those remaining uses as colloquial guidance rather than the chat-type declaration bug, so we are stopping at the narrower landed product boundary.

Closing as broader follow-up work not planned, not as an exact duplicate or an assertion that every changed string already landed. Thanks @samrusani for the careful branch refresh and regression work.

@vincentkoc vincentkoc closed this Jul 2, 2026
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: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

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

2 participants