mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-21 16:18:55 +00:00
fix(agent): avoid overwriting manual session titles
This commit is contained in:
parent
46d16f4c28
commit
f725cf830f
2 changed files with 24 additions and 0 deletions
|
|
@ -237,6 +237,13 @@ def _auto_title_session(
|
|||
return
|
||||
|
||||
try:
|
||||
latest = session_db.get_session_title(session_id)
|
||||
if latest:
|
||||
logger.debug(
|
||||
"Skipping auto-generated session title because a title was set while generation was in flight: %s",
|
||||
latest,
|
||||
)
|
||||
return
|
||||
session_db.set_session_title(session_id, title)
|
||||
logger.debug("Auto-generated session title: %s", title)
|
||||
if title_callback is not None:
|
||||
|
|
|
|||
|
|
@ -245,6 +245,23 @@ class TestAutoTitleSession:
|
|||
auto_title_session(db, "sess-1", "hi", "hello")
|
||||
db.set_session_title.assert_called_once_with("sess-1", "New Title")
|
||||
|
||||
def test_does_not_overwrite_title_set_while_generation_was_in_flight(self):
|
||||
db = MagicMock()
|
||||
db.get_session_title.side_effect = [None, "Manual Title"]
|
||||
seen = []
|
||||
|
||||
with patch("agent.title_generator.generate_title", return_value="Auto Title"):
|
||||
auto_title_session(
|
||||
db,
|
||||
"sess-1",
|
||||
"hi",
|
||||
"hello",
|
||||
title_callback=seen.append,
|
||||
)
|
||||
|
||||
db.set_session_title.assert_not_called()
|
||||
assert seen == []
|
||||
|
||||
def test_invokes_title_callback_after_setting_title(self):
|
||||
db = MagicMock()
|
||||
db.get_session_title.return_value = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue