fix(gateway): normalize empty agent responses in inner runner early-return

When _run_agent_inner returns via its "not final_response" early path
(e.g. an output-length truncation with no visible assistant text), it
returned the raw "⚠️ Response truncated due to output length limit"
string as final text. Messaging gateways then echoed that to users.

Route this path through _normalize_empty_agent_response +
_sanitize_gateway_final_response — the same treatment the outer
_handle_message_with_agent path already applies — so users see the
friendly "⚠️ Processing stopped: … Try again." instead, falling back to
the raw error only when normalization yields nothing.

Salvaged from #48034 by @djimit (gateway normalization half only; the
retry-count/token-boost tuning in conversation_loop.py was dropped as
symptom-tuning of an already-working recovery loop).
This commit is contained in:
Dutch Dim 2026-07-01 04:30:55 -07:00 committed by teknium1
parent fb7a38ad21
commit 74ae07b612
No known key found for this signature in database
3 changed files with 44 additions and 2 deletions

View file

@ -46,6 +46,7 @@ ACP_REGISTRY_MANIFEST = REPO_ROOT / "acp_registry" / "agent.json"
# Auto-extracted from noreply emails + manual overrides
AUTHOR_MAP = {
"mac-studio@Fabios-Mac-Studio.local": "valenteff", # PR #53277 salvage (macOS launchd reload: retry bootstrap via _launchctl_bootstrap until launchctl-list confirms registration or the restart-drain window elapses; retry TimeoutExpired not just CalledProcessError; log persistent orphans)
"info@djimit.nl": "djimit", # PR #48034 salvage (normalize empty agent responses in the proxy/inner runner's not-final_response early return so gateways surface "⚠️ Processing stopped: … Try again." instead of a raw truncation error)
"gary@bitcryptic.com": "bitcryptic-gw", # PR #53997 salvage (Matrix E2EE: resolve device_id via query_keys({mxid: []}) when whoami returns none; guard verification call sites so query_keys is never sent [null]; reset _device_id_unverified at connect() start; disconnect before reconnect)
"7698789+abchiaravalle@users.noreply.github.com": "abchiaravalle", # PR #46997 salvage (recover resume_pending sessions: dual freshness signal + empty-turn safety net so restart auto-resume never sends a blank user turn)
"swissly@users.noreply.github.com": "swissly", # PR #47167 salvage (wrap cron delivery thread-pool fallback in its own try/except so a per-target failure can't escape the except-RuntimeError block and crash the multi-target delivery loop; #47163)