diff --git a/pkg/mcp/brain/direct.go b/pkg/mcp/brain/direct.go index 37f787f..eddbe48 100644 --- a/pkg/mcp/brain/direct.go +++ b/pkg/mcp/brain/direct.go @@ -289,10 +289,10 @@ func (s *DirectSubsystem) list(ctx context.Context, _ *mcp.CallToolRequest, inpu if s.onChannel != nil { s.onChannel(ctx, coremcp.ChannelBrainListDone, map[string]any{ - "project": input.Project, - "type": input.Type, - "agent": input.AgentID, - "limit": limit, + "project": input.Project, + "type": input.Type, + "agent_id": input.AgentID, + "limit": limit, }) } diff --git a/pkg/mcp/brain/direct_test.go b/pkg/mcp/brain/direct_test.go index 486d43f..eb892b9 100644 --- a/pkg/mcp/brain/direct_test.go +++ b/pkg/mcp/brain/direct_test.go @@ -361,6 +361,50 @@ func TestDirectList_Good(t *testing.T) { } } +func TestDirectList_Good_EmitsAgentIDChannelPayload(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + json.NewEncoder(w).Encode(map[string]any{"memories": []any{}}) + })) + defer srv.Close() + + var gotChannel string + var gotPayload map[string]any + + s := newTestDirect(srv.URL) + s.onChannel = func(_ context.Context, channel string, data any) { + gotChannel = channel + if payload, ok := data.(map[string]any); ok { + gotPayload = payload + } + } + + _, out, err := s.list(context.Background(), nil, ListInput{ + Project: "eaas", + Type: "decision", + AgentID: "virgil", + Limit: 20, + }) + if err != nil { + t.Fatalf("list failed: %v", err) + } + if !out.Success { + t.Fatal("expected list success") + } + if gotChannel != "brain.list.complete" { + t.Fatalf("expected brain.list.complete, got %q", gotChannel) + } + if gotPayload == nil { + t.Fatal("expected channel payload") + } + if gotPayload["agent_id"] != "virgil" { + t.Fatalf("expected agent_id=virgil, got %v", gotPayload["agent_id"]) + } + if gotPayload["project"] != "eaas" { + t.Fatalf("expected project=eaas, got %v", gotPayload["project"]) + } +} + func TestDirectList_Good_DefaultLimit(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if got := r.URL.Query().Get("limit"); got != "50" { diff --git a/pkg/mcp/brain/provider.go b/pkg/mcp/brain/provider.go index d2a1baa..328e2ec 100644 --- a/pkg/mcp/brain/provider.go +++ b/pkg/mcp/brain/provider.go @@ -318,10 +318,10 @@ func (p *BrainProvider) list(c *gin.Context) { } p.emitEvent(coremcp.ChannelBrainListDone, map[string]any{ - "project": project, - "type": typ, - "agent": agentID, - "limit": limit, + "project": project, + "type": typ, + "agent_id": agentID, + "limit": limit, }) c.JSON(http.StatusOK, api.OK(ListOutput{ diff --git a/pkg/mcp/brain/tools.go b/pkg/mcp/brain/tools.go index cf54f64..784fd2a 100644 --- a/pkg/mcp/brain/tools.go +++ b/pkg/mcp/brain/tools.go @@ -235,10 +235,10 @@ func (s *Subsystem) brainList(ctx context.Context, _ *mcp.CallToolRequest, input } s.emitChannel(ctx, coremcp.ChannelBrainListDone, map[string]any{ - "project": input.Project, - "type": input.Type, - "agent": input.AgentID, - "limit": limit, + "project": input.Project, + "type": input.Type, + "agent_id": input.AgentID, + "limit": limit, }) return nil, ListOutput{ diff --git a/pkg/mcp/process_notifications.go b/pkg/mcp/process_notifications.go index 622b257..a56550e 100644 --- a/pkg/mcp/process_notifications.go +++ b/pkg/mcp/process_notifications.go @@ -75,6 +75,8 @@ func isTestProcess(command string, args []string) bool { } func (s *Service) emitTestResult(ctx context.Context, processID string, exitCode int, duration time.Duration, signal string, errText string) { + defer s.forgetProcessRuntime(processID) + meta, ok := s.processRuntimeFor(processID) if !ok || !isTestProcess(meta.Command, meta.Args) { return @@ -115,5 +117,4 @@ func (s *Service) emitTestResult(ctx context.Context, processID string, exitCode } s.ChannelSend(ctx, ChannelTestResult, payload) - s.forgetProcessRuntime(processID) }