feat(gateway): opt-in cleanup of temporary progress bubbles (#21186)

When display.cleanup_progress (or display.platforms.<plat>.cleanup_progress)
is true, the gateway deletes tool-progress bubbles, long-running ' Still
working...' notices, and status-callback messages after the final response
is delivered successfully. Currently effective on adapters that implement
delete_message (Telegram); silently no-ops elsewhere. Off by default.
Failed runs skip cleanup so bubbles stay as breadcrumbs.

Minimal plumbing: base.py's existing post_delivery_callback slot now chains
new registrations onto any existing callback (with per-callback exception
isolation) rather than clobbering. Stale-generation registrations are
rejected so they can't step on a fresher run's callbacks. This lets the
cleanup callback coexist with the background-review release hook already
registered on the same slot.

Co-authored-by: mrcharlesiv <Mrcharlesiv@gmail.com>
This commit is contained in:
Teknium 2026-05-07 05:04:37 -07:00 committed by GitHub
parent 7c0766e06a
commit bf843adf05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 700 additions and 4 deletions

View file

@ -333,3 +333,64 @@ class TestStreamingPerPlatform:
}
}
assert resolve_display_setting(config, "email", "streaming") is True
# ---------------------------------------------------------------------------
# cleanup_progress — opt-in deletion of temporary progress bubbles
# ---------------------------------------------------------------------------
class TestCleanupProgress:
"""``cleanup_progress`` is off by default and resolvable per-platform."""
def test_default_off_for_all_platforms(self):
"""No config set → cleanup_progress resolves to False everywhere."""
from gateway.display_config import resolve_display_setting
for plat in ("telegram", "discord", "slack", "email"):
assert resolve_display_setting({}, plat, "cleanup_progress") is False
def test_global_true_applies_to_all_platforms(self):
"""display.cleanup_progress=true opts in globally."""
from gateway.display_config import resolve_display_setting
config = {"display": {"cleanup_progress": True}}
assert resolve_display_setting(config, "telegram", "cleanup_progress") is True
assert resolve_display_setting(config, "discord", "cleanup_progress") is True
def test_per_platform_override_wins(self):
"""display.platforms.<plat>.cleanup_progress beats the global value."""
from gateway.display_config import resolve_display_setting
config = {
"display": {
"cleanup_progress": False,
"platforms": {
"telegram": {"cleanup_progress": True},
},
}
}
assert resolve_display_setting(config, "telegram", "cleanup_progress") is True
assert resolve_display_setting(config, "discord", "cleanup_progress") is False
def test_yaml_off_string_normalises_to_false(self):
"""YAML 1.1 bare ``off`` becomes string 'off' — treat as False."""
from gateway.display_config import resolve_display_setting
config = {
"display": {
"platforms": {"telegram": {"cleanup_progress": "off"}},
}
}
assert resolve_display_setting(config, "telegram", "cleanup_progress") is False
def test_yaml_true_string_normalises_to_true(self):
"""String 'true'/'yes'/'on' all resolve to True."""
from gateway.display_config import resolve_display_setting
for val in ("true", "yes", "on", "1"):
config = {
"display": {
"platforms": {"telegram": {"cleanup_progress": val}},
}
}
assert resolve_display_setting(config, "telegram", "cleanup_progress") is True, val