test(agent): cover early user-message persistence
Use session.add_message for the pre-turn user-message flush and add focused regression tests for crash-time persistence and duplicate-free successful saves. Made-with: Cursor
This commit is contained in:
@@ -701,12 +701,7 @@ class AgentLoop:
|
||||
# makes recovery possible from the session log alone.
|
||||
user_persisted_early = False
|
||||
if isinstance(msg.content, str) and msg.content.strip():
|
||||
from datetime import datetime as _dt
|
||||
session.messages.append({
|
||||
"role": "user",
|
||||
"content": msg.content,
|
||||
"timestamp": _dt.now().isoformat(),
|
||||
})
|
||||
session.add_message("user", msg.content)
|
||||
self.sessions.save(session)
|
||||
user_persisted_early = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user