1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package main
import (
"context"
"slices"
"strings"
"testing"
"mm/internal/config"
"mm/internal/detector"
"mm/internal/engine"
"github.com/firebase/genkit/go/genkit"
)
// A `tools:` entry is declared to the model under its own name.
func TestDeclaredToolsAreAssembled(t *testing.T) {
withConfig(t, func(c *config.Config) {
c.Tools = []config.DeclaredTool{{Name: "release", Description: "d", Command: []string{"./release.sh"}}}
})
if names := assembledNames(t); !slices.Contains(names, "release") {
t.Errorf("names = %v, want release among them", names)
}
}
// A declared tool that would take an MCP tool's name is skipped with a
// warning; the others are still declared.
func TestDeclaredToolTakingAnMCPNameIsSkipped(t *testing.T) {
withConfig(t, func(c *config.Config) {
c.Tools = []config.DeclaredTool{
{Name: "proj_release", Description: "d", Command: []string{"a"}},
{Name: "status", Description: "d", Command: []string{"b"}},
}
})
e := &engine.Engine{G: genkit.Init(context.Background())}
set := toolSet{names: []string{"proj_release"}}
assembleDeclared(e, detector.NewLoopDetector(10, 3), &set)
if !slices.Equal(set.names, []string{"proj_release", "status"}) || len(set.tools) != 1 {
t.Errorf("names %v, %d tool(s)", set.names, len(set.tools))
}
if len(set.warnings) != 1 || !strings.Contains(set.warnings[0], "proj_release skipped") {
t.Errorf("warnings = %v", set.warnings)
}
}
|