Skip to content

feat: add thread_id and local file support to proactive channel_send#510

Closed
houko wants to merge 10 commits intoRightNow-AI:mainfrom
houko:feat/channel-send-thread-id-pr
Closed

feat: add thread_id and local file support to proactive channel_send#510
houko wants to merge 10 commits intoRightNow-AI:mainfrom
houko:feat/channel-send-thread-id-pr

Conversation

@houko
Copy link
Contributor

@houko houko commented Mar 11, 2026

Summary

  • add thread_id and file_path support to proactive channel_send
  • route proactive channel sends through send_in_thread(...) when thread_id is present
  • let Telegram sendDocument accept an existing local file path and upload it via multipart while preserving message_thread_id
  • preserve file captions end-to-end for proactive file sends
  • make file_path explicitly telegram-only for now, with a clear runtime error on unsupported channels
  • add tests for schema exposure, kernel handoff, local path detection, caption propagation, and multipart request behavior

Why

Closes #509. OpenFang already supports threaded Telegram replies at the adapter level, but the proactive outbound path still could not target a specific thread/topic or send a generated local file without an external wrapper.

Validation

  • cargo test -p openfang-runtime test_channel_send
  • cargo test -p openfang-channels telegram::tests::test_api_send_document_multipart_for_local_file_preserves_thread_id
  • cargo test -p openfang-channels telegram::tests::test_parse_telegram_document_fallback
  • cargo test -p openfang-channels telegram::tests::test_local_document_path_accepts_existing_file_and_file_scheme
  • cargo check -p openfang-kernel
  • live-fire verification on a real Telegram topic: sent text and a local PDF with caption to topic 18 using the PR branch code

@houko
Copy link
Contributor Author

houko commented Mar 11, 2026

Follow-up pushed in e084f8c.

This tightens the initial implementation in two ways:

  • preserves file captions end-to-end for channel_send -> kernel -> channel adapters
  • makes file_path explicitly telegram-only for now, with a clear runtime error for other channels

Validation rerun on the PR branch:

  • cargo test -p openfang-runtime test_channel_send
  • cargo test -p openfang-channels telegram::tests::test_api_send_document_multipart_for_local_file_preserves_thread_id
  • cargo test -p openfang-channels telegram::tests::test_parse_telegram_document_fallback
  • cargo check -p openfang-kernel

Also re-verified live against a real Telegram topic on the PR branch code:

  • sent text to topic 18
  • sent a local PDF to topic 18 with caption PR #510 caption pipeline check

@houko
Copy link
Contributor Author

houko commented Mar 11, 2026

Follow-up pushed in 8cf0a24.

This also fixes Telegram rendering for proactive outbound sends:

  • channel_send text now uses the same channel formatter defaults as bridge replies
  • Telegram proactive messages render Markdown-style **bold**, *italic*, `code`, and links as Telegram HTML instead of showing raw markup
  • image/file captions in the proactive path now go through the same formatter

Validation:

  • cargo test -p openfang-kernel test_format_proactive_channel_text

@houko
Copy link
Contributor Author

houko commented Mar 11, 2026

Added two follow-up commits on top of the existing thread/topic work:

  • 796b51a feat(telegram): support local image attachments in proactive sends
    • adds image_path to channel_send
    • routes local Telegram images through multipart sendPhoto
    • preserves message_thread_id for proactive topic delivery
  • ce0e969 feat(formatter): render task lists for telegram
    • renders Markdown task lists like - [x] / - [ ] as / in Telegram formatting
    • keeps nested list bullets from being misparsed as italics

Validation rerun after these commits:

  • cargo test -p openfang-runtime test_channel_send
  • cargo test -p openfang-channels formatter::tests::
  • cargo test -p openfang-channels test_api_send_

The sendPhoto coverage now includes a multipart local-file test that checks message_thread_id is preserved.

@jaberjaber23
Copy link
Member

Has merge conflicts with current main. Please rebase and resubmit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: expose thread_id in proactive channel_send and support local file attachments

2 participants