fix: follow-up for salvaged PR #65187 — add missing compression_state to 5th call site, force-redact error text at gateway boundaries

This commit is contained in:
kshitijk4poor 2026-07-16 13:33:06 +05:30 committed by kshitij
parent 1e895f4c17
commit e844ea9f0b
2 changed files with 11 additions and 0 deletions

View file

@ -11603,6 +11603,11 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew
_comp = getattr(_hyg_agent, "context_compressor", None)
if _comp is not None and getattr(_comp, "_last_compress_aborted", False):
_err = getattr(_comp, "_last_summary_error", None) or "unknown error"
# Force-redact: provider exception text
# may contain credentials; this message
# reaches gateway users directly.
from agent.redact import redact_sensitive_text
_err = redact_sensitive_text(_err, force=True)
_warn_msg = (
"⚠️ Context compression aborted "
f"({_err}). No messages were dropped — "

View file

@ -3345,6 +3345,7 @@ class GatewaySlashCommandsMixin:
compressed,
approx_tokens,
new_tokens,
compression_state=compressor,
)
# Detect summary-generation failure so we can surface a
# visible warning to the user even on the manual /compress
@ -3355,6 +3356,11 @@ class GatewaySlashCommandsMixin:
# passed above so any active cooldown is bypassed.
_summary_aborted = bool(getattr(compressor, "_last_compress_aborted", False))
_summary_err = getattr(compressor, "_last_summary_error", None)
# Force-redact provider exception text at this UI boundary
# even when global redaction is disabled.
if _summary_err:
from agent.redact import redact_sensitive_text
_summary_err = redact_sensitive_text(_summary_err, force=True)
# Separately: did the user's CONFIGURED aux model fail
# and we recovered via main? Surface that as an info
# note so they can fix their config.