Skip to content

fix(gateway): avoid false failure reactions on restart cancellation - #6322

Closed
bobashopcashier wants to merge 1 commit into
NousResearch:mainfrom
bobashopcashier:aquaright1/fix/6315-restart-cancel-reactions
Closed

fix(gateway): avoid false failure reactions on restart cancellation#6322
bobashopcashier wants to merge 1 commit into
NousResearch:mainfrom
bobashopcashier:aquaright1/fix/6315-restart-cancel-reactions

Conversation

@bobashopcashier

Copy link
Copy Markdown
Contributor

Summary

  • add a shared ProcessingOutcome lifecycle enum so expected shutdown/restart cancellation is not treated as an ordinary processing failure
  • avoid false terminal failure reactions for Discord, Telegram, and Matrix when adapter background tasks are intentionally cancelled during gateway shutdown
  • keep genuine delivery failures and genuine exceptions mapped to failure, with regression coverage for both expected and unexpected cancellation paths

What this addresses

Fixes #6315.

Related historical issue: #1414.

Follow-up to PR #1427.

Issue #1414 and PR #1427 fixed an important shutdown bug: old gateway instances could keep unwinding in-flight work after shutdown/replacement because adapter background tasks were not canceled and running agents were not interrupted.

Current main still had a narrower remaining UX bug for reaction-capable adapters:

  • gateway/platforms/base.py mapped any asyncio.CancelledError to processing failure
  • Discord, Telegram, and Matrix all mapped that failure path to a terminal
  • intentional self-restart or shutdown cancellation could therefore surface as a false failure reaction even when the cancellation was expected

This PR distinguishes expected shutdown/restart cancellation from real processing failure so the bot no longer reports a false red for that case.

Why this is a follow-up to #1427

PR #1427 made gateway shutdown actually cancel adapter background tasks and interrupt running agents.

That exposed the remaining lifecycle classification problem more clearly: once cancellation became deliberate and reliable during shutdown, the shared processing hook still treated that expected cancellation as a generic failure. This PR fixes that semantic gap without regressing genuine failure signaling.

Behavior By Platform

  • Discord: remove 👀 on expected cancellation and do not add a terminal
  • Telegram: leave the in-progress reaction untouched on expected cancellation instead of replacing it with
  • Matrix: do not add a terminal on expected cancellation
  • All three adapters still emit failure reactions for genuine exceptions and genuine delivery failures

Test plan

  • .venv/bin/python -m pytest tests/gateway/test_discord_reactions.py tests/gateway/test_telegram_reactions.py tests/gateway/test_base_topic_sessions.py tests/gateway/test_gateway_shutdown.py tests/gateway/test_matrix.py -n0 -q

@bobashopcashier
bobashopcashier force-pushed the aquaright1/fix/6315-restart-cancel-reactions branch from 5050813 to 238f1c5 Compare April 9, 2026 22:05
@bobashopcashier

Copy link
Copy Markdown
Contributor Author

Closing to reopen as a refreshed PR that follows the current contributing guide and PR template.

@bobashopcashier

Copy link
Copy Markdown
Contributor Author

Superseded by #6942, reopened on a fresh branch with the current contributing-guide/template format.

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.

fix(discord): avoid false ❌ on self-restart cancellation

1 participant