hermes - ✅(Solved) Fix edit_message missing finalize parameter in Telegram/Discord/Slack/Matrix adapters [3 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#12579Fetched 2026-04-20 12:18:07
View on GitHub
Comments
0
Participants
1
Timeline
9
Reactions
0
Author
Participants
Timeline (top)
referenced ×5cross-referenced ×3closed ×1

Error Message

When streaming messages on these platforms:

TypeError: TelegramAdapter.edit_message() got an unexpected keyword argument 'finalize'

Root Cause

The commit message states: "Default False so Telegram/Slack/Discord/Matrix stay on the zero-overhead fast path" — suggesting these adapters don't need special handling. However, even if finalize is not used, the method signature must accept it to match the base class and avoid TypeError when stream_consumer.py calls edit_message(finalize=finalize).

Fix Action

Fix

Add *, finalize: bool = False to edit_message signature in all four adapters (matching the base class signature).

PR fix notes

PR #12601: fix(gateway): accept finalize kwarg in all platform edit_message overrides

Description (problem / solution / changelog)

What does this PR do?

Fixes a TypeError that crashes streaming on every non-DingTalk gateway platform.

stream_consumer._send_or_edit unconditionally passes finalize= to adapter.edit_message(...) (see gateway/stream_consumer.py:794), but only DingTalk's override accepts the kwarg. The REQUIRES_EDIT_FINALIZE capability flag added in 4459913f only gates the redundant final edit and the identical-text short-circuit — it does not gate the kwarg itself. So every adapter that opts out of finalize still receives the keyword argument and must accept it.

Affected adapters (7): telegram, discord, slack, matrix, mattermost, feishu, whatsapp. Crash fires the first time a segment break (got_segment_break) or final edit (got_done) hits _send_or_edit:

TypeError: TelegramAdapter.edit_message() got an unexpected keyword argument 'finalize'

Related Issue

Fixes #12579

Type of Change

  • Bug fix (crash)

Changes Made

  • gateway/platforms/{telegram,discord,slack,matrix,mattermost,feishu,whatsapp}.py: add *, finalize: bool = False to edit_message override. Body ignores the arg — these platforms treat edits as stateless, consistent with the base class contract in gateway/platforms/base.py:1067 (the class docstring explicitly calls out Telegram/Slack/Discord/Matrix as no-op finalize consumers).
  • tests/gateway/test_stream_consumer.py: add TestEditMessageFinalizeSignature — a parametrized inspect.signature check over every concrete adapter class. Existing finalize tests use MagicMock which swallows any kwarg and cannot catch an adapter override that drops finalize; this regression guard fails loudly if a future adapter forgets it.

Issue reporter listed 4 adapters but a repo-wide scan found 7 — mattermost, feishu, whatsapp also missed the kwarg.

How to Test

Without the fix, streaming any message on e.g. Telegram crashes when the stream consumer fires its final-edit path. With the fix:

pytest tests/gateway/test_stream_consumer.py -v

The 8 new test_edit_message_accepts_finalize[...] cases pass for every adapter class. All existing 67 stream_consumer tests still pass (75 total).

Checklist

  • Branch cut from current main (was 701 commits behind, fast-forwarded)
  • No hardcoded ~/.hermes — not applicable, pure signature change
  • pytest tests/gateway/test_stream_consumer.py passes (75/75)
  • git diff --stat contains only the 8 relevant files
  • Regression test included
  • Conventional Commits format
  • One logical change (signature fix + its test)

AI Disclosure

This bug was diagnosed and fixed with AI assistance.

Changed files

  • gateway/platforms/discord.py (modified, +2/-0)
  • gateway/platforms/feishu.py (modified, +2/-0)
  • gateway/platforms/matrix.py (modified, +1/-1)
  • gateway/platforms/mattermost.py (modified, +1/-1)
  • gateway/platforms/slack.py (modified, +2/-0)
  • gateway/platforms/telegram.py (modified, +2/-0)
  • gateway/platforms/whatsapp.py (modified, +2/-0)
  • scripts/release.py (modified, +1/-0)
  • tests/gateway/test_stream_consumer.py (modified, +37/-0)

PR #12828: fix(gateway): add missing finalize parameter to edit_message in all platform adapters

Description (problem / solution / changelog)

What changed

Added the finalize: bool = False parameter to edit_message() method signatures in all 7 platform adapters that were missing it (Discord, Feishu, Matrix, Mattermost, Slack, Telegram, WhatsApp). The base class PlatformAdapter.edit_message() already defined this parameter, but the subclass overrides did not — causing TypeError when the gateway attempted to pass finalize=True during streaming message finalization.

Before: When the gateway called adapter.edit_message(..., finalize=True) to signal the last edit in a streaming sequence, adapters that didn't accept the parameter would raise TypeError.

After: All adapters accept the finalize parameter consistently with the base class signature, with a default of False for backward compatibility.

How to test

  1. Start a gateway session with any platform adapter
  2. Send a message that triggers streaming edits
  3. Verify the final edit completes without TypeError
  4. Run the test suite:
    pytest tests/gateway/test_edit_message_finalize.py -v

Platforms tested

  • Linux (Docker container, Python 3.11)

Closes #12579

Changed files

  • gateway/platforms/discord.py (modified, +2/-0)
  • gateway/platforms/feishu.py (modified, +2/-0)
  • gateway/platforms/matrix.py (modified, +1/-1)
  • gateway/platforms/mattermost.py (modified, +1/-1)
  • gateway/platforms/slack.py (modified, +2/-0)
  • gateway/platforms/telegram.py (modified, +2/-0)
  • gateway/platforms/whatsapp.py (modified, +2/-0)
  • tests/gateway/test_edit_message_finalize.py (added, +324/-0)

PR #12854: fix(gateway): accept finalize kwarg in all platform edit_message overrides

Description (problem / solution / changelog)

Summary

Streaming no longer raises TypeError on Telegram, Discord, Slack, Matrix, Mattermost, Feishu, or WhatsApp.

Commit 4459913f added finalize: bool = False to BasePlatformAdapter.edit_message() and made stream_consumer._send_or_edit pass it unconditionally, but only DingTalk's override accepted it — every other adapter hit TypeError on the first edit. Salvaged from #12601 by @jackjin1997.

Changes

  • 7 adapter overrides gain *, finalize: bool = False to match the base signature
  • tests/gateway/test_stream_consumer.py: new TestEditMessageFinalizeSignature parametrized inspect.signature check across all 8 adapters
  • scripts/release.py: add jackjin1997's qq email to AUTHOR_MAP

Validation

  • scripts/run_tests.sh tests/gateway/test_stream_consumer.py — 75/75 passed
  • E2E: imported all 7 adapter classes, verified edit_message has finalize KEYWORD_ONLY with default False, and sig.bind(..., finalize=True) succeeds on each

Closes #12579. Supersedes #12163, #12288, #12364, #12828.

Changed files

  • gateway/platforms/discord.py (modified, +2/-0)
  • gateway/platforms/feishu.py (modified, +2/-0)
  • gateway/platforms/matrix.py (modified, +1/-1)
  • gateway/platforms/mattermost.py (modified, +1/-1)
  • gateway/platforms/slack.py (modified, +2/-0)
  • gateway/platforms/telegram.py (modified, +2/-0)
  • gateway/platforms/whatsapp.py (modified, +2/-0)
  • scripts/release.py (modified, +1/-0)
  • tests/gateway/test_stream_consumer.py (modified, +37/-0)

Code Example

TypeError: TelegramAdapter.edit_message() got an unexpected keyword argument 'finalize'
RAW_BUFFERClick to expand / collapse

Bug Description

Commit 4459913f (feat(dingtalk): AI Cards streaming) added finalize: bool = False parameter to BasePlatformAdapter.edit_message() and updated stream_consumer.py to pass this parameter. However, only the DingTalk adapter was updated to accept it.

The following adapters still have the old signature without finalize:

  • gateway/platforms/telegram.py
  • gateway/platforms/discord.py
  • gateway/platforms/slack.py
  • gateway/platforms/matrix.py

Error

When streaming messages on these platforms:

TypeError: TelegramAdapter.edit_message() got an unexpected keyword argument 'finalize'

Root Cause

The commit message states: "Default False so Telegram/Slack/Discord/Matrix stay on the zero-overhead fast path" — suggesting these adapters don't need special handling. However, even if finalize is not used, the method signature must accept it to match the base class and avoid TypeError when stream_consumer.py calls edit_message(finalize=finalize).

Fix

Add *, finalize: bool = False to edit_message signature in all four adapters (matching the base class signature).

extent analysis

TL;DR

Update the edit_message method signature in the unaffected adapters to include the finalize: bool = False parameter to match the base class signature.

Guidance

  • Identify the adapters that need updates: telegram.py, discord.py, slack.py, and matrix.py.
  • Add *, finalize: bool = False to the edit_message method signature in each of these adapters.
  • Verify that the updated adapters can accept the finalize parameter without raising a TypeError.
  • Test the streaming functionality on each platform to ensure it works as expected with the updated adapters.

Example

class TelegramAdapter(BasePlatformAdapter):
    # ...
    def edit_message(self, *, finalize: bool = False):
        # method implementation
        pass

Notes

This fix assumes that the adapters do not require special handling for the finalize parameter, as indicated by the commit message. If special handling is needed, additional implementation changes may be required.

Recommendation

Apply the workaround by updating the adapters' edit_message method signatures to include the finalize parameter, as this will resolve the immediate TypeError issue and allow streaming to function on the affected platforms.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix edit_message missing finalize parameter in Telegram/Discord/Slack/Matrix adapters [3 pull requests, 1 participants]