Skip to content

feat(telegram): expose inline keyboard buttons via send_message tool - #42865

Open
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:feat/telegram-inline-keyboard-send-message
Open

feat(telegram): expose inline keyboard buttons via send_message tool#42865
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:feat/telegram-inline-keyboard-send-message

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

Problem

When the agent needs user approval for multi-step workflows (e.g. approve commit, approve push), it can only send plain text via send_message. Users must manually type the exact approval phrase, which is error-prone and creates friction — especially on Telegram where inline keyboard buttons already exist for terminal command approvals.

Solution

Add an optional buttons parameter to the send_message tool schema. Each button specifies text (label) and callback_data (payload sent on tap). When targeting Telegram, buttons are converted to InlineKeyboardMarkup and attached as reply_markup. Non-Telegram platforms silently ignore the parameter.

Changes

  • tools/send_message_tool.py — Added buttons array parameter to SEND_MESSAGE_SCHEMA. Updated _handle_send, _send_to_platform, and _send_telegram to forward and render inline keyboard buttons.
  • tests/tools/test_send_message_tool.py — 6 new tests covering: schema validation, button rendering, no-buttons baseline, empty list, invalid entries filtering, and pass-through from _send_to_platform.

Usage

send_message(
    action="send",
    target="telegram",
    message="To continue, choose an option:",
    buttons=[
        {"text": "✅ Approve", "callback_data": "approve:once"},
        {"text": "❌ Deny", "callback_data": "approve:deny"},
    ]
)

Closes #42696

Add optional 'buttons' parameter to the send_message tool schema,
enabling agents to attach inline keyboard buttons when sending to
Telegram. Each button specifies 'text' (label) and 'callback_data'
(payload sent on tap). Buttons are arranged in a single row.

The parameter is ignored on non-Telegram platforms, preserving
backward compatibility. Invalid button entries (missing text or
callback_data) are silently filtered out.

Closes NousResearch#42696
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter comp/gateway Gateway runner, session dispatch, delivery labels Jun 9, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Changes Overview

  • New feature: Telegram inline keyboard buttons via the buttons parameter in send_message tool
  • Buttons are converted to Telegram's InlineKeyboardMarkup format
  • Comprehensive test coverage (6 new test methods)

Analysis

Correctness

  • Implementation looks correct: buttons are properly mapped to InlineKeyboardButton
  • Invalid buttons (missing text or callback_data) are filtered out gracefully
  • Buttons only apply on Telegram platform (silently ignored on others)
  • Error handling for keyboard building failures is appropriate (warning logged, message still sent)

Security

  • No security concerns
  • callback_data is passed through as-is (Telegram handles this)

Code Quality

  • Clean implementation with good separation of concerns
  • Error handling in keyboard building is defensive (try/except with warning)
  • Test coverage is comprehensive: schema, with/without buttons, empty list, invalid entries, integration

Testing

  • Excellent test coverage including edge cases (empty buttons, invalid entries)

Reviewed by Hermes Agent

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused Telegram UX contribution. The send-side keyboard construction is clear, but it does not complete the approval workflow described in the PR.

Problems

  • The new callback_data is only attached to the outbound message. Current callback dispatch in plugins/platforms/telegram/adapter.py:5316-5639 recognizes specific mp:, gt:, ea:, sc:, cl:, and update_prompt: forms; the example approve:once falls through without reaching an agent session.
  • The new tests cover markup creation and forwarding, but not a callback tap or session delivery.

Suggested changes

  • For agent workflow choices, consider using the existing clarify path: tools/clarify_tool.py:125-174 exposes choices, and plugins/platforms/telegram/adapter.py:4696-4749 plus :5578-5635 renders and resolves them.
  • If a generic button API is needed, add an authorized callback-routing contract and an end-to-end callback test.

This is an automated hermes-sweeper review.

if buttons and isinstance(buttons, list) and len(buttons) > 0:
try:
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
keyboard = InlineKeyboardMarkup([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only creates outbound callback payloads. Current Telegram callback dispatch handles specific registered prefixes and otherwise returns (plugins/platforms/telegram/adapter.py:5316-5639), so the documented approve:once value will not deliver an approval phrase to the agent. Please add a receive-side routing contract and an end-to-end tap test, or use the existing clarify interaction path.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
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 P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Telegram Gateway: Expose inline keyboard buttons for agent approval prompts

4 participants