fix(honcho): honor writeFrequency in sync_turn by routing through manager.save()
sync_turn called manager._flush_session() directly, which flushes synchronously every turn no matter what writeFrequency says — the "async", "session", and every-N-turns modes were dead configuration on the main turn path. Route through save(), the dispatcher that actually implements those modes. Same bug class reported in #19650 (starship-s) and #72708 (Diaspar4u); this takes the minimal one-line routing fix without their broader lifecycle refactors. Co-authored-by: starship-s <45587122+starship-s@users.noreply.github.com>
This commit is contained in:
parent
9cfff1546d
commit
756aa54b67
|
|
@ -1449,7 +1449,10 @@ class HonchoMemoryProvider(MemoryProvider):
|
|||
if clean_assistant_content:
|
||||
for chunk in self._chunk_message(clean_assistant_content, msg_limit):
|
||||
session.add_message("assistant", chunk)
|
||||
self._manager._flush_session(session)
|
||||
# Route through save() so writeFrequency is honored —
|
||||
# _flush_session() directly bypassed "session"/N batching
|
||||
# and flushed every turn regardless of config.
|
||||
self._manager.save(session)
|
||||
except Exception as e:
|
||||
logger.debug("Honcho sync_turn failed: %s", e)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,16 @@ class TestSyncTurn:
|
|||
p = _provider(save_messages=False)
|
||||
p.sync_turn('user says', 'assistant says')
|
||||
p._manager.get_or_create.assert_not_called()
|
||||
p._manager._flush_session.assert_not_called()
|
||||
p._manager.save.assert_not_called()
|
||||
|
||||
def test_enabled_routes_through_save(self):
|
||||
p = _provider(save_messages=True)
|
||||
p.sync_turn('user says', 'assistant says')
|
||||
if p._sync_thread is not None:
|
||||
p._sync_thread.join(timeout=5)
|
||||
p._manager.get_or_create.assert_called_once()
|
||||
# save() (not _flush_session) so writeFrequency batching is honored
|
||||
p._manager.save.assert_called_once()
|
||||
|
||||
def test_enabled_writes(self):
|
||||
p = _provider(save_messages=True)
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ def test_honcho_sync_turn_same_instance_config_flip_gates_writes():
|
|||
manager_calls.append(session_key)
|
||||
return SimpleNamespace(add_message=lambda role, content: None)
|
||||
|
||||
def _flush_session(self, session):
|
||||
def save(self, session):
|
||||
write_done.set()
|
||||
|
||||
provider._config = cfg
|
||||
|
|
|
|||
Loading…
Reference in New Issue