Skip to content

fix(telegram): keep over-limit-name models selectable in /model picker (#98221) - #98230

Closed
luoyanglang wants to merge 3 commits into
openclaw:mainfrom
luoyanglang:wolf/telegram-model-picker-index-callback
Closed

luoyanglang wants to merge 3 commits into
openclaw:mainfrom
luoyanglang:wolf/telegram-model-picker-index-callback

Conversation

@luoyanglang

@luoyanglang luoyanglang commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #98221

What Problem This Solves

The Telegram /model picker silently omits any model whose callback_data exceeds Telegram's 64-byte limit on both the standard (mdl_sel_{provider}/{model}) and compact (mdl_sel/{model}) encodings. The header reports the correct total (for example, "7 available") but fewer buttons render, with no error, warning, or placeholder. Long namespaced Ollama ids, increasingly common with community fine-tunes, become unreachable from the picker.

Why This Change Was Made

buildModelSelectionCallbackData embeds the full model name in the callback, so an arbitrarily long name cannot fit 64 bytes and buildModelsKeyboard dropped it (if (!callbackData) continue). The 64-byte ceiling is a hard Telegram limit, so this adds a length-safe provider/index callback resolved server-side against the same sorted list the keyboard was built from.

The latest follow-up also binds index callbacks to a compact model identity token. If the provider model list changes while an old keyboard is visible and the old index now points at a different model, the handler now asks the user to rerun /model instead of applying the wrong model.

User Impact

  • Long-named models are no longer dropped; every model in the reported count is selectable.
  • Short names keep their existing readable name-based callbacks.
  • Over-limit models render length-safe index callbacks (mdl_idx_{provider}_{index}_{token}).
  • Stale in-range index callbacks refresh instead of selecting a different current model.

Evidence

Local macOS validation against head 1f829039bc:

  • extensions/telegram/src/model-buttons.ts: index callbacks now include a compact identity token; resolveIndexedModelSelection rejects missing or token-mismatched indexes.
  • extensions/telegram/src/bot-handlers.runtime.ts: the callback handler resolves selectIndex through resolveIndexedModelSelection; missing or mismatched identity prompts That model list changed. Send /model again to refresh.
  • extensions/telegram/src/model-buttons.test.ts: added regression coverage for stale in-range index drift and token-bound over-limit callbacks.
  • RED/GREEN: the stale-index regression failed before the helper existed, then passed after the token guard.
  • node scripts/run-vitest.mjs extensions/telegram/src/model-buttons.test.ts — 29 tests passed.
  • node scripts/run-vitest.mjs extensions/telegram/src/model-buttons.test.ts extensions/telegram/src/bot.create-telegram-bot.test.ts extensions/telegram/src/bot.test.ts — 224 tests passed.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test — passed.
  • node scripts/run-oxlint.mjs extensions/telegram/src/model-buttons.ts extensions/telegram/src/model-buttons.test.ts extensions/telegram/src/bot-handlers.runtime.ts — passed.
  • pnpm exec oxfmt --check --threads=1 extensions/telegram/src/model-buttons.ts extensions/telegram/src/model-buttons.test.ts extensions/telegram/src/bot-handlers.runtime.ts — passed.
  • git diff --check and node scripts/check-no-conflict-markers.mjs — passed.
  • gitleaks protect --staged --redact — no leaks.

Real Behavior Proof

Mantis captured native Telegram Desktop before/after proof in PR comment openclaw-mantis on 2026-06-30:

Summary from the proof: current main reports 2 available models but shows only one listed model; this PR shows the long over-limit model button in native Telegram Desktop.

openclaw#98221)

The /model picker silently dropped any model whose callback_data exceeded
Telegram's 64-byte limit on both the standard and compact encodings — long
namespaced Ollama ids in particular — while the header still counted them.

Add a length-safe index fallback: when neither name-based encoding fits,
buildModelSelectionCallbackData emits mdl_idx_{provider}_{index} referencing the
model's position in the provider's sorted list, parseModelCallbackData decodes
it, and buildModelsKeyboard stops dropping over-limit models. The callback
handler resolves the index against the same [...set].toSorted(localeCompare)
derivation used to build the keyboard, then reuses the existing select path; a
list that changed since render prompts a refresh instead of mis-selecting.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S labels Jun 30, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 5:25 AM ET / 09:25 UTC.

Summary
The PR adds a tokenized mdl_idx_* Telegram model-selection callback fallback for over-limit model names, resolves that callback in the Telegram handler, and updates model-button regression tests.

PR surface: Source +89, Tests +99. Total +188 across 3 files.

Reproducibility: yes. Current main is source-reproducible because over-limit compact callback data returns null, buildModelsKeyboard skips that row, and Mantis baseline proof shows the visible count/button mismatch.

Review metrics: 1 noteworthy metric.

  • Telegram model callback formats: 1 added, 2 preserved. The PR adds mdl_idx_* for over-limit models while keeping both existing name-based formats, so maintainers should notice the callback contract change before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98221
Summary: This PR is a candidate fix for the open Telegram /model picker callback_data overflow issue, with one other open proof-positive candidate and several closed unmerged attempts for the same root cause.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • [P2] Inspect the exact-head Telegram QA smoke failure before merge; this read-only review did not establish a diff-caused bug.

Risk before merge

  • [P1] There is another open, proof-positive sibling PR for the same linked issue, so maintainers should choose one canonical callback format before landing either branch.
  • [P1] The new indexed callback path resolves provider/model choices that flow into Telegram session model overrides, so the callback contract is a model-routing merge risk even though this implementation looks correct.
  • [P1] The latest exact-head CI has a Telegram QA smoke failure; I did not trace it to this diff in the read-only review, but it should be inspected before merge.

Maintainer options:

  1. Accept this callback contract (recommended)
    Merge this PR as the canonical fix once exact-head checks are acceptable, accepting the bounded model-routing risk from the new indexed callback fallback.
  2. Choose the sibling format instead
    If maintainers prefer the broader sibling callback contract, pause or close this PR after naming fix(telegram): use index-based callback_data to avoid silent model drops in /model picker (fixes #98221) #98694 as canonical.
  3. Tighten before merge
    If maintainers want stronger stale-list protection, require a focused update to the token/fingerprint scheme before choosing this branch.

Next step before merge

  • No automated repair is pending; maintainers need to choose the canonical open fix, then inspect the exact-head Telegram QA smoke failure before merge.

Maintainer decision needed

  • Question: Should maintainers make this PR the canonical fix for the Telegram over-limit /model callback issue, or choose the open sibling implementation instead?
  • Rationale: Both open candidates address the same user-visible bug with different callback formats, and the provider/model routing contract should be intentional before merge.
  • Likely owner: steipete — The byte-limit refactor and compact callback fallback history make this the best available routing owner for the callback-format choice.
  • Options:
    • Use this PR as canonical (recommended): Land this minimal index-plus-identity fallback if maintainers prefer preserving existing name-based callbacks for all models that already fit.
    • Use the sibling candidate: Choose fix(telegram): use index-based callback_data to avoid silent model drops in /model picker (fixes #98221) #98694 if maintainers prefer its broader indexed callback contract, then pause or close this PR.
    • Hold for owner selection: Keep both candidates open until a Telegram owner explicitly selects the callback format, accepting the extra review round trip.

Security
Cleared: The diff is limited to Telegram callback parsing, callback handling, and tests, with no dependency, workflow, permission, secret, or package-resolution changes.

Review details

Best possible solution:

Land one canonical Telegram-layer index callback fix for the linked issue; this PR is a strong candidate if maintainers prefer preserving existing name-based callbacks and falling back to indexed callbacks only when Telegram's limit requires it.

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

Yes. Current main is source-reproducible because over-limit compact callback data returns null, buildModelsKeyboard skips that row, and Mantis baseline proof shows the visible count/button mismatch.

Is this the best way to solve the issue?

Yes for this branch. The index-plus-identity fallback fixes the Telegram 64-byte limit only when needed, preserves existing selectable callback formats, and rejects stale in-range index drift; the remaining question is which sibling callback contract maintainers want to own.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded Telegram model-picker bug fix with clear source and visual reproduction evidence and limited channel-surface blast radius.
  • merge-risk: 🚨 auth-provider: The changed Telegram callback route resolves provider/model selections that determine the model override applied to a user session.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Mantis Telegram Desktop before/after screenshots directly show baseline hiding the long model despite 2 available and the candidate rendering that long model button.
  • proof: sufficient: Contributor real behavior proof is sufficient. Mantis Telegram Desktop before/after screenshots directly show baseline hiding the long model despite 2 available and the candidate rendering that long model button.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Mantis Telegram Desktop before/after screenshots directly show baseline hiding the long model despite 2 available and the candidate rendering that long model button.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram /model inline-button rendering, which is exactly the kind of behavior Telegram Desktop proof can demonstrate.
Evidence reviewed

PR surface:

Source +89, Tests +99. Total +188 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 95 6 +89
Tests 1 110 11 +99
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 205 17 +188

What I checked:

  • Current main still has the silent-drop path: On current main, buildModelSelectionCallbackData returns null when both name-based callback encodings exceed the Telegram limit, and buildModelsKeyboard skips rows with null callback data. (extensions/telegram/src/model-buttons.ts:107, da1b0fa2a8f4)
  • Latest release is still affected: The v2026.6.11 tag contains the same null-return and row-skip behavior, so the PR is not obsolete against the latest shipped release. (extensions/telegram/src/model-buttons.ts:107, e085fa1a3ffd)
  • PR head implements a bounded fallback: The PR preserves the existing standard and compact callbacks, adds selectIndex, builds mdl_idx_{provider}_{index}_{token} only after name-based encodings fail, and keeps the index payload under the callback limit when the provider id is reasonable. (extensions/telegram/src/model-buttons.ts:120, 92fd45067eb7)
  • PR head guards stale index callbacks: The Telegram callback handler resolves selectIndex against the same sorted provider model list and asks the user to rerun /model when the identity token no longer matches. (extensions/telegram/src/bot-handlers.runtime.ts:3043, 92fd45067eb7)
  • Focused regression coverage exists: The PR adds coverage for index parsing, stale in-range index rejection, over-limit round-trip behavior, and not dropping over-limit model rows. (extensions/telegram/src/model-buttons.test.ts:122, 92fd45067eb7)
  • Real Telegram proof is positive: Mantis proof shows baseline Telegram Desktop reporting 2 available models while rendering only gpt-5.5, and the candidate rendering the long ...agentic-fable5-composer2.5-v2:latest button as well. (a89907bc689e)

Likely related people:

  • steipete: Peter Steinberger authored the callback-data byte-limit refactor and committed the older compact model callback fallback, making this a strong routing candidate for the callback contract decision. (role: recent area contributor; confidence: high; commits: 047b701859ab, 54eb13893fd5; files: extensions/telegram/src/model-buttons.ts, extensions/telegram/src/approval-callback-data.ts, src/telegram/model-buttons.ts)
  • vincentkoc: Vincent Koc most recently touched the current Telegram model-buttons and callback-handler files through the plugin-localization refactor and latest release-adjacent history. (role: recent area contributor; confidence: medium; commits: 33163d427391, e085fa1a3ffd; files: extensions/telegram/src/model-buttons.ts, extensions/telegram/src/bot-handlers.runtime.ts)
  • scoootscooob: scoootscooob moved the Telegram implementation into extensions/telegram, carrying the model-button surface into the current plugin boundary. (role: migration owner for current path; confidence: medium; commits: e5bca0832fbd; files: extensions/telegram/src/model-buttons.ts, extensions/telegram/src/bot-handlers.runtime.ts, src/telegram/model-buttons.ts)
  • bmendonca3: The compact Telegram model callback fallback involved in this bug appears authored by bmendonca3 in the older Telegram path. (role: fallback behavior introducer; confidence: medium; commits: 54eb13893fd5; files: src/telegram/model-buttons.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.
Review history (2 earlier review cycles)
  • reviewed 2026-06-30T18:09:54.579Z sha a89907b :: needs real behavior proof before merge. :: [P2] Guard index callbacks against in-range list drift
  • reviewed 2026-07-07T07:09:09.609Z sha 1f82903 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 30, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared June 30, 2026 18:07 Inactive
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 30, 2026
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIFs for the /model picker: Main shows one listed model despite 2 available; This PR shows the long model button.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-98230/run-28465647047-1/index.json

@luoyanglang

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the stale-index P2 in head 1f829039bc: over-limit /model picker index callbacks now carry a compact model identity token, and the Telegram handler refreshes instead of selecting when the current in-range index token does not match. I also updated the PR body with the Mantis Telegram Desktop proof links from run 28465647047 plus fresh local validation.

@clawsweeper

clawsweeper Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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. labels Jul 7, 2026
@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@barnacle-openclaw barnacle-openclaw Bot added the stale Marked as stale due to inactivity label Jul 22, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@luoyanglang
luoyanglang deleted the wolf/telegram-model-picker-index-callback branch September 25, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M stale Marked as stale due to inactivity status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram /model picker silently drops models when callback_data exceeds 64 bytes

1 participant