Skip to content

fix(think): telegramMessenger nativeStreaming option (#2397) - #2414

Merged
threepointone merged 3 commits into
mainfrom
fix-2397-telegram-native-streaming
Sep 29, 2026
Merged

threepointone merged 3 commits into
mainfrom
fix-2397-telegram-native-streaming

Conversation

@threepointone

@threepointone threepointone commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2397.

The problem

@chat-adapter/telegram 4.38 made native draft streaming opt-in through TelegramAdapterConfig.nativeStreaming (default false). telegramMessenger builds the adapter itself and didn't forward the option, so with 4.38+ private-chat replies always posted a placeholder and edited it, with no way to turn drafts back on.

The same adapter versions throw at construction in webhook mode when there's no secretToken, unless allowUnverifiedWebhooks is set. So telegramMessenger({ verifyWebhook: false }) and custom verifyWebhook functions without a secret threw secretToken is required in webhook mode.

What changed

  • TelegramMessengerOptions.nativeStreaming?: boolean, forwarded to createTelegramAdapter.
  • allowUnverifiedWebhooks: !options.secretToken is passed to the adapter. Think already refuses a webhook with neither a secret token nor an explicit verifyWebhook, so this only applies when Think verifies the webhook itself or the caller opted out.
  • Both fields are typed through a local compat type, so Think keeps its ^4.29.0 adapter range. Older adapters ignore the extra fields. There's no dependency bump, so the chat 4.41 drainQueue signature change mentioned in the issue doesn't come into play here.
  • docs/think/messengers.md documents the option.

Based on the reference implementation in harryy2510#1. Thanks @harryy2510.

Tests

telegram-messenger.test.ts checks that nativeStreaming is forwarded (and left unset by default), and that allowUnverifiedWebhooks is false with a secret token and true with verifyWebhook: false. The full Think suite passes and pnpm run check is clean.


Devin Review

@changeset-bot

changeset-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b9badc1

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 found 1 potential issue.

Devin Review

Comment on lines +21 to +29
describe("telegram messenger adapter config (#2397)", () => {
it("forwards nativeStreaming to the adapter", () => {
telegramMessenger({
nativeStreaming: true,
secretToken: "secret",
token: "token",
userName: "fake_bot"
});
expect(lastAdapterConfig()).toMatchObject({ nativeStreaming: true });

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.

🔍 Adapter behavior remains untested

The lockfile installs Telegram adapter 4.31, which predates both new options. These assertions check forwarding, not native drafts or webhook construction under 4.38+.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional. Bumping the lockfile to chat/@chat-adapter/telegram 4.38+ changes the private Chat.prototype.drainQueue signature that Think's recovery drain (#2312) relies on (see #2397), so that belongs in a separate dependency-update PR. What Think controls here is the config it passes the adapter, which these tests cover; draft streaming and webhook validation are the adapter's own behaviour.

@agent-think

agent-think Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (bcb1f12f → b9badc10, workflow run)

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: b9badc1

@threepointone
threepointone merged commit 484f7ab into main Sep 29, 2026
10 checks passed
@threepointone
threepointone deleted the fix-2397-telegram-native-streaming branch September 29, 2026 21:30
@github-actions github-actions Bot mentioned this pull request Oct 2, 2026
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.

think: telegramMessenger can't enable native draft streaming (@chat-adapter/telegram >= 4.38 made it opt-in)

1 participant