Skip to content

feat: Telegram message reactions for agent lifecycle feedback#436

Open
houko wants to merge 5 commits intoRightNow-AI:mainfrom
houko:feat/telegram-reactions
Open

feat: Telegram message reactions for agent lifecycle feedback#436
houko wants to merge 5 commits intoRightNow-AI:mainfrom
houko:feat/telegram-reactions

Conversation

@houko
Copy link

@houko houko commented Mar 8, 2026

Summary

  • Implement Telegram setMessageReaction API for real-time emoji-based agent lifecycle feedback
  • Dynamic reaction flow: 👀 (received) → 🤔 (thinking, after 2s) → AI-chosen emoji (done) / 😱 (error)
  • Add message_react tool so agents can choose their own reaction emoji contextually — no hardcoded "done" emoji
  • Uses tokio::select! with biased racing to skip the thinking reaction if agent responds within 2 seconds

Changes

crates/openfang-channels/src/telegram.rs

  • Add api_set_reaction() method calling Telegram Bot API setMessageReaction
  • Implement send_reaction() on ChannelAdapter trait with status_reactions guard
  • Add telegram_reaction_emoji() mapping for lifecycle phases (Queued→👀, Thinking→🤔, Error→😱, etc.)
  • Add with_reactions() constructor and status_reactions field
  • Input validation: parse chat_id/message_id, skip reaction for invalid message_id (≤0)

crates/openfang-channels/src/bridge.rs

  • Dynamic lifecycle reactions using tokio::select! with biased racing
  • Inject [channel_context] header into agent messages with channel, recipient, message_id
  • Remove hardcoded "done" reaction — agent chooses via message_react tool
  • Keep hardcoded "error" reaction (agent can't call tools on failure)

crates/openfang-runtime/src/tool_runner.rs

  • Add message_react tool definition and handler
  • Agent specifies channel, recipient, message_id, and emoji to react with

crates/openfang-runtime/src/kernel_handle.rs

  • Add send_channel_reaction() method to KernelHandle trait

crates/openfang-kernel/src/kernel.rs

  • Implement send_channel_reaction() — routes through channel adapter's send_reaction()

crates/openfang-types/src/config.rs

  • Add status_reactions: bool to TelegramConfig (default: true)

crates/openfang-api/src/channel_bridge.rs

  • Pass status_reactions config flag to TelegramAdapter::with_reactions()

Test plan

  • Unit test: test_telegram_reaction_emoji_mapping — verifies phase→emoji mappings
  • Unit test: test_send_reaction_disabled — no-op when status_reactions=false
  • Unit test: test_send_reaction_invalid_message_id — error on non-numeric message_id
  • Unit test: test_builtin_tool_definitions — includes message_react tool
  • Integration tests: 9 bridge tests updated for [channel_context] header
  • Live Telegram verification: emoji reactions appear and AI chooses contextual emoji
  • cargo test -p openfang-channels -p openfang-runtime — all tests pass

Closes #435

houko and others added 5 commits March 8, 2026 21:16
Add emoji reactions on incoming Telegram messages to provide immediate
visual feedback while the agent processes the request.

Flow: 👀 (received) → 👍 (success) or 👎 (error)

Changes:
- telegram.rs: add api_set_reaction() calling setMessageReaction API,
  implement send_reaction() on ChannelAdapter trait, add
  telegram_reaction_emoji() mapping phases to Telegram-supported emojis
- bridge.rs: send queued reaction on message receipt, update to done/error
  after agent responds

Closes RightNow-AI#435

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add `status_reactions` config field to TelegramConfig (default: true)
  so reactions can be disabled via config.toml
- Guard api_set_reaction against message_id <= 0
- Truncate error response body in logs to 200 chars
- Add TelegramAdapter::with_reactions() constructor
- Add tests: disabled reactions no-op, invalid message_id error

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add tokio::select! racing in bridge dispatch: show 👀 immediately,
  switch to 🤔 after 2s if agent is still processing, then 🎉/😱 on
  completion/error
- Change Done emoji from 👍 to 🎉 and Error from 👎 to 😱 for clearer
  status indication
- Update tests to match new emoji mapping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add `message_react` tool so agents can choose their own reaction emoji
  instead of hardcoded lifecycle emojis
- Add `send_channel_reaction()` to KernelHandle trait and implement in kernel
- Inject [channel_context] header into messages so agents know channel,
  recipient, and message_id for the react tool
- Remove hardcoded "done" reaction — agent chooses via tool call
- Keep hardcoded "error" reaction (agent can't react on failure)
- Update bridge integration tests for channel_context header in messages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

under-review PR is under review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Telegram message reactions for agent lifecycle feedback

2 participants