Skip to content

The agent that grows with you

fix(cli): address review feedback on chat -c fail-loudly PR

yflmq0010816ba2f938d
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index 7941c1b4e75..ed9fe973ab2 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -1806,6 +1806,11 @@ def _create_titled_session(title: str) -> Optional[str]:
db.set_session_title(new_session_id, title)
return new_session_id
except Exception:
+ # Programmatic callers (the #86794 use case) rely on --create-if-missing
+ # being deterministic; swallow the failure to keep the error path simple,
+ # but log the underlying cause so it lands in errors.log and stays
+ # debuggable (DB lock, I/O error, import error — all otherwise invisible).
+ logger.exception("Failed to create titled session %r", title)
return None
finally:
if db is not None:
@@ -1864,6 +1869,15 @@ def _resolve_continue_arg(args, *, use_tui: bool) -> None:
# each continue their own conversation. Falls back to the
# most-recent session when there is no valid breadcrumb, or when
# session.terminal_continue is false in config.yaml.
+ if getattr(args, "create_if_missing", False):
+ # --create-if-missing only makes sense with a named session;
+ # with a bare -c there is nothing to create, so surface the
+ # no-op to programmatic callers instead of silently ignoring it.
+ print(
+ "--create-if-missing requires a session name: "
+ "`-c <name> --create-if-missing`",
+ file=sys.stderr,
+ )
try:
from hermes_cli.terminal_breadcrumbs import resolve_breadcrumb_session
diff --git a/tests/hermes_cli/test_chat_c_fail_loudly.py b/tests/hermes_cli/test_chat_c_fail_loudly.py
index adbf818bb80..351a8263f7f 100644
--- a/tests/hermes_cli/test_chat_c_fail_loudly.py
+++ b/tests/hermes_cli/test_chat_c_fail_loudly.py
@@ -15,8 +15,6 @@ Two behaviors are fixed here:
deterministic "send to this named thread, making it if needed" primitive.
"""
-import os
-
import pytest
@@ -159,15 +157,3 @@ class TestChatCFailLoudlyOnStderr:
assert db.get_session_title(args.resume) == "Bot Chat"
finally:
db.close()
-
-
-class TestSourceGuard:
- """Source-level guards: the fail-loudly branch must target stderr."""
-
- def test_not_found_message_uses_stderr(self):
- src = open(
- os.path.join(os.path.dirname(__file__), "..", "..", "hermes_cli", "main.py"),
- encoding="utf-8",
- ).read()
- assert "No session found matching '{continue_val}'." in src
- assert "file=sys.stderr" in src