Skip to content

fix: inline Slack block and attachment context - #11426

Closed
Wang-tianhao wants to merge 1 commit into
NousResearch:mainfrom
Wang-tianhao:fix/slack-inline-block-context
Closed

fix: inline Slack block and attachment context#11426
Wang-tianhao wants to merge 1 commit into
NousResearch:mainfrom
Wang-tianhao:fix/slack-inline-block-context

Conversation

@Wang-tianhao

Copy link
Copy Markdown
Contributor

Summary

  • inline redacted Slack Block Kit payloads for non-rich_text messages so the agent can inspect the current message structure
  • extract nested rich_text quotes/lists into readable text and surface link unfurl attachment previews
  • preserve routing semantics by keeping mention detection and slash-command detection based on the original user text
  • update Slack platform notes and add regression coverage for block payloads, quotes/lists, unfurls, redaction, and routing

Why

Slack blocks and attachment previews were present in the incoming payload but only stored in raw_message, so the model could not inspect them. This made the agent blind to block-heavy alerts and other structured Slack content.

Test Plan

  • source venv/bin/activate && pytest tests/gateway/test_slack.py -q
  • source venv/bin/activate && pytest tests/gateway/test_session.py -q

Notes

This is effectively a bug fix for the Slack adapter's message normalization path: the gateway already received the structured payload, but the model-visible text dropped it.

- extract quote/list rich_text content into agent-visible text
- inline redacted non-rich-text Block Kit payloads
- surface link unfurl attachment previews without affecting routing
- document and test Slack block/attachment visibility
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/slack Slack app adapter labels Apr 24, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #16213 — your commit was cherry-picked onto current main with your authorship preserved (9904f15). Thanks for the thorough work on the rich_text tree walk and the careful routing guard that keeps mention-gating / slash-command classification anchored to the original user text.

One adjustment: dropped _serialize_slack_blocks_for_agent (the JSON dump of non-rich_text Block Kit payloads). It added up to 6000 characters of inlined JSON into the prompt context on every qualifying message with no opt-out. The rich_text quote/list/preformatted extraction and the link-unfurl attachment previews land the clear bug-fix (agent no longer blind to forwarded content / shared-link previews) without that prefill tax. If a concrete plugin or use case needs block-structure inspection later, it can return behind a config opt-in.
#16213

nikitaBarkov added a commit to JetBrains/hermes-agent that referenced this pull request Aug 10, 2026
`_serialize_slack_blocks_for_agent()` inlines a redacted JSON view of the
message's blocks so the agent can inspect structure it cannot otherwise
read. NousResearch#11426 introduced it "for non-`rich_text` messages", but the guard
bailed out only when *every* block was `rich_text`, so a single bot
`section` alongside the user's own text dumped that text as well.

`rich_text` is the authored message, already rendered into the message text
by `_extract_text_from_slack_blocks()`. Repeating it is duplication on its
own, and because the scalar allowlist drops `url` by design, the repeat
arrives as the same sentence with every link deleted and a double space
where the link used to be. Only non-`rich_text` blocks are serialized now;
`section`, `actions` and accessory blocks are still described in full.
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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants