Repository navigation
feat(channels): expose what the sender wrote on Telegram messages - #399
Merged
Merged
Conversation
The Telegram channel wraps the sender's text in JSON with sender and message metadata before it reaches hooks, so a hook that searches or indexes messages can only get the text back by parsing that JSON. ChannelMessage now carries the text in an optional `text` field, which batching joins like the content. The model-facing content is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fengzdadi
added a commit
to Fengzdadi/powercontext
that referenced
this pull request
Nov 12, 2026
Bub sets `text` to None when `content` is what the sender wrote (bubbuild/bub#399). Fall back to `content` only then, so an empty `text` skips recall instead of recalling the JSON envelope with its metadata and replied-to message.
hidb4ai
added a commit
to oceanbase/powercontext
that referenced
this pull request
Nov 13, 2026
* fix(bub): recall with the inbound message, not Bub's framed prompt Bub's builtin build_prompt prefixes each channel message with its context and the time, which outweighs the user's words in lexical recall. The plugin now takes the recall text from the inbound message in load_state, before that framing, and keeps the model request unchanged. * fix(bub): map each built prompt to its inbound text for recall Bub drains steered follow-ups into a running turn through build_prompt without load_state, so the per-turn recall text went stale. The plugin now implements build_prompt at tryfirst priority, delegates to the other implementations in Bub's resolution order, and records the inbound text (ChannelMessage.text when set, else content) for each built prompt. before_llm_call recalls with the text of the latest user message. * fix(bub): match multi-part prompts and guard delegated build_prompt The turn's message reaches the model through Bub's legacy prompt form, which joins text parts with newlines, so record the recall text under that form too. A plugin delegating build_prompt the same way would call back into this one without end; return None when re-entered so the delegation continues with the remaining implementations. * fix(bub): skip recall for an explicitly empty sender text Bub sets `text` to None when `content` is what the sender wrote (bubbuild/bub#399). Fall back to `content` only then, so an empty `text` skips recall instead of recalling the JSON envelope with its metadata and replied-to message. --------- Co-authored-by: hidb4ai <oceanbasememory@126.com>
100gle
pushed a commit
to 100gle/bub
that referenced
this pull request
Nov 14, 2026
…bbuild#399) The Telegram channel wraps the sender's text in JSON with sender and message metadata before it reaches hooks, so a hook that searches or indexes messages can only get the text back by parsing that JSON. ChannelMessage now carries the text in an optional `text` field, which batching joins like the content. The model-facing content is unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
The Telegram channel builds each message's
contentas JSON: the sender's text undermessage, next to sender and message metadata (message_id,username,sender_id,date,reply_to_message, ...). That is what the model should see, but a hook that searches or indexes messages also gets only that JSON. To recover what the user wrote, it has to parse the JSON back out.PowerContext's Bub plugin hit this case. It recalls memory with the inbound message's text, read in
load_statebeforebuild_promptframes it. For Telegram, the JSON metadata outweighs the user's words in lexical recall. In the review of oceanbase/powercontext#2488, @PsiACE suggested exposing the searchable text before JSON wrapping instead of parsing it.ChannelMessagegets an optionaltextfield: what the sender wrote, whencontentwraps it with channel metadata.None, the default, meanscontentis that text, so other channels and existing constructors are unchanged.TelegramChannel._build_messagesetstextto the parsed message text. That is the same string that goes undermessagein the JSON, so it excludes the replied-to message.ChannelMessage.from_batchjoinstextthe same way it joinscontent. A message withouttextcontributes itscontent, and the batch'stextstaysNonewhen no message has one.content, the prompt, and the tape are unchanged. Commands keep returning before the JSON wrapping, withouttext.Impacted modules
src/bub/channels/message.pysrc/bub/channels/telegram.pytests/test_channels.pyVerification
make check: lock check, prek (ruff, ruff format), and mypy passed.uv run pytest -q: 730 passed, 20 skipped.test_telegram_channel_build_message_wraps_payload_and_disables_outboundchecks thattextis the sender's text.test_channel_message_batch_joins_text_and_falls_back_to_contentchecks batching.🤖 Generated with Claude Code