Skip to content

Commit 54032f9

Browse files
committed
Temporary fix to exclude todo tools from code Mode
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent 19cfe5f commit 54032f9

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

pkg/codemode/codemode.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,17 @@ func (c *codeModeTool) Instructions() string {
4646
return ""
4747
}
4848

49+
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")
53+
}
54+
4955
func (c *codeModeTool) Tools(ctx context.Context) ([]tools.Tool, error) {
50-
var functionsDoc []string
56+
var (
57+
functionsDoc []string
58+
excludedTools []tools.Tool
59+
)
5160

5261
for _, toolset := range c.toolsets {
5362
allTools, err := toolset.Tools(ctx)
@@ -56,11 +65,15 @@ func (c *codeModeTool) Tools(ctx context.Context) ([]tools.Tool, error) {
5665
}
5766

5867
for _, tool := range allTools {
59-
functionsDoc = append(functionsDoc, toolToJsDoc(tool))
68+
if isExcludedTool(tool) {
69+
excludedTools = append(excludedTools, tool)
70+
} else {
71+
functionsDoc = append(functionsDoc, toolToJsDoc(tool))
72+
}
6073
}
6174
}
6275

63-
return []tools.Tool{{
76+
allTools := []tools.Tool{{
6477
Name: "run_tools_with_javascript",
6578
Description: prompt + strings.Join(functionsDoc, "\n"),
6679
Parameters: tools.MustSchemaFor[RunToolsWithJavascriptArgs](),
@@ -88,7 +101,11 @@ func (c *codeModeTool) Tools(ctx context.Context) ([]tools.Tool, error) {
88101
Annotations: tools.ToolAnnotations{
89102
Title: "Run tools with Javascript",
90103
},
91-
}}, nil
104+
}}
105+
106+
allTools = append(allTools, excludedTools...)
107+
108+
return allTools, nil
92109
}
93110

94111
func (c *codeModeTool) Start(ctx context.Context) error {

0 commit comments

Comments
 (0)