Repository navigation
fix(telegram): use index-based callback data to avoid silent model drops - #98303
LeonidasLux wants to merge 2 commits into
Conversation
Replace name-based callback_data (mdl_sel_{provider}/{model}) with an index-based format (mdl_sel_idx_{provider}_{page}_{index}) that always fits within Telegram's 64-byte limit.
Previously, buildModelSelectionCallbackData returned null when even the compact encoding exceeded 64 bytes, causing buildModelsKeyboard to silently skip that model while the header still reported the full count.
Fixes openclaw#98221
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: the PR addresses a valid Telegram /model picker bug and has real visual proof, but the current branch still has merge-blocking review issues around the weak stale-callback guard and unchanged bot-level callback expectations. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this PR as superseded by #98694. So I’m closing this here and keeping the remaining discussion on #98694. Review detailsBest possible solution: Close this PR as superseded by #98694. Do we have a high-confidence way to reproduce the issue? Yes. Current main is source-reproducible: over-limit compact model callback data returns null, and buildModelsKeyboard skips that row while the handler still reports the full model count. Is this the best way to solve the issue? No, not yet. The index-callback direction is the right Telegram-layer fix, but this branch still needs a stronger stale guard and bot-level test alignment before it is the best merge candidate. Security review: Security review cleared: The diff is limited to Telegram callback parsing/rendering and tests, with no dependency, workflow, secret, permission, or package-resolution changes. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against e0970cfec572. |
Mantis Telegram Desktop ProofSummary: Mantis captured native Telegram Desktop before/after GIFs for the model picker button list.
Motion-trimmed clips: |
|
@clawsweeper re-view |
…rift
Add a compact 16-bit model fingerprint (4 hex chars) to index-based
Telegram model-selection callback data (mdl_sel_idx_{p}_{page}_{idx}_{fp}).
Built at keyboard-creation time from the model ID, verify it in
resolveModelSelection when the callback fires: a mismatch means the
sorted provider model list has shifted and the same index now points
to a different model, so reject with ambiguous to force a keyboard
refresh instead of silently selecting the wrong model.
Backward compatible — old-format callbacks without a fingerprint
resolve normally (no verification).
[P1] A stale but in-range index callback could apply a shifted model.
[P2] Add compact identity guard for index callbacks.
[P2] Add regression test for stale in-range index detection.
Ref. openclaw#98303
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞✅ Reason: structured ClawSweeper close marker: close-required (sha=1fec277c4c6d9abd69369e87665a27a29411fe9b) Closed:
|




Summary
The Telegram
/modelpicker embeds the full model name incallback_data. When a model ID is long enough that even the compact encoding (mdl_sel/{model}) exceeds Telegram's 64-byte limit,buildModelSelectionCallbackDatareturnsnullandbuildModelsKeyboardsilently skips that model — the header still reports the full count.Replace the name-based
callback_datascheme with an index-based format:mdl_sel_idx_{provider}_{page}_{index}that always fits within 64 bytes regardless of model name length. The server resolves the model by looking up the sorted provider model list using the page and index.Fixes #98221
What Problem This Solves
Problem: Users with long-namespaced models (e.g. Ollama community fine-tunes like
xentriom/gemma-4-12B-agentic-fable5-composer2.5-v2:latest) can't select them from Telegram's/modelpicker. The button is silently dropped with no error message — the header says "X available" but fewer buttons are shown.Why This Change Was Made:
provider/page/indexinstead of model name. Always fits in 64 bytes. Completely eliminates the length limitation.User Impact: All models are now selectable via Telegram buttons regardless of name length. No user-facing changes.
Root Cause
Trigger condition: Any model ID ≥ 57 bytes makes the compact callback
mdl_sel/{model}exceed Telegram's 64-byte limit.Root cause analysis:
buildModelSelectionCallbackDatainextensions/telegram/src/model-buttons.tsreturnsnullwhen both standard and compact encodings exceed the limit.buildModelsKeyboardsilently skips models withnullcallback data viacontinue, while the header still reportsmodels.length.Affected scope: Telegram channel only. All OpenClaw versions since the model picker was introduced.
Real behavior proof
Behavior addressed: Long model names are no longer silently dropped from the Telegram /model picker button list.
Real environment tested: Windows 10 / Node.js v24.14.1 / openclaw @ f284ce3
Exact steps or command run after this patch: Unit tests covering the fix (29 tests, all passing).
After-fix evidence:
Observed result after the fix: All 29 tests pass — no silent drops, always under 64 bytes, fully backward compatible with legacy callback formats.
What was not tested: Live Telegram bot interaction (requires real Telegram bot credentials). The fix is fully covered by unit tests since it's a pure logic change.
Tests and validation
Unit tests
Key new tests:
resolveModelSelection > resolves index-based selection by looking up the model in the provider's listresolveModelSelection > resolves index across page boundariesresolveModelSelection > returns ambiguous when index is out of boundsbuildModelSelectionCallbackData > always returns a valid callback data under 64 bytes regardless of model name lengthbuildModelsKeyboard > renders all models regardless of name length (no silent drops)parseModelCallbackData > parses supported callback variants(includes newmdl_sel_idx_format)All existing backward-compatibility tests remain passing.
Risk checklist
Current review state