fix(session): normalize CreatedAt in SessionManager AddFullMessage/SetHistory

This commit is contained in:
LiusCraft
2026-05-11 01:36:38 +08:00
parent fd08ebd3db
commit 33e5503e26
3 changed files with 24 additions and 7 deletions
+6 -4
View File
@@ -105,9 +105,10 @@ func TestTurnProfile_DisabledPreservesDefaultHistoryAndPrompt(t *testing.T) {
al := newTurnProfileAgentLoop(t, cfg, provider)
agent := al.GetRegistry().GetDefaultAgent()
sessionKey := "agent:default:test-default"
ts := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
initialHistory := []providers.Message{
{Role: "user", Content: "old user"},
{Role: "assistant", Content: "old assistant"},
{Role: "user", Content: "old user", CreatedAt: &ts},
{Role: "assistant", Content: "old assistant", CreatedAt: &ts},
}
agent.Sessions.SetHistory(sessionKey, initialHistory)
agent.Sessions.SetSummary(sessionKey, "old summary")
@@ -154,9 +155,10 @@ func TestTurnProfile_HistoryOffSuppressesHistoryAndPersistence(t *testing.T) {
al := newTurnProfileAgentLoop(t, cfg, provider)
agent := al.GetRegistry().GetDefaultAgent()
sessionKey := "agent:default:test-history-off"
ts := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
initialHistory := []providers.Message{
{Role: "user", Content: "old user"},
{Role: "assistant", Content: "old assistant"},
{Role: "user", Content: "old user", CreatedAt: &ts},
{Role: "assistant", Content: "old assistant", CreatedAt: &ts},
}
agent.Sessions.SetHistory(sessionKey, initialHistory)
agent.Sessions.SetSummary(sessionKey, "old summary")