Skip to content

fix(think): resolve messenger self-mentions#1920

Open
cjol wants to merge 1 commit into
mainfrom
fix/jul9-1850-slack-self-mention
Open

fix(think): resolve messenger self-mentions#1920
cjol wants to merge 1 commit into
mainfrom
fix/jul9-1850-slack-self-mention

Conversation

@cjol

@cjol cjol commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This PR rewrites Think messenger self-mentions before they reach the model. It replaces the bot's own unresolved raw user-id mention with the configured bot handle in Chat SDK messenger events.

Why

  • Mention-triggered messenger messages can start with the bot's own platform id, for example @U0BD9EYL52S, after adapters resolve other users to readable names.
  • Small models can misread that unresolved id as a third party the sender wanted to contact, rather than as the bot mention that triggered the event.
  • The existing userName messenger option already represents the readable bot handle, so the fix can reconstruct @<userName> without adding configuration.
  • Rewriting is limited to adapters that expose botUserId; handle-based adapters already produce readable mentions and are left unchanged.

Public API Surface

Symbol Kind Notes
resolveSelfMention Function Additive export from @cloudflare/think/messengers that rewrites <@id>, <@!id>, and bare @id self-mentions to @<userName>.

Code Changes

  • defaultChatSdkEvent now normalizes the message once, rewrites the bot self-mention, and passes the rewritten message into the messenger event.
  • resolveSelfMention handles Slack and Discord angle-bracket mention forms plus the bare @id form some adapters normalize to.
  • Messenger docs explain why self-mentions are rewritten and when the behavior applies.
  • The changeset marks this as a patch fix for @cloudflare/think.

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 03e5e8e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/think Patch
@cloudflare/agent-think Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Jul 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@1920

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@1920

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@1920

create-think

npm i https://pkg.pr.new/create-think@1920

hono-agents

npm i https://pkg.pr.new/hono-agents@1920

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@1920

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@1920

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@1920

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@1920

commit: 03e5e8e

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.

Slack messenger: the bot's own @mention reaches the model as a raw @U… id token (self-mention is never resolved or stripped)

1 participant