Skip to content

Telegram: model buttons silently dropped when Bedrock callback_data exceeds 64 bytes #31815

@zqchris

Description

@zqchris

Bug Description

When using Amazon Bedrock models, the provider/model callback data string (e.g., mdl_sel_amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0) can exceed Telegram's 64-byte callback_data limit. The current code silently skips these buttons with continue, making the model completely unselectable from the Telegram /model picker UI.

Expected Behavior

When the full provider/model callback data exceeds 64 bytes, the code should try a shorter format (e.g., omit the provider prefix: mdl_sel_us.anthropic.claude-haiku-4-5-20251001-v1:0) and only skip if that also exceeds the limit. The callback parser and handler should support both formats.

Actual Behavior

const callbackData = `mdl_sel_${provider}/${model}`;
if (Buffer.byteLength(callbackData, "utf8") > MAX_CALLBACK_DATA_BYTES) continue;
// Button silently dropped — model is unselectable

Impact

Any Bedrock model with a long ID (which is most of them, e.g., global.anthropic.claude-sonnet-4-6, us.anthropic.claude-haiku-4-5-20251001-v1:0) cannot be selected via the Telegram model picker. Users see an incomplete or empty model list.

Suggested Fix

Three changes needed across subagent-registry-*.js, reply-*.js, and pi-embedded-*.js:

1. Button generation — fallback to model-only callback:

- const callbackData = `mdl_sel_${provider}/${model}`;
- if (Buffer.byteLength(callbackData, "utf8") > MAX_CALLBACK_DATA_BYTES) continue;
+ let callbackData = `mdl_sel_${provider}/${model}`;
+ if (Buffer.byteLength(callbackData, "utf8") > MAX_CALLBACK_DATA_BYTES) {
+   callbackData = `mdl_sel_${model}`;
+   if (Buffer.byteLength(callbackData, "utf8") > MAX_CALLBACK_DATA_BYTES) continue;
+ }

2. Callback parser — handle missing provider:

  if (slashIndex > 0 && slashIndex < modelRef.length - 1) return {
    type: "select", provider: modelRef.slice(0, slashIndex), model: modelRef.slice(slashIndex + 1)
  };
+ return { type: "select", provider: "", model: modelRef };

3. Callback handler — support empty provider:

  const { provider, model } = modelCallback;
- text: `/model ${provider}/${model}`
+ const modelArg = provider ? `${provider}/${model}` : model;
+ text: `/model ${modelArg}`

Environment

  • OpenClaw: v2026.3.1
  • Channel: Telegram
  • Provider: Amazon Bedrock

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions