@@ -163,28 +163,43 @@ func TestNudgeRoleIsUser(t *testing.T) {
163163 // Simulate what happens in run() when a nudge is received
164164 // The code calls: a.SendMessage(a.buildContinuePrompt(attemptCount), store.MemorySourceDirect)
165165 prompt := mysis.buildContinuePrompt(0)
166- err := mysis.SendMessage(prompt, store.MemorySourceDirect)
167166
168- // SendMessage will fail because mysis is not running, but we can test the role logic directly
169- if err == nil || !strings.Contains(err.Error(), "not running") {
170- t.Fatalf("Expected 'not running' error, got: %v", err)
167+ // Idle myses now accept messages, so this should succeed
168+ err := mysis.SendMessage(prompt, store.MemorySourceDirect)
169+ if err != nil {
170+ t.Fatalf("SendMessage should succeed for idle mysis, got: %v", err)
171171 }
172172
173173 // The important part: verify that MemorySourceDirect maps to user role
174- // This is tested by checking the SendMessageFrom logic
175- // role := store.MemoryRoleUser (default)
176- // if source == store.MemorySourceSystem { role = store.MemoryRoleSystem }
177- // Since we're using MemorySourceDirect, role should be user
174+ // Check the stored memory to verify role
175+ memories, err := s.GetMemories(mysis.ID())
176+ if err != nil {
177+ t.Fatalf("GetMemories() error: %v", err)
178+ }
179+
180+ // Should have stored the nudge message (and possibly LLM response)
181+ if len(memories) == 0 {
182+ t.Fatal("Expected stored memory for nudge message")
183+ }
184+
185+ // Find the user message (the nudge we sent)
186+ var userMemory *store.Memory
187+ for i := range memories {
188+ if memories[i].Role == store.MemoryRoleUser {
189+ userMemory = memories[i]
190+ break
191+ }
192+ }
178193
179- // We can verify this by checking what would be stored
180- // Let's test the role mapping directly
181- testRole := store.MemoryRoleUser
182- testSource := store.MemorySourceDirect
183- if testSource == store.MemorySourceSystem {
184- testRole = store.MemoryRoleSystem
194+ if userMemory == nil {
195+ t.Fatal("Expected to find user role memory (the nudge)")
185196 }
186197
187- if testRole != store.MemoryRoleUser {
188- t.Errorf("Expected nudge to use user role, got: %s", testRole)
198+ // Verify the role is user (not system) and source is direct
199+ if userMemory.Role != store.MemoryRoleUser {
200+ t.Errorf("Expected nudge to use user role, got: %s", userMemory.Role)
201+ }
202+ if userMemory.Source != store.MemorySourceDirect {
203+ t.Errorf("Expected source to be direct, got: %s", userMemory.Source)
189204 }
190205 }