Skip to content

fix(slack): guard against empty text in chat.postMessage (#52663) - #52672

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/slack-empty-text-guard
Closed

fix(slack): guard against empty text in chat.postMessage (#52663)#52672
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/slack-empty-text-guard

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Guards against Slack no_text API errors when chat.postMessage is called with empty or whitespace-only text. This occurs when cron delivery posts an agent response before the agent produces content (e.g. a malformed turn before [SILENT]).

Related Issue

Fixes #52663

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • plugins/platforms/slack/adapter.py: Add early-return empty-text guard in _standalone_send() (out-of-process cron delivery) and send() (in-process gateway adapter). Both paths now skip the API call and return success when formatted text is empty/whitespace.
  • tests/gateway/test_slack.py: Add TestEmptyTextGuard class with 4 tests covering both empty string and whitespace-only inputs for both send paths.

How to Test

  1. Run pytest tests/gateway/test_slack.py::TestEmptyTextGuard -xvs — all 4 tests should pass.
  2. Run pytest tests/gateway/test_slack.py -q — all 213 tests should pass (no regressions).
  3. Run pytest tests/tools/test_send_message_tool.py -q — all 146 tests should pass (standalone sender integration).

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Code Intelligence

  • Analyzed: plugins/platforms/slack/adapter.py (_standalone_send, send)
  • Blast radius: LOW — additive guard, no existing behavior changed
  • Related patterns: Other adapters (Discord, Telegram) have similar empty-text handling at the base adapter level

Slack API returns `no_text` error when `chat.postMessage` is called
with empty or whitespace-only text. This happens when cron delivery
posts a response before the agent produces content (e.g. malformed
turn before [SILENT]).

Add early-return guards in both code paths:
- `_standalone_send()`: out-of-process cron delivery via Web API
- `send()`: in-process gateway adapter

Both paths now skip the API call and return success when the formatted
message is empty or whitespace-only.

Fixes NousResearch#52663
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/slack Slack app adapter P2 Medium — degraded but workaround exists labels Jun 25, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for addressing the verified Slack cron-delivery failure. The proposed guards cover the normal send() path and the standalone sender, but one direct chat_postMessage path remains.

Problems

  • plugins/platforms/slack/adapter.py:3547-3559 posts result_text from slash_confirm.resolve() whenever it is truthy. tools/slash_confirm.py:140 returns any handler result that is a str, so a whitespace-only result passes if result_text and is posted to Slack, reproducing the same no_text failure class.

Suggested changes

  • Apply the same whitespace check to the slash-confirm follow-up before its direct chat_postMessage call, ideally via a shared predicate, and add a regression test for a whitespace-only resolved result.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #69317 — your commit was cherry-picked onto current main with your authorship preserved in git history: your empty-text postMessage guard was cherry-picked directly.

Thanks for the contribution!

@teknium1 teknium1 closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/slack Slack app adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BLOCKER: Slack chat.postMessage no_text when cron delivers empty/minimal agent response

3 participants