Skip to content

fix: truncate HITL card body to prevent silent Slack rejection - #8072

Merged
Mustafa-Esoofally merged 2 commits into
mainfrom
fix/slack-hitl-body-truncation
May 23, 2026
Merged

Mustafa-Esoofally merged 2 commits into
mainfrom
fix/slack-hitl-body-truncation

Conversation

@Mustafa-Esoofally

@Mustafa-Esoofally Mustafa-Esoofally commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Slack Block Kit rejects Card block body text longer than 200 characters with invalid_blocks error, causing HITL approval cards to silently fail to render. When this happens, agents pause indefinitely waiting for approval that can never come.

This fix truncates the card body text using the existing truncate() helper (already in types.py) before building the card.

Changes

  • Import truncate from agno.os.interfaces.slack.types
  • Apply truncate(body_text, 200) in _build_confirmation_card()
  • Apply truncate(body_text, 200) in build_confirmation_toggle_card()
  • Add 2 tests verifying truncation behavior

Root cause

Tool calls like comment_on_issue with 250+ character arguments cause the body text to exceed Slack's Card block body limit of 200 chars. The card post request returns ok: false with invalid_blocks error, but this was not being detected — the agent just hangs waiting for approval.

Note: Section blocks have a 3000 char limit, but agno's HITL cards use the newer Card block type (2024) which has stricter limits.

How it was discovered

agno-agi/coda#23 implemented a monkey-patch workaround (coda/slack_patches.py) to fix this. This PR moves the fix upstream where it belongs.

Test plan

  • Ruff passes
  • 46 unit tests pass (pytest libs/agno/tests/unit/os/routers/test_slack_blocks.py)
  • Added test_long_tool_args_truncated_to_200_chars for _build_confirmation_card
  • Added test_long_body_truncated_to_200_chars for build_confirmation_toggle_card

Slack Block Kit rejects section text >200 chars with invalid_blocks error,
causing HITL approval cards to never render. Uses existing truncate() helper.

Fixes issue discovered in agno-agi/coda#23 where comment_on_issue with
250+ char body caused approval UI to fail silently.
@Mustafa-Esoofally
Mustafa-Esoofally requested a review from a team as a code owner May 23, 2026 00:11
Verifies that body text >200 chars is truncated in both
_build_confirmation_card and build_confirmation_toggle_card.
@Mustafa-Esoofally Mustafa-Esoofally changed the title fix(slack): truncate HITL card body to prevent silent Slack rejection fix: truncate HITL card body to prevent silent Slack rejection May 23, 2026
@Mustafa-Esoofally
Mustafa-Esoofally merged commit 42b5126 into main May 23, 2026
5 of 7 checks passed
@Mustafa-Esoofally
Mustafa-Esoofally deleted the fix/slack-hitl-body-truncation branch May 23, 2026 00:28
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.

1 participant