fix(gateway): salvage 6 gateway fix PRs #6942 #6935 #6921 #6897 #6853 #6811#7123
Merged
Conversation
When /background was sent during an active run, it was not in the platform adapter's bypass list and fell through to the interrupt path instead of spawning a parallel background task. Add "background" to the active-session command bypass in the platform adapter, and add an early return in the gateway runner's running-agent guard to route /background to _handle_background_command() before it reaches the default interrupt logic. Fixes #6827
Adds a regression test verifying that /background bypasses the active-session guard in the platform adapter, matching the existing test pattern for /stop, /new, /approve, /deny, and /status.
…am and Feishu Python assertions are stripped when running with `python -O` (optimized mode), making them unsuitable for runtime error handling. 1. `telegram_network.py:113` — After exhausting all fallback IPs, the code uses `assert last_error is not None` before `raise last_error`. In optimized mode, the assert is skipped; if `last_error` is unexpectedly None, `raise None` produces a confusing `TypeError` instead of a meaningful error. Replace with an explicit `if` check that raises `RuntimeError` with a descriptive message. 2. `feishu.py:975` — The `_configure_with_overrides` closure uses `assert original_configure is not None` as a guard. While the outer scope only installs this closure when `original_configure` is not None, the assert would silently disappear in optimized mode. Replace with an explicit `if` check for defensive safety.
- configure Telegram HTTPXRequest pool/timeouts with env-overridable defaults\n- use separate request/get_updates request objects to reduce pool contention\n- skip fallback-IP transport when proxy is configured (or explicitly disabled)\n\nThis mitigates recurrent pool-timeout failures during polling reconnect/bootstrap (delete_webhook).
Platforms that don't return a message_id after the first send (Signal, GitHub webhooks) were causing GatewayStreamConsumer to re-enter the "first send" path on every tool boundary, posting one platform message per tool call (observed as 155 PR comments on a single response). Fix: treat _message_id == "__no_edit__" as a sentinel meaning "platform accepted the send but cannot be edited". When a tool boundary arrives in that state, skip the message_id/accumulated/last_sent_text reset so all continuation text is delivered once via _send_fallback_final rather than re-posted per segment. Also make prompt_toolkit imports in hermes_cli/commands.py optional so gateway and test environments that lack the package can still import resolve_command, gateway_help_lines, and COMMAND_REGISTRY.
- test_background_autocompletes: pytest.importorskip("prompt_toolkit")
so the test skips gracefully where the CLI dep is absent
- test_run_agent_progress_stays_in_originating_topic: update stale emoji
💻 → ⚙️ to match get_tool_emoji("terminal", default="⚙️") in run.py
- test_internal_event_bypass{_authorization,_pairing}: mock
_handle_message_with_agent to raise immediately; avoids the 300s
run_in_executor hang that caused the tests to time out
This was referenced Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvage of 6 gateway fix PRs onto current main. All contributor authorship preserved via cherry-pick.
Cherry-picked commits:
fix(gateway): avoid false failure reactions on restart cancellation #6942 (aquaright1) — Introduces
ProcessingOutcomeenum (SUCCESS/FAILURE/CANCELLED) replacing booleansuccessparam inon_processing_complete(). Prevents false ❌ failure reactions on Discord/Telegram/Matrix when gateway restarts cancel background tasks.fix(gateway): route /background through active-session bypass #6935 (Tranquil-Flow) — Adds "background" to the active-session bypass list in
base.pyand early dispatch inrun.py. Without this,/backgroundgets queued as a pending message when an agent is running. Only the 3-file fix was cherry-picked — the PR's ~660 lines of unrelated changes (Mnemoria plugin, browser/vision/RL fixes) were excluded.fix(gateway): replace assertions with proper error handling in Telegram and Feishu #6921 (Cafexss) — Replaces
assertwithif/raise RuntimeErrorintelegram_network.pyandfeishu.py. Underpython -O, asserts are stripped, causing confusing TypeErrors.fix(gateway/telegram): reduce HTTPX pool-timeout failures during reconnect #6897 (borischou) — Increases HTTPX pool sizes/timeouts for Telegram adapter, makes them env-configurable, creates separate HTTPXRequest instances for request vs get-updates to reduce contention, skips fallback-IP transport when proxy is configured.
fix(gateway): prevent duplicate messages on no-message-id platforms #6853 (KUSH42) — Fixes duplicate message flood on platforms without message IDs (Signal, webhooks). The
__no_edit__sentinel was being reset on every tool-call boundary, re-entering the "first send" path. Also repairs 3 pre-existing test failures.fix(gateway): use platform-aware force-kill semantics for stale gateway PIDs #6811 (Dusk1e) — Centralizes PID termination into
terminate_pid()helper ingateway/status.pyusingtaskkillon Windows instead ofSIGKILL(which doesn't exist there).Also closed (not merged):
refresh_launchd_plist_if_needed()already does bootout+bootstrap internallyTest results
test_run_progress_topics.py(missing_session_model_overridesattribute —object.__new__()test pattern issue, exists on main)