@@ -11,7 +11,6 @@ import (
1111 "time"
1212
1313 "github.com/xonecas/zoea-nova/internal/constants"
14- "github.com/xonecas/zoea-nova/internal/mcp"
1514 "github.com/xonecas/zoea-nova/internal/provider"
1615 "github.com/xonecas/zoea-nova/internal/store"
1716 )
@@ -47,7 +46,7 @@ func TestMysisLifecycle(t *testing.T) {
4746 }
4847
4948 mock := provider.NewMock("mock", "Hello from mysis!")
50- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
49+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
5150
5251 // Initial state
5352 if mysis.State() != MysisStateIdle {
@@ -97,7 +96,7 @@ func TestMysisConcurrentStopDuringTurn(t *testing.T) {
9796 }
9897
9998 mock := provider.NewMock("mock", "ok").SetDelay(50 * time.Millisecond)
100- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
99+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
101100
102101 if err := mysis.Start(); err != nil {
103102 t.Fatalf("Start() error: %v", err)
@@ -130,7 +129,7 @@ func TestMysisSendMessage(t *testing.T) {
130129
131130 stored, _ := s.CreateMysis("msg-mysis", "mock", "test-model", 0.7)
132131 mock := provider.NewMock("mock", "I received your message!")
133- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
132+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
134133
135134 // Can send to idle mysis (will be stored and processed when started)
136135 if err := mysis.SendMessage("Hello", store.MemorySourceDirect); err != nil {
@@ -218,7 +217,7 @@ func TestMysisReceivesBroadcastWithSender(t *testing.T) {
218217
219218 receiverStored, _ := s.CreateMysis("receiver", "mock", "test-model", 0.7)
220219 mock := provider.NewMock("mock", "response")
221- receiver := NewMysis(receiverStored.ID, receiverStored.Name, receiverStored.CreatedAt, mock, s, bus)
220+ receiver := NewMysis(receiverStored.ID, receiverStored.Name, receiverStored.CreatedAt, mock, s, bus, "")
222221
223222 if err := receiver.Start(); err != nil {
224223 t.Fatalf("Start() error: %v", err)
@@ -259,7 +258,7 @@ func TestMysisSetErrorState(t *testing.T) {
259258
260259 stored, _ := s.CreateMysis("error-state-test", "mock", "test-model", 0.7)
261260 mock := provider.NewMock("mock", "response")
262- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
261+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
263262
264263 events := bus.Subscribe()
265264
@@ -300,7 +299,7 @@ func TestMysisProviderName(t *testing.T) {
300299
301300 stored, _ := s.CreateMysis("provider-test", "mock", "test-model", 0.7)
302301 mock := provider.NewMock("test-provider", "response")
303- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
302+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
304303
305304 if mysis.ProviderName() != "test-provider" {
306305 t.Errorf("expected provider name=test-provider, got %s", mysis.ProviderName())
@@ -319,7 +318,7 @@ func TestMysisStateEvents(t *testing.T) {
319318
320319 stored, _ := s.CreateMysis("event-test", "mock", "test-model", 0.7)
321320 mock := provider.NewMock("mock", "response")
322- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
321+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
323322
324323 events := bus.Subscribe()
325324
@@ -442,7 +441,7 @@ func TestSnapshotCompaction(t *testing.T) {
442441
443442 stored, _ := s.CreateMysis("compaction-test", "mock", "test-model", 0.7)
444443 mock := provider.NewMock("mock", "response")
445- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
444+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
446445
447446 // Add system prompt
448447 s.AddMemory(stored.ID, store.MemoryRoleSystem, store.MemorySourceSystem, "System prompt", "", "")
@@ -495,7 +494,7 @@ func TestGetContextMemories_CurrentTurnBoundary(t *testing.T) {
495494 }
496495
497496 mock := provider.NewMock("mock", "response")
498- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
497+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
499498
500499 // Commander ID for testing
501500 commanderID := "commander-mysis-id"
@@ -631,7 +630,7 @@ func TestExtractLatestToolLoopHelper(t *testing.T) {
631630 }
632631
633632 mock := provider.NewMock("mock", "response")
634- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
633+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
635634
636635 tests := []struct {
637636 name string
@@ -967,7 +966,7 @@ func TestMysisStopDoesNotOverrideWithError(t *testing.T) {
967966 stored, _ := s.CreateMysis("stop-test", "mock", "test-model", 0.7)
968967
969968 mock := provider.NewMock("mock", "test response")
970- m := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
969+ m := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
971970
972971 // Start the mysis
973972 if err := m.Start(); err != nil {
@@ -1012,7 +1011,7 @@ func TestStopDuringInitialMessage(t *testing.T) {
10121011 // Use a mock provider with NO delay - we want to test the race
10131012 // between Start() spawning SendMessage and Stop() being called
10141013 mock := provider.NewMock("mock", "response")
1015- m := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1014+ m := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
10161015
10171016 // Start the mysis (spawns initial SendMessage goroutine)
10181017 if err := m.Start(); err != nil {
@@ -1068,7 +1067,7 @@ func TestStopDuringInitialMessageWithSlowProvider(t *testing.T) {
10681067
10691068 // Use a provider with delay to simulate the mysis being mid-turn when Stop is called
10701069 mock := provider.NewMock("mock", "response").SetDelay(50 * time.Millisecond)
1071- m := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1070+ m := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
10721071
10731072 // Start the mysis
10741073 if err := m.Start(); err != nil {
@@ -1148,7 +1147,7 @@ func TestStopAtVariousTimings(t *testing.T) {
11481147
11491148 // Use a mock with a delay to simulate real LLM processing
11501149 mock := provider.NewMock("mock", "test response").SetDelay(25 * time.Millisecond)
1151- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1150+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
11521151
11531152 // Start mysis
11541153 if err := mysis.Start(); err != nil {
@@ -1193,7 +1192,7 @@ func TestEncouragementLimit(t *testing.T) {
11931192 }
11941193
11951194 mock := provider.NewMock("mock", "response")
1196- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1195+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
11971196
11981197 // Add system prompt only (no user messages)
11991198 err = s.AddMemory(stored.ID, store.MemoryRoleSystem, store.MemorySourceSystem, "System prompt", "", "")
@@ -1237,7 +1236,7 @@ func TestEncouragementReset(t *testing.T) {
12371236 }
12381237
12391238 mock := provider.NewMock("mock", "response")
1240- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1239+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
12411240
12421241 // Set encouragementCount to 2 (simulate 2 synthetic messages)
12431242 mysis.mu.Lock()
@@ -1274,7 +1273,7 @@ func TestEncouragementReset(t *testing.T) {
12741273 }
12751274
12761275 mock := provider.NewMock("mock", "response")
1277- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1276+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
12781277
12791278 // Set encouragementCount to 2
12801279 mysis.mu.Lock()
@@ -1303,7 +1302,7 @@ func TestEncouragementReset(t *testing.T) {
13031302 }
13041303
13051304 mock := provider.NewMock("mock", "response")
1306- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1305+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
13071306
13081307 // Add system prompt
13091308 err = s.AddMemory(stored.ID, store.MemoryRoleSystem, store.MemorySourceSystem, "System prompt", "", "")
@@ -1356,7 +1355,7 @@ func TestMysisWithBroadcastsKeepsRunning(t *testing.T) {
13561355
13571356 // Use mock provider with no delay for fast test
13581357 mock := provider.NewMock("mock", "I will continue exploring")
1359- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1358+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
13601359
13611360 // Step 1-2: Send broadcast "Explore the universe!" via QueueBroadcast
13621361 // This will be stored as a user message with source=broadcast
@@ -1464,7 +1463,7 @@ func TestExecuteToolCall_ErrorPaths(t *testing.T) {
14641463 t.Run("nil_mcp_proxy", func(t *testing.T) {
14651464 stored, _ := s.CreateMysis("nil-proxy-test", "mock", "test-model", 0.7)
14661465 mock := provider.NewMock("mock", "response")
1467- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1466+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
14681467
14691468 // Call executeToolCall with nil proxy
14701469 tc := provider.ToolCall{
@@ -1493,14 +1492,13 @@ func TestExecuteToolCall_ErrorPaths(t *testing.T) {
14931492 t.Run("tool_call_timeout", func(t *testing.T) {
14941493 stored, _ := s.CreateMysis("timeout-test", "mock", "test-model", 0.7)
14951494 mock := provider.NewMock("mock", "response")
1496- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1495+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
14971496
14981497 // Create a context with very short timeout
14991498 ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
15001499 defer cancel()
15011500 time.Sleep(10 * time.Millisecond) // Ensure timeout fires
15021501
1503- proxy := mcp.NewProxy(nil)
15041502 tc := provider.ToolCall{
15051503 ID: "call_1",
15061504 Name: "get_status",
@@ -1525,9 +1523,8 @@ func TestExecuteToolCall_ErrorPaths(t *testing.T) {
15251523 t.Run("invalid_tool_arguments", func(t *testing.T) {
15261524 stored, _ := s.CreateMysis("invalid-args-test", "mock", "test-model", 0.7)
15271525 mock := provider.NewMock("mock", "response")
1528- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1526+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
15291527
1530- proxy := mcp.NewProxy(nil)
15311528 // Register a tool that validates arguments
15321529 proxy.RegisterTool(
15331530 mcp.Tool{
@@ -1579,9 +1576,8 @@ func TestExecuteToolCall_ErrorPaths(t *testing.T) {
15791576 t.Run("mcp_call_tool_error", func(t *testing.T) {
15801577 stored, _ := s.CreateMysis("mcp-error-test", "mock", "test-model", 0.7)
15811578 mock := provider.NewMock("mock", "response")
1582- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1579+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
15831580
1584- proxy := mcp.NewProxy(nil)
15851581 // Register a tool that returns an error
15861582 proxy.RegisterTool(
15871583 mcp.Tool{
@@ -1618,9 +1614,8 @@ func TestExecuteToolCall_ErrorPaths(t *testing.T) {
16181614 t.Run("tool_result_parsing_with_empty_content", func(t *testing.T) {
16191615 stored, _ := s.CreateMysis("parse-test", "mock", "test-model", 0.7)
16201616 mock := provider.NewMock("mock", "response")
1621- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1617+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
16221618
1623- proxy := mcp.NewProxy(nil)
16241619 // Register a tool that returns empty content
16251620 proxy.RegisterTool(
16261621 mcp.Tool{
@@ -1674,7 +1669,7 @@ func setupTestMysis(t *testing.T) (*Mysis, func()) {
16741669 }
16751670
16761671 mock := provider.NewMock("mock", "test response")
1677- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1672+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
16781673
16791674 return mysis, cleanup
16801675 }
@@ -1692,7 +1687,7 @@ func setupTestMysisWithErrorProvider(t *testing.T) (*Mysis, func()) {
16921687
16931688 // Create a mock provider that returns errors
16941689 mock := provider.NewMock("mock", "").WithChatError(errors.New("provider error"))
1695- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1690+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
16961691
16971692 return mysis, cleanup
16981693 }
@@ -1790,7 +1785,7 @@ func TestQueueBroadcast_IdleState(t *testing.T) {
17901785 }
17911786
17921787 mock := provider.NewMock("mock", "Hello!")
1793- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1788+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
17941789
17951790 // Mysis starts in idle state
17961791 if mysis.State() != MysisStateIdle {
@@ -1824,7 +1819,7 @@ func TestQueueBroadcast_StoppedState(t *testing.T) {
18241819 }
18251820
18261821 mock := provider.NewMock("mock", "Hello!")
1827- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
1822+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
18281823
18291824 // Start then stop
18301825 if err := mysis.Start(); err != nil {
@@ -2003,7 +1998,7 @@ func TestGetContextMemories_NoUserPrompt(t *testing.T) {
20031998
20041999 stored, _ := s.CreateMysis("no-prompt-test", "mock", "test-model", 0.7)
20052000 mock := provider.NewMock("mock", "response")
2006- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
2001+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
20072002
20082003 // Add only system and assistant messages (no user prompt)
20092004 err := s.AddMemory(stored.ID, store.MemoryRoleSystem, store.MemorySourceSystem, "System prompt", "", "")
@@ -2040,7 +2035,7 @@ func TestGetContextMemories_OnlyHistoricalTurns(t *testing.T) {
20402035
20412036 stored, _ := s.CreateMysis("historical-test", "mock", "test-model", 0.7)
20422037 mock := provider.NewMock("mock", "response")
2043- mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus)
2038+ mysis := NewMysis(stored.ID, stored.Name, stored.CreatedAt, mock, s, bus, "")
20442039
20452040 // Add system prompt
Cut short: this commit's diff is over 1000 lines.