core/agent: shift persist_from when prepending system prompt

This commit is contained in:
2026-07-21 22:44:09 +08:00
parent b51d4780ab
commit b06bb1d409
2 changed files with 11 additions and 6 deletions
+3 -3
View File
@@ -210,9 +210,9 @@ class ChatAgent:
if self.messages and isinstance(self.messages[0], SystemChatMessage):
return
self.messages.insert(0, SystemChatMessage(content=self.system_prompt))
# System inject is not a DB message unless already stored.
if self._persist_from == 0:
self._persist_from = 1
# Prepended system is local-only; shift the checkpoint so indices that
# already pointed past stored messages stay correct after insert.
self._persist_from = min(len(self.messages), self._persist_from + 1)
def replace_messages(
self,