The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): hard-bound the share_nous client-text scrub window for single-line input
kshitijk4poor7d04a125fc34
diff --git a/tests/tui_gateway/test_diagnostics_share_nous.py b/tests/tui_gateway/test_diagnostics_share_nous.pyindex 50725205440..7c3c8b83ac0 100644--- a/tests/tui_gateway/test_diagnostics_share_nous.py+++ b/tests/tui_gateway/test_diagnostics_share_nous.py@@ -143,8 +143,8 @@ def test_redacted_support_egress_scrubs_structured_values_and_errors(assert "support-fixture" in renderedassert not [canary for canary in canaries.values() if canary in rendered]- # An oversized client value is scrubbed through a line-aligned 2x-cap window- # (bounded cost), with the same capped output as scrubbing the whole value.+ # An oversized client value is scrubbed through a bounded window (line-aligned+ # when a line ends in [2x, 3x) cap), with the same capped output as a full scrub.import hermes_cli.debug_redaction as drreal_redact, scrubbed_sizes = dr.redact_debug_support_text, []@@ -160,6 +160,12 @@ def test_redacted_support_egress_scrubs_structured_values_and_errors(big_context = _envelope(captured_upload["blob"])["files"]["error-context.txt"]assert max(scrubbed_sizes) <= 2 * 8_000 + len(line)assert big_context == real_redact((line * 2_000).strip(), max_chars=8_000)+ scrubbed_sizes.clear()+ monkeypatch.setattr(dr, "redact_debug_support_text", _spy)+ one_line = f"cookie={canaries['header']} " + "x" * 2_000_000+ assert _handler()("rid-one-line", {"error_context": one_line})["result"]["ok"] is True+ monkeypatch.setattr(dr, "redact_debug_support_text", real_redact)+ assert max(scrubbed_sizes) <= 3 * 8_000import hermes_cli.diagnostics_upload as dudiff --git a/tui_gateway/methods_config.py b/tui_gateway/methods_config.pyindex 51202890e50..2b81cdfd15f 100644--- a/tui_gateway/methods_config.py+++ b/tui_gateway/methods_config.py@@ -482,13 +482,15 @@ def _(rid, params: dict) -> dict:def _redact_client_text(text: str, cap: int) -> str:- """Strict-scrub client text, then cap it. The scrub sees a line-aligned window of- 2x the cap so a key cut by the cap still gets redacted, but an unbounded RPC- param cannot make the superlinear scrub run on megabytes."""+ """Strict-scrub client text, then cap it. The scrub sees at most 3x the cap: the+ first line end in [2x, 3x) cap, else a hard 2x-cap cut, so a key cut by the cap+ still gets redacted but an unbounded (even single-line) RPC param cannot make+ the superlinear scrub run on megabytes."""from hermes_cli.debug_redaction import redact_debug_support_text- cut = text.find("\n", 2 * cap)- return redact_debug_support_text(text if cut < 0 else text[: cut + 1], max_chars=cap)+ cut = text.find("\n", 2 * cap, 3 * cap)+ window = text[: cut + 1] if cut >= 0 else text[: 2 * cap]+ return redact_debug_support_text(window, max_chars=cap)def _safe_client_label(label: str) -> str: