add test for SetSessionID preamble update

This commit is contained in:
Levi Neely 2026-05-20 10:50:20 +02:00
parent 09a9364b6f
commit 82df12e293
1 changed files with 27 additions and 0 deletions

View File

@ -1705,6 +1705,33 @@ func TestSetSessionID_Rename(t *testing.T) {
}
}
func TestSetSessionID_UpdatesPreamble(t *testing.T) {
oldID := NewSessionID()
env := AgentEnv{
preamble: "session is " + oldID + " end",
}
c := NewAgentCore(AgentCoreConfig{
Backend: defaultBE(),
AgentName: "test",
AgentsDir: t.TempDir(),
SessionsDir: t.TempDir(),
SessionID: oldID,
CWD: t.TempDir(),
Env: env,
NewDispatcher: tools.NewDispatcher,
}).(*agent)
t.Cleanup(c.Close)
newID := NewSessionID()
if err := c.SetSessionID(newID); err != nil {
t.Fatalf("SetSessionID: %v", err)
}
want := "session is " + newID + " end"
if got := c.SystemPrompt(); got != want {
t.Errorf("SystemPrompt() = %q; want %q", got, want)
}
}
func TestSetSessionID_SameID(t *testing.T) {
c := newCore(t, nil, nil)
id := c.sessionID