fix(api): trim tool bridge tags

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 00:31:38 +00:00
parent ffbb6d83d0
commit 68f5abefd0
2 changed files with 19 additions and 2 deletions

View file

@ -143,8 +143,8 @@ func (b *ToolBridge) snapshotTools() []boundTool {
}
func describeTool(desc ToolDescriptor, defaultTag string) RouteDescription {
tags := []string{desc.Group}
if desc.Group == "" {
tags := cleanTags([]string{desc.Group})
if len(tags) == 0 {
tags = []string{defaultTag}
}
return RouteDescription{

View file

@ -154,6 +154,23 @@ func TestToolBridge_Good_Describe(t *testing.T) {
}
}
func TestToolBridge_Good_DescribeTrimsBlankGroup(t *testing.T) {
bridge := api.NewToolBridge("/tools")
bridge.Add(api.ToolDescriptor{
Name: "file_read",
Description: "Read a file from disk",
Group: " ",
}, func(c *gin.Context) {})
descs := bridge.Describe()
if len(descs) != 1 {
t.Fatalf("expected 1 description, got %d", len(descs))
}
if len(descs[0].Tags) != 1 || descs[0].Tags[0] != "tools" {
t.Fatalf("expected blank group to fall back to bridge tag, got %v", descs[0].Tags)
}
}
func TestToolBridge_Good_ValidatesRequestBody(t *testing.T) {
gin.SetMode(gin.TestMode)
engine := gin.New()