fix(gateway): explicit tool_progress new/all keeps text progress in un-cardable Slack chats

The destination preflight / refusal path suppressed the whole progress lane
for a flat DM regardless of mode, so an operator who WROTE `tool_progress:
all` got nothing there (before #108668 they got text bubbles via the
fallback). Silence is right only for Slack's tier default, where no text
lane was asked for; explicit new/all now routes through the editable text
fallback instead. Also hoists resolve_tool_progress into the existing
display_config import in _run_agent_display_settings.

Test proven red on the salvaged head (adapter.sent == [] with `all`).
This commit is contained in:
teknium1
2026-09-14 07:10:45 -07:00
committed by Teknium
parent e9c037f65a
commit 4748caff76
5 changed files with 65 additions and 23 deletions
+1 -2
View File
@@ -2704,7 +2704,7 @@ class GatewayTurnMixin:
_gateway_platform_value, _has_platform_display_override, _load_gateway_config,
_platform_config_key,
)
from gateway.display_config import resolve_display_setting
from gateway.display_config import resolve_display_setting, resolve_tool_progress
from gateway.status_phrases import choose_status_phrase, resolve_status_phrase_catalog
user_config = _load_gateway_config()
platform_key = _platform_config_key(source.platform)
@@ -2721,7 +2721,6 @@ class GatewayTurnMixin:
getattr(_agent_display, _setter)(_cast(_val))
# Resolve the mode and its provenance together: null inherits, tier off is not intent.
from gateway.display_config import resolve_tool_progress
progress_mode, _tool_progress_explicit = resolve_tool_progress(
user_config, platform_key, os.getenv("HERMES_TOOL_PROGRESS_MODE"),
)
+29 -17
View File
@@ -408,8 +408,9 @@ class TurnRunner:
if callable(destination_supported) and destination_supported(
ctx.source.chat_id, reply_to=ctx._progress_reply_to, metadata=ctx._progress_metadata,
) is False:
st.publication_suppressed = True
return
self._task_card_uncardable_destination(st)
if st.publication_suppressed:
return
if not st.native_failed:
result = await st.adapter.send_native_task_card_progress(
chat_id=ctx.source.chat_id, tasks=st.visible_tasks(), title="Hermes is working",
@@ -439,25 +440,36 @@ class TurnRunner:
return
st.native_failed = True
if getattr(result, "error", None) in _CARD_DESTINATION_REFUSALS:
# The destination itself cannot host a card (flat DM: no thread anchor). This is
# a property of the chat, not a transient outage, and it repeats on every event.
# The text fallback exists to keep a WORKING card lane live through a transient
# native failure, not to turn an un-cardable chat into text bubbles; the lane
# goes silent for this turn whatever the configured mode.
st.publication_suppressed = True
logger.info(
"Slack native task cards are unsupported for this destination "
"(%s); tool progress stays off for this turn",
getattr(result, "error", "unknown error"),
self._task_card_uncardable_destination(st, getattr(result, "error", "unknown error"))
if st.publication_suppressed:
return
else:
logger.warning(
"Slack native task-card progress failed; falling back "
"to an editable text update: %s", getattr(result, "error", "unknown error"),
)
return
logger.warning(
"Slack native task-card progress failed; falling back "
"to an editable text update: %s", getattr(result, "error", "unknown error"),
)
# Once the native rail fails, every later lifecycle event edits the same fallback message.
await self._task_card_send_or_edit_fallback(st)
def _task_card_uncardable_destination(self, st, reason: str = "no thread anchor") -> None:
"""The chat cannot host a card (flat DM: no thread anchor) — a property of the destination,
not a transient outage. The text fallback exists to keep a WORKING card lane live through a
transient failure, not to invent text bubbles the operator never asked for: with Slack's tier
default (``tool_progress: off``) the lane goes silent for the turn. An operator who WROTE
``new``/``all`` asked for text progress, so the editable fallback carries it instead."""
if self._ctx.tool_progress_enabled:
st.native_failed = True
logger.info(
"Slack native task cards are unsupported for this destination (%s); "
"tool progress continues as an editable text update", reason,
)
return
st.publication_suppressed = True
logger.info(
"Slack native task cards are unsupported for this destination (%s); "
"tool progress stays off for this turn", reason,
)
def _task_card_drain(self, st) -> bool:
changed = False
try:
+28
View File
@@ -1263,6 +1263,34 @@ async def test_slack_unsupported_card_destination_does_not_degrade_to_text_progr
assert adapter.edits == []
@pytest.mark.asyncio
async def test_slack_explicit_all_in_unsupported_card_destination_falls_back_to_text(
monkeypatch, tmp_path
):
# Same flat DM, but the operator WROTE ``tool_progress: all``: they asked for text progress,
# so an un-cardable chat carries it through the editable fallback instead of going silent.
adapter, result = await _run_with_agent(
monkeypatch,
tmp_path,
DuplicateNativeToolsAgent,
session_id="sess-native-unsupported-dest-all",
config_data={"display": {"platforms": {"slack": {"tool_progress": "all"}}}},
platform=Platform.SLACK,
chat_id="D1",
chat_type="dm",
thread_id=None,
adapter_cls=UnsupportedDestinationTaskCardAdapter,
user_id="U1",
scope_id="T1",
)
assert result["final_response"] == "done"
assert len(adapter.native_updates) == 1
assert len(adapter.sent) == 1
assert adapter.edits
assert "web_search" in adapter.edits[-1]["content"]
@pytest.mark.asyncio
async def test_retryable_overflow_edit_keeps_editable_bubble_identity(monkeypatch, tmp_path):
"""A transient split edit must retain can_edit and the current message ID."""
@@ -64,6 +64,7 @@ async def run_progress(adapter, metadata, reply_to, after_first=None):
ctx = SimpleNamespace(
source=SimpleNamespace(chat_id="D1"), _progress_reply_to=reply_to,
_progress_metadata=metadata, _cleanup_progress=False, progress_queue=events,
tool_progress_enabled=False, # Slack tier default: no text lane was asked for
_run_still_current=lambda: not events.empty(), agent_holder=[None],
)
await TurnRunner(None, ctx)._send_native_task_card_progress(adapter)
+6 -4
View File
@@ -432,7 +432,8 @@ platforms:
# Render live tool calls as Slack-native plan/task cards. Works with
# Slack's built-in tool_progress: off default; a tool_progress: off you
# write yourself disables cards too. Cards need a thread: an un-threaded
# chat shows no tool progress. Recoverable native API failures keep one
# chat shows no tool progress (text progress if you wrote new/all).
# Recoverable native API failures keep one
# editable text fallback current for the rest of the turn.
native_task_cards: false
@@ -469,7 +470,7 @@ platforms:
| `platforms.slack.extra.unfurl_media` | Slack default | Set to `false` to suppress automatic media previews while preserving clickable links. Same caption-ordering and streaming notes as `unfurl_links`. |
| `platforms.slack.extra.rich_blocks` | `false` | When `true`, agent messages are rendered as [Block Kit](https://docs.slack.dev/block-kit/) blocks (headers, dividers, true nested lists, and native tables). A plain-text fallback is always sent. Tables over Slack's limits fall back to aligned monospace. No app reinstall required — it's a send-side change only. |
| `platforms.slack.extra.feedback_buttons` | `false` | When `true` with `rich_blocks`, appends Slack-native feedback controls to final replies. |
| `platforms.slack.extra.native_task_cards` | `false` | When `true`, renders live tool calls as Slack-native plan/task cards. Cards work with Slack's built-in default `tool_progress: off`; an explicitly configured `display.tool_progress: off` (global or `display.platforms.slack`; `/verbose` writes the same key) disables cards too. Cards need a thread: when the card lane is active and the chat has no thread to anchor on (a top-level DM with `reply_in_thread: false`), Hermes shows no tool progress instead of text bubbles. Recoverable native API failures fall back to one continuously edited text update. |
| `platforms.slack.extra.native_task_cards` | `false` | When `true`, renders live tool calls as Slack-native plan/task cards. Cards work with Slack's built-in default `tool_progress: off`; an explicitly configured `display.tool_progress: off` (global or `display.platforms.slack`; `/verbose` writes the same key) disables cards too. Cards need a thread: when the card lane is active and the chat has no thread to anchor on (a top-level DM with `reply_in_thread: false`), Hermes shows no tool progress instead of text bubbles, unless you explicitly set `tool_progress: new`/`all`, which falls back to editable text progress there. Recoverable native API failures fall back to one continuously edited text update. |
| `platforms.slack.extra.suggested_prompts` | `[]` | Up to four `{title, message}` prompts for Agent/Assistant DM entry points; accepts either a list or `{title, prompts}`. |
| `platforms.slack.extra.assistant_thread_titles` | `true` | When `true`, names Agent/Assistant DM threads from the first user message. |
| `platforms.slack.extra.allow_bots` | `"none"` | Controls messages from other Slack bots: `"none"` ignores them, `"mentions"` accepts a bot message only when **that message itself** @mentions Hermes, and `"all"` accepts all of them. Use `"mentions"` for the safest bot-to-bot collaboration mode. See [Accepting messages from other bots](#accepting-messages-from-other-bots-allow_bots). |
@@ -584,8 +585,9 @@ platforms:
when the next turn resolves its display settings.
- Cards need a thread. With the card lane active, a chat that has no thread to
anchor on (a top-level DM under `reply_in_thread: false`) shows no tool
progress at all rather than text bubbles; replies inside an existing thread
still get cards.
progress rather than text bubbles under Slack's default `tool_progress: off`;
if you wrote `new` or `all`, that chat gets the editable text progress you
asked for. Replies inside an existing thread still get cards.
- Concurrent calls to the same tool are correlated by real tool-call ID, so
parallel `web_search` calls each get their own row with the right status.
- Hermes checks thread eligibility before attempting publication, so a