Skip to content

fix(telegram): add mdl_idx callback fallback for long model names - #98581

Closed
ly-wang19 wants to merge 1 commit into
openclaw:mainfrom
ly-wang19:fix/telegram-model-picker-long-names-98221
Closed

ly-wang19 wants to merge 1 commit into
openclaw:mainfrom
ly-wang19:fix/telegram-model-picker-long-names-98221

Conversation

@ly-wang19

Copy link
Copy Markdown
Contributor

What Problem This Solves

Telegram inline button callback_data is capped at 64 bytes. Namespaced Ollama tags (e.g. xentriom/gemma-4-12B-agentic-fable5-composer2.5-v2:latest) plus the mdl_sel_ or mdl_sel/ prefix overflow that cap, so buildModelsKeyboard silently dropped those rows from the /model picker. The user saw a model count that did not match the buttons, and could never select the long-named model.

Fixes #98221

Why This Change Was Made

The existing fallback stack (standard → compact) handled real-world IDs from OpenRouter / Bedrock but still failed for Ollama tags with provider namespacing (e.g. xentriom/...:latest). Dropping the button was the wrong default: every row in the picker should be selectable. A 1-indexed position in the locale-sorted model list fits in 64 bytes for any realistic provider name and total model count, and the handler can re-derive the same sort order ([...modelSet].toSorted(localeCompare)) to map the index back to the exact model the user pressed.

User Impact

Ollama / OpenRouter models with long, namespaced tags now appear and are selectable in the Telegram /model picker. Previously the count said "12 models" but only 11 buttons rendered, and the missing one was often the one the user wanted.

Evidence

  • Local: npx vitest run extensions/telegram/src/model-buttons.test.ts → 29 tests pass (added 4 new cases for mdl_idx parser + index fallback in buildModelSelectionCallbackData / buildModelsKeyboard; updated the prior "skips models that would exceed callback_data limit" test which now asserts the index fallback instead).
  • Lint: node scripts/run-oxlint.mjs extensions/telegram/src/{model-buttons.ts,bot-handlers.runtime.ts,model-buttons.test.ts} clean.
  • Typecheck: node scripts/run-tsgo.mjs -p extensions/telegram/tsconfig.json shows no new errors (the two reported errors in bot-message-dispatch.ts are pre-existing on main and unrelated to this change).

Telegram inline button callback_data is capped at 64 bytes. Namespaced
Ollama tags (e.g. 'xentriom/gemma-4-12B-agentic-fable5-composer2.5-v2:latest')
plus the mdl_sel_ or mdl_sel/ prefix overflow that cap, so buildModelsKeyboard
silently dropped those rows and the user could never pick the model.

Add a third-tier callback encoding mdl_idx/{provider}/{i} that stores the
provider name plus the 1-indexed position in the locale-sorted model list.
The handler re-derives the same sort order ([...modelSet].toSorted(localeCompare))
to map the index back to a model, so the user's selection still lands on the
exact row they pressed.

Fixes openclaw#98221
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S labels Jul 1, 2026
@clawsweeper

clawsweeper Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 7:59 AM ET / 11:59 UTC.

Summary
The PR adds a Telegram mdl_idx/{provider}/{i} fallback for over-limit model-selection callback data and updates the Telegram model-button parser, handler, and tests.

PR surface: Source +70, Tests +49. Total +119 across 3 files.

Reproducibility: yes. source-level. Current main returns null for over-limit standard and compact model callbacks, and the keyboard then skips that row while the header still counts the full provider model list.

Review metrics: 1 noteworthy metric.

  • Telegram callback formats: 1 added. The new mdl_idx wire value affects model-choice routing and must stay consistent across every model-picker entry point before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98221
Summary: This PR is one candidate fix for the open Telegram over-limit model callback issue; two other open PRs attempt the same root-cause repair but are not safe superseding targets yet.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • [P1] Use one canonical sort order or add a compact identity/snapshot guard for index callbacks.
  • [P1] Add redacted Telegram Desktop proof, terminal/live output, or logs showing the long model appears and selecting it applies exactly that model.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists local tests, lint, and typecheck only; it needs redacted Telegram Desktop proof, live output, or logs showing the over-limit model button renders and selects correctly. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A native Telegram proof would directly show whether the over-limit model row appears and whether pressing it applies the exact model. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify that /model shows and selects an over-limit Ollama model name without dropping it or selecting a neighboring model.

Risk before merge

  • [P1] Index callbacks can currently map to a different model because rendering and resolution do not share one canonical ordering or model-identity token.
  • [P1] The PR has only local test/lint/typecheck evidence; Telegram callback behavior still needs redacted real Telegram proof before merge.
  • [P1] Two sibling open PRs target the same canonical issue, so maintainers should choose one fixed and proven callback format rather than landing multiple competing variants.

Maintainer options:

  1. Bind index callbacks to model identity (recommended)
    Use one canonical model order for every Telegram model-list entry point and include a compact model identity/hash or opaque snapshot key so mismatched or stale index callbacks refresh instead of selecting a shifted model.
  2. Accept the drift window explicitly
    Maintainers could accept rare stale or mismatched index drift, but that would intentionally allow Telegram buttons to apply a different model than the row the user pressed.

Next step before merge

  • [P1] The PR needs contributor real-behavior proof and a maintainer-visible correctness repair before it can proceed.

Security
Cleared: The diff is limited to Telegram callback parsing/handling and tests, with no dependency, workflow, secret, or supply-chain surface change.

Review findings

  • [P1] Use one model order for index callbacks — extensions/telegram/src/bot-handlers.runtime.ts:2947
Review details

Best possible solution:

Keep the length-safe fallback direction, but resolve it through one canonical ordered list plus a compact model-identity or stale-callback guard, then attach redacted real Telegram proof before merge.

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

Yes, source-level. Current main returns null for over-limit standard and compact model callbacks, and the keyboard then skips that row while the header still counts the full provider model list.

Is this the best way to solve the issue?

No, not yet. The length-safe index fallback is the right direction, but the current implementation must use a shared ordering and model-identity or stale-callback guard before it is the best fix.

Full review comments:

  • [P1] Use one model order for index callbacks — extensions/telegram/src/bot-handlers.runtime.ts:2947
    mdl_idx values are generated from the order passed into buildModelsKeyboard, but this resolver re-sorts the current provider set with localeCompare. The direct /models <provider> path passes a default .toSorted() list, and those orders differ for realistic IDs with uppercase segments like 12B; pressing an index fallback button can therefore apply a neighboring model. Render and resolve from one canonical order, or include a compact model identity token and reject mismatches.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: This is a bounded Telegram model-picker bug fix with a concrete correctness blocker before merge.
  • add merge-risk: 🚨 session-state: A wrong index resolution can write the wrong session-only model override for the user.
  • add merge-risk: 🚨 auth-provider: The PR changes model-choice callback routing and can apply a different provider/model than the Telegram button represented.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists local tests, lint, and typecheck only; it needs redacted Telegram Desktop proof, live output, or logs showing the over-limit model button renders and selects correctly. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • add mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram inline model-picker buttons and callback selection behavior that a short Telegram Desktop recording can demonstrate.

Label justifications:

  • P2: This is a bounded Telegram model-picker bug fix with a concrete correctness blocker before merge.
  • merge-risk: 🚨 auth-provider: The PR changes model-choice callback routing and can apply a different provider/model than the Telegram button represented.
  • merge-risk: 🚨 session-state: A wrong index resolution can write the wrong session-only model override for the user.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists local tests, lint, and typecheck only; it needs redacted Telegram Desktop proof, live output, or logs showing the over-limit model button renders and selects correctly. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram inline model-picker buttons and callback selection behavior that a short Telegram Desktop recording can demonstrate.
Evidence reviewed

PR surface:

Source +70, Tests +49. Total +119 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 75 5 +70
Tests 1 58 9 +49
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 133 14 +119

What I checked:

  • Repository policy applied: Root AGENTS.md, extensions/AGENTS.md, and the Telegram maintainer note were read; the Telegram note specifically requires real Telegram proof for callback behavior changes. (.agents/maintainer-notes/telegram.md:35, 94cb14b97ead)
  • Telegram callback byte contract: The official Telegram Bot API documents inline button callback_data as 1-64 bytes, matching the underlying limit this PR is trying to handle. (core.telegram.org)
  • Current main still drops over-limit model buttons: Current main returns null when standard and compact model-selection callback encodings exceed the byte limit, and buildModelsKeyboard skips rows with null callback data. (extensions/telegram/src/model-buttons.ts:107, 94cb14b97ead)
  • Current main can show count/button mismatch: The Telegram callback handler builds the full sorted model list and formats the header from the full count before delegating button rendering to buildModelsKeyboard, so skipped rows leave the visible count higher than the rendered buttons. (extensions/telegram/src/bot-handlers.runtime.ts:2906, 94cb14b97ead)
  • Latest release has not fixed it: The latest release tag v2026.6.11 still contains the null-returning over-limit compact callback path. (extensions/telegram/src/model-buttons.ts:107, e085fa1a3ffd)
  • PR adds an index callback wire value: The patch adds parsing/building for mdl_idx/{provider}/{i} and resolves that index inside the Telegram callback handler before reusing the existing select path. (extensions/telegram/src/model-buttons.ts:90, 036fffcfa58c)

Likely related people:

  • vincentkoc: Current blame maps the model-button helper, skip path, handler list path, and shared /models source to recent current-main commits by Vincent Koc, and the latest release carries the same area. (role: recent area contributor; confidence: high; commits: 84247114c2f4, e085fa1a3ffd; files: extensions/telegram/src/model-buttons.ts, extensions/telegram/src/model-buttons.test.ts, extensions/telegram/src/bot-handlers.runtime.ts)
  • Saurabh Mishra: Commit 90e82fa changed the Telegram model selector display-name flow and tests that share the same buildModelsKeyboard and provider-data surfaces. (role: adjacent feature contributor; confidence: medium; commits: 90e82fabb3e8; files: extensions/telegram/src/model-buttons.ts, extensions/telegram/src/model-buttons.test.ts, extensions/telegram/src/bot-handlers.runtime.ts)
  • scoootscooob: Commit e5bca08 moved the Telegram channel implementation into extensions/telegram, including the model-button and handler surfaces now being changed. (role: introduced extension boundary; confidence: medium; commits: e5bca0832fbd; files: extensions/telegram/src/model-buttons.ts, extensions/telegram/src/bot-handlers.runtime.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.

@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 1, 2026
@ly-wang19

Copy link
Copy Markdown
Contributor Author

Closing as duplicate of #98230 — that PR uses the same index-callback approach for #98221 and ships with Mantis/Telegram Desktop proof, which ClawSweeper flagged as the merge blocker on this branch. No unique value in keeping the third competing branch open.

This branch had an error being deployed

1 failed deployment
qa-live-shared — 036fffcf Deployed Jul 1, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #256282
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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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