Skip to content

feat(telegram): add a persistThreadHistory option - #1098

Merged
bensabic merged 2 commits into
mainfrom
b/telegram-persist-thread-history
Oct 27, 2026
Merged

bensabic merged 2 commits into
mainfrom
b/telegram-persist-thread-history

Conversation

@bensabic

Copy link
Copy Markdown
Collaborator

This picks up #1079 from @mlenczewski-tidio. That PR comes from a fork owned by the tidio-tools organization, and GitHub doesn't let maintainers push to organization-owned forks, so we couldn't update it in place. Their commit is kept with their authorship and sign-off, and a second commit adds the follow-up changes. The branch is rebased onto main, which resolves the merge conflict in packages/adapter-telegram/src/subclass.test-d.ts with the new long message tests.

The Telegram adapter copied every incoming message into the Chat state adapter, and persistThreadHistory was typed as the literal true, so neither config nor a subclass could turn it off. An app that keeps its own transcript ended up with a second, unredacted copy of every message in the state store. This adds a persistThreadHistory option that defaults to true, and types the field as boolean so a subclass can override it.

const telegram = createTelegramAdapter({ persistThreadHistory: false });

With false, the SDK saves neither incoming messages nor the bot's own posts, so thread.messages and bot.history.thread.list() only see what the current process has cached. On serverless that's empty after a cold start. The Telegram docs, README, core history docs, and catalog entry now describe this.

New tests run a real Chat with the Telegram adapter and check what lands in state with the option on and off.

mlenczewski-tidio and others added 2 commits October 28, 2026 10:37
Telegram always copied every incoming message into the Chat state adapter,
and persistThreadHistory was typed as the literal `true`, so neither config
nor a subclass could turn it off. An app that keeps its own transcript ended
up with a second, unredacted copy of every message in the state store.

Add a persistThreadHistory config option, defaulting to true as before, and
type the field as boolean so a subclass can override it too.

Signed-off-by: Miłosz Lenczewski <m.lenczewski@tidio.net>
…ions

With persistThreadHistory set to false, the SDK stops saving the bot's own
posts as well as incoming messages. The changeset, docs page, README, and
JSDoc now say so, and the core history docs explain that Telegram uses the
thread cache by default and what bot.history.thread.list() returns when the
option is off. The catalog lists persistThreadHistory as a config-only
option, with a patch bump for @chat-adapter/catalog.

Add tests that run a real Chat with the Telegram adapter and check the
msg-history list in state: with the default it holds the incoming message
and the bot's reply, and with false it is empty. A runtime test covers a
subclass override, and the type test now asserts the base field is typed
boolean.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
@bensabic
bensabic requested a review from a team October 27, 2026 23:38
@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
chat Ready Ready Preview, v0 Oct 27, 2026 11:39pm UTC

@bensabic
bensabic merged commit 6300fe4 into main Oct 27, 2026
26 of 27 checks passed
@bensabic
bensabic deleted the b/telegram-persist-thread-history branch October 27, 2026 23:48

This branch was successfully deployed

1 active deployment
Preview — 7be0c4c3 Deployed Oct 27, 2026 by vercel[bot]
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.

2 participants