Skip to content

fix(gateway/telegram): include full numbered choices in clarify body#27535

Closed
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/telegram-clarify-full-text-body
Closed

fix(gateway/telegram): include full numbered choices in clarify body#27535
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/telegram-clarify-full-text-body

Conversation

@luyao618

Copy link
Copy Markdown
Contributor

Summary

Fixes #27497.

Telegram inline-button labels are clipped on mobile when clarify choices are long, leaving users unable to read the full options. Previously send_clarify rendered each option only as an inline-keyboard button (label truncated to 60 chars in code, and further visually truncated by Telegram on mobile), with the message body containing only the question.

This change moves the full option text into the message body as a numbered list and shortens inline-button labels to just the option index, so buttons always fit while the full text is readable in the chat.

Changes

  • gateway/platforms/telegram.py::send_clarify
    • When choices is non-empty, build message text as ❓ <question>\n\n1. <choice1>\n2. <choice2>…, with each choice HTML-escaped.
    • Inline-button labels become just the index ("1", "2", …) instead of "{n}. {label}".
    • callback_data (cl:<id>:<idx>, cl:<id>:other) is unchanged — callback handling is untouched.
    • Open-ended (no-choices) path is unchanged.
    • "✏️ Other (type answer)" button preserved as-is.

Tests

  • tests/gateway/test_telegram_clarify_buttons.py::test_truncates_long_choice_label rewritten to:
    • Pass 4 long choices (>100 chars each).
    • Assert each full f"{idx}. {choice}" line appears in the sent body.
    • Assert non-Other button labels are exactly the index string ("1", "2", "3", "4").
    • Assert the "Other" button label is preserved.
$ pytest tests/gateway/test_telegram_clarify_buttons.py tests/tools/test_clarify_gateway.py
27 passed in 1.94s

Notes

  • HTML escaping is applied to both the question and each choice in the body.
  • Callback data length stays well within Telegram's 64-byte cap.
  • No change to clarify_gateway text-capture path or the "Other" flow.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels May 17, 2026
Telegram inline button labels are clipped on mobile when clarify choices
are long, leaving users unable to read full options. Render the question
and a full numbered list of escaped options in the message body, and
shorten inline button labels to just the option index so they always
fit. Fixes NousResearch#27497.
@teknium1

Copy link
Copy Markdown
Contributor

Closing in favor of #27852 (same fix, three competing implementations of the same body+button-label pattern for #27497).

#27852 was chosen because:

  • Most surgical patch — appends to existing text variable rather than restructuring kwargs flow
  • Cleaner test rename (test_long_choice_rendered_in_body_not_truncated)
  • Smallest diff (28/-11 vs your 42/-18)

Functionally all three PRs (yours, #27581, #27852) do the same thing. Thanks for the parallel work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram clarify choices should include full numbered text when buttons truncate

3 participants