Skip to content

fix(auto-reply): use a chat_type-neutral group/channel intro opener - #96069

Closed
iloveleon19 wants to merge 1 commit into
openclaw:mainfrom
iloveleon19:fix/group-intro-chat-type-collision
Closed

iloveleon19 wants to merge 1 commit into
openclaw:mainfrom
iloveleon19:fix/group-intro-chat-type-collision

Conversation

@iloveleon19

@iloveleon19 iloveleon19 commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves #95645.

buildGroupChatContext is built for both group and channel ChatTypes (the caller gates on isGroupChat = ChatType === "group" || ChatType === "channel" in get-reply-run), but its opener hard-coded:

You are in a <provider> group chat.

For a public channel the authoritative inbound-meta block reports chat_type: "channel", while "group" denotes a private channel / group DM. So the natural-language opener contradicts the trusted metadata, and "group chat" is the more salient signal. Agents key off it and emit chat_type: group (or --chat-type group to tools) for a public channel.

Because session keys are namespaced …:mattermost:<direct|channel|group>:<peerId>:thread:<root>, a wrong group for a public channel addresses a non-existent session and breaks downstream routing.

Fix

Reword the opener so it no longer declares a chat_type:

-  lines.push(`You are in a ${providerLabel} group chat.`);
+  lines.push(`You are in a shared ${providerLabel} chat (not a 1:1 DM).`);

This is the neutral wording proposed in the issue. It is provider-agnostic — buildGroupChatContext is shared by all providers, and "shared chat (not a 1:1 DM)" holds for every non-DM conversation this intro fires for. The remaining "group" mentions in the function ("be a good group participant", "…sent to this group chat") are colloquial role/delivery guidance, not a type declaration, so they are intentionally left unchanged.

Scope

Deliberately narrow: this is the system-prompt-intro half only. The deeper chat_type-derivation inconsistency for private channels (channel-type vs target-string inference) is tracked separately in #95646 and is not addressed here.

What changed

  • src/auto-reply/reply/groups.ts — neutral opener + rationale comment.
  • src/auto-reply/reply/groups.test.ts — updated expectation; new regression test asserting a public-channel (ChatType: "channel") context opens neutrally and never says "… group chat".
  • src/auto-reply/reply.triggers.group-intro-prompts.cases.ts — updated the Discord/WhatsApp/Telegram opener expectations (delivery-guidance text unchanged).
  • src/agents/prompt-composition.test.ts — updated the Slack group opener invariant.
  • test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/discord-group-codex-message-tool.md — regenerated via pnpm prompt:snapshots:gen (the opener change shifts the recorded char/token counts).

Evidence (after-fix, on a live deployment)

The one-line opener reword is running in production (applied over the deployed dist/get-reply-*.js).

1. Deployed opener — verbatim from the running container. The agent declines to quote its system prompt verbatim, so the rendered template is shown directly from dist (${providerLabel} is substituted at runtime, e.g. Mattermost); the old type-declaring opener is gone:

$ docker exec <gateway> sh -c "grep -rho 'You are in a shared.*1:1 DM)' /app/dist/get-reply-*.js | sort -u"
You are in a shared ${providerLabel} chat (not a 1:1 DM).

$ docker exec <gateway> sh -c "grep -hoc 'You are in a \${providerLabel} group chat' /app/dist/get-reply-*.js"
0

2. Public channel → chat_type: channel. The agent reads the trusted chat_type as channel and frames the venue as a shared chat that is not a 1:1 DM — no "group chat" type-word:

public channel turn

Q: report (1) the chat_type in your Inbound Context (trusted metadata), and (2) the opener describing this venue.
A: (1) chat_type is channel. (2) (declines to quote verbatim) … this is a shared Mattermost chat, not a 1:1 DM.

3. Private channel → chat_type: group. Same neutral opener; the agent reads the trusted chat_type as group. Confirms the opener no longer forces "group" wording and the type comes from trusted metadata:

private channel turn

A: (1) chat_type is group. (2) (declines to quote verbatim) … this is a shared Mattermost chat, not a 1:1 DM.

Before the fix the opener read You are in a <provider> group chat. for both of the above — which (per #95645) led agents to emit chat_type: group for a public channel, binding a non-existent group:<channelId> session and breaking threaded delivery.

CI: the Codex prompt snapshot was regenerated; prompt:snapshots:check and the auto-reply / prompt-composition tests pass on the current head.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS 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 Jun 23, 2026
@iloveleon19
iloveleon19 force-pushed the fix/group-intro-chat-type-collision branch from 07e6333 to 30ae5af Compare June 23, 2026 10:32
@clawsweeper

clawsweeper Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 23, 2026, 5:48 PM ET / 21:48 UTC.

Summary
The PR rewrites the shared non-DM auto-reply prompt opener to avoid declaring a group chat type and updates prompt tests and a Codex prompt snapshot.

PR surface: Source +6, Tests +16. Total +22 across 5 files.

Reproducibility: yes. source-level reproduction is high confidence: a Mattermost public channel maps to chat_type: channel, but current main still routes that context through an opener that says group chat; no live Mattermost run was performed in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #95645
Summary: this PR is a candidate fix for the prompt-intro half tracked by #95645, while #95646 remains adjacent work for deeper Mattermost chat_type inference.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until stronger real behavior proof is added.

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

Rank-up moves:

  • [P1] Add redacted real behavior proof for the Mattermost public-channel case, such as terminal output, logs, a recording, or a linked artifact showing the corrected chat_type: channel path.
  • Regenerate and commit the Codex prompt snapshot so prompt:snapshots:check passes.
  • Rerun or cite the focused prompt snapshot check and relevant auto-reply tests after the fixture is regenerated.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body claims a live deployment observation, but it does not attach inspectable redacted logs, terminal output, screenshots, recordings, or artifacts showing the after-fix Mattermost public-channel behavior; the contributor should add proof and redact private data, then update the PR body for re-review.

Risk before merge

  • [P1] The edited Codex prompt snapshot currently fails the repository snapshot check, so merging as-is would leave generated prompt fixtures inconsistent with the generator output.
  • [P1] The PR body describes a live production observation, but no redacted logs, terminal output, screenshot, recording, or linked artifact are attached for reviewer inspection.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the neutral opener change, regenerate the Codex prompt snapshots from the repository generator, and add redacted real-behavior proof for a Mattermost public-channel turn before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] A maintainer or contributor needs to provide inspectable real-behavior proof and fix the generated snapshot drift before this otherwise narrow bug fix can merge.

Security
Cleared: The diff only changes prompt wording, tests, and a prompt snapshot; no secrets, dependencies, workflows, install scripts, or code-execution supply-chain surfaces are changed.

Review findings

  • [P2] Regenerate the prompt snapshot fixture — test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/discord-group-codex-message-tool.md:453
Review details

Best possible solution:

Keep the neutral opener change, regenerate the Codex prompt snapshots from the repository generator, and add redacted real-behavior proof for a Mattermost public-channel turn before merge.

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

Yes, source-level reproduction is high confidence: a Mattermost public channel maps to chat_type: channel, but current main still routes that context through an opener that says group chat; no live Mattermost run was performed in this read-only review.

Is this the best way to solve the issue?

Yes, the neutral shared-chat opener is the best narrow fix for issue #95645 because it removes the type collision without changing the separate Mattermost target-inference work tracked in #95646; the branch still needs generated snapshot repair and real proof before merge.

Full review comments:

  • [P2] Regenerate the prompt snapshot fixture — test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/discord-group-codex-message-tool.md:453
    The PR edits this Codex prompt snapshot, but prompt:snapshots:check reports the file differs from generated output. Please regenerate and commit the canonical snapshot output so the fixture matches the repository generator instead of carrying a hand-edited drift.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.84

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 🛠️ actively grinding: The PR author has acted after the latest ClawSweeper review and work remains. Needs stronger real behavior proof before merge: The PR body claims a live deployment observation, but it does not attach inspectable redacted logs, terminal output, screenshots, recordings, or artifacts showing the after-fix Mattermost public-channel behavior; the contributor should add proof and redact private data, then update the PR body for re-review.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 🛠️ actively grinding.
  • remove proof: 📸 screenshot: Current real behavior proof evidence kind is none.

Label justifications:

  • P2: This is a normal-priority fix for a source-reproducible agent/channel routing prompt bug with limited blast radius and clear remaining merge blockers.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 🛠️ actively grinding: The PR author has acted after the latest ClawSweeper review and work remains. Needs stronger real behavior proof before merge: The PR body claims a live deployment observation, but it does not attach inspectable redacted logs, terminal output, screenshots, recordings, or artifacts showing the after-fix Mattermost public-channel behavior; the contributor should add proof and redact private data, then update the PR body for re-review.
Evidence reviewed

PR surface:

Source +6, Tests +16. Total +22 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 11 5 +6
Tests 3 20 4 +16
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 31 9 +22

Acceptance criteria:

  • [P1] prompt:snapshots:check after regenerating Codex prompt snapshots.
  • [P1] Focused auto-reply prompt tests covering buildGroupChatContext for ChatType: "channel".
  • [P1] Redacted live Mattermost public-channel proof showing the agent preserves chat_type: channel.

What I checked:

Likely related people:

  • tyler6204: Commit b8f66c260db8fd36f48d9c112d825df8cd014f69 touched the auto-reply group context and related get-reply path while adding group-chat orchestration prompt behavior. (role: introduced prompt behavior; confidence: medium; commits: b8f66c260db8; files: src/auto-reply/reply/groups.ts, src/auto-reply/reply/get-reply-run.ts)
  • Peter Steinberger: Commit 355b4c62bcc2f33a502121edcb7467fef7066df7 is related to Mattermost private-channel routing as group, which is adjacent to the channel/group chat_type semantics involved here. (role: adjacent Mattermost routing contributor; confidence: medium; commits: 355b4c62bcc2; files: extensions/mattermost/src/mattermost/monitor.ts)
  • BlueBirdBack: The Mattermost private-channel routing commit credits @BlueBirdBack, making them relevant to adjacent Mattermost chat_type semantics rather than this prompt-only PR. (role: adjacent source contributor; confidence: low; commits: 355b4c62bcc2; files: extensions/mattermost/src/mattermost/monitor.ts)
  • Vincent Koc: Current blame around the touched prompt files points through broad recent commit 273eed4c51cb39545ee82a9c864891d9421980fc, so this is a recent-area signal rather than proof of original authorship. (role: recent area contributor; confidence: low; commits: 273eed4c51cb; files: src/auto-reply/reply/groups.ts, src/agents/prompt-composition.test.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 rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 23, 2026
buildGroupChatContext runs for both `group` and `channel` ChatTypes (see
get-reply-run's isGroupChat), but its opener hard-coded "You are in a
<provider> group chat." For a public channel the authoritative inbound
chat_type is "channel", while "group" denotes a private channel / group
DM, so the prose contradicts the trusted metadata. Agents key off the
louder "group chat" wording and emit chat_type=group for a public
channel, which addresses a non-existent group:<id> session and
misroutes or loses replies.

Reword the opener to "You are in a shared <provider> chat (not a 1:1
DM)." so it no longer declares a chat_type. Delivery/role guidance keeps
its colloquial "group" wording, which is advice, not a type claim. The
phrasing is provider-agnostic: it holds for every non-DM provider this
intro fires for. Updates the affected unit/case/snapshot expectations and
adds a public-channel regression test.

Resolves openclaw#95645. Leaves the deeper chat_type derivation work to openclaw#95646.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@iloveleon19
iloveleon19 force-pushed the fix/group-intro-chat-type-collision branch from 30ae5af to 9e03125 Compare June 24, 2026 01:30
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Jun 24, 2026
iloveleon19 added a commit to iloveleon19/openclaw that referenced this pull request Jun 24, 2026
iloveleon19 added a commit to iloveleon19/openclaw that referenced this pull request Jun 24, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. labels Jun 24, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Jun 27, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. 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. labels Jun 27, 2026
@iloveleon19

Copy link
Copy Markdown
Contributor Author

Superseded by #96244, which landed the same neutral-opener change and closed #95645. The fix is already in main, so this PR is redundant (and now conflicts) — closing. Thanks @arkyu2077.

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

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains.

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