Skip to content

Commit 9102329

Browse files
committed
Add a category to all TODO tools
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent 1635b61 commit 9102329

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

pkg/codemode/codemode.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ func (c *codeModeTool) Instructions() string {
4747
}
4848

4949
func isExcludedTool(tool tools.Tool) bool {
50-
// TODO(dga): make this more robust. It really a temporary hack to exclude the todo tools.
51-
// See #514
52-
return strings.Contains(tool.Name, "_todo")
50+
return tool.Category == "todo"
5351
}
5452

5553
func (c *codeModeTool) Tools(ctx context.Context) ([]tools.Tool, error) {

pkg/tools/builtin/todo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func (t *TodoTool) Tools(context.Context) ([]tools.Tool, error) {
154154
return []tools.Tool{
155155
{
156156
Name: "create_todo",
157+
Category: "todo",
157158
Description: "Create a new todo item with a description",
158159
Parameters: tools.MustSchemaFor[CreateTodoArgs](),
159160
OutputSchema: tools.MustSchemaFor[string](),
@@ -165,6 +166,7 @@ func (t *TodoTool) Tools(context.Context) ([]tools.Tool, error) {
165166
},
166167
{
167168
Name: "create_todos",
169+
Category: "todo",
168170
Description: "Create a list of new todo items with descriptions",
169171
Parameters: tools.MustSchemaFor[CreateTodosArgs](),
170172
OutputSchema: tools.MustSchemaFor[string](),
@@ -176,6 +178,7 @@ func (t *TodoTool) Tools(context.Context) ([]tools.Tool, error) {
176178
},
177179
{
178180
Name: "update_todo",
181+
Category: "todo",
179182
Description: "Update the status of a todo item",
180183
Parameters: tools.MustSchemaFor[UpdateTodoArgs](),
181184
OutputSchema: tools.MustSchemaFor[string](),
@@ -187,6 +190,7 @@ func (t *TodoTool) Tools(context.Context) ([]tools.Tool, error) {
187190
},
188191
{
189192
Name: "list_todos",
193+
Category: "todo",
190194
Description: "List all current todos with their status",
191195
OutputSchema: tools.MustSchemaFor[string](),
192196
Handler: t.handler.listTodos,

pkg/tools/builtin/todo_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ func TestTodoTool_Tools(t *testing.T) {
3434

3535
require.NoError(t, err)
3636
assert.Len(t, allTools, 4)
37+
for _, tool := range allTools {
38+
assert.NotNil(t, tool.Handler)
39+
assert.Equal(t, "todo", tool.Category)
40+
}
3741

3842
// Verify tool functions
3943
assert.Equal(t, "create_todo", allTools[0].Name)
4044
assert.Equal(t, "create_todos", allTools[1].Name)
4145
assert.Equal(t, "update_todo", allTools[2].Name)
4246
assert.Equal(t, "list_todos", allTools[3].Name)
43-
assert.NotNil(t, allTools[0].Handler)
44-
assert.NotNil(t, allTools[1].Handler)
45-
assert.NotNil(t, allTools[2].Handler)
46-
assert.NotNil(t, allTools[3].Handler)
4747

4848
// Check create_todo parameters
4949
schema, err := json.Marshal(allTools[0].Parameters)

pkg/tools/tools.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type ToolType string
2929

3030
type Tool struct {
3131
Name string `json:"name"`
32+
Category string `json:"category"`
3233
Description string `json:"description,omitempty"`
3334
Parameters any `json:"parameters"`
3435
Annotations ToolAnnotations `json:"annotations"`

0 commit comments

Comments
 (0)