Skip to content

The agent that grows with you

refactor(debug): simplify the truncated flag and hoist the share_nous import

kshitijk4poordba3144a4363
diff --git a/hermes_cli/debug.py b/hermes_cli/debug.py
index 219c1f99edc..fafdf3a2249 100644
--- a/hermes_cli/debug.py
+++ b/hermes_cli/debug.py
@@ -322,7 +322,7 @@ def _capture_log_snapshot(
all_text = all_text.split("\n", 1)[1] if "\n" in all_text else ""
tail_text = "".join(all_text.splitlines(keepends=True)[-tail_lines:]).rstrip("\n")
full_text, capped = _truncate_complete_lines(all_text, max_bytes)
- truncated = bool(start_offset or capped or size > max_bytes)
+ truncated = capped or size > max_bytes
if truncated:
full_text = f"[... truncated — showing last ~{max_bytes // 1024}KB ...]\n{full_text}"
return LogSnapshot(path=log_path, tail_text=tail_text, full_text=full_text)
diff --git a/tui_gateway/methods_config.py b/tui_gateway/methods_config.py
index fbd0a9884c8..51202890e50 100644
--- a/tui_gateway/methods_config.py
+++ b/tui_gateway/methods_config.py
@@ -506,6 +506,9 @@ def _(rid, params: dict) -> dict:
and consent lives with the CALLER (privacy notice first). Structured ``ok``/``error`` envelope so
upload failures render inline. Optional: ``error_context`` (-> ``error-context.txt``),
``extra_files`` ({label -> text}), ``log_lines`` (default 200); all force-redacted."""
+ # Outside the try: the except path needs it, and agent.redact is a hard dependency.
+ from hermes_cli.debug_redaction import redact_debug_support_text
+
try:
from hermes_cli.debug import build_nous_bundle, collect_share_bundle
from hermes_cli.diagnostics_upload import share_to_nous
@@ -531,8 +534,6 @@ def _(rid, params: dict) -> dict:
return _ok(rid, {"ok": True, "view_url": view_url, "upload_id": upload_id,
"expires_at": res.get("expiresAt") or res.get("expires_at")})
except Exception as e:
- from hermes_cli.debug_redaction import redact_debug_support_text
-
return _ok(rid, {"ok": False, "error": redact_debug_support_text(e)})