diff options
| author | adamdottv <[email protected]> | 2025-05-15 12:44:16 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-15 12:44:16 -0500 |
| commit | a65e593ab4f35e1a647832ba36be2c696e1f5165 (patch) | |
| tree | 38eed9994399e426a418c1e0424fe55133b648f4 /internal/llm/agent | |
| parent | 5d9058eb74581091d84b2cd935927da636b3dd37 (diff) | |
| download | opencode-a65e593ab4f35e1a647832ba36be2c696e1f5165.tar.gz opencode-a65e593ab4f35e1a647832ba36be2c696e1f5165.zip | |
feat: batch tool
Diffstat (limited to 'internal/llm/agent')
| -rw-r--r-- | internal/llm/agent/tools.go | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/internal/llm/agent/tools.go b/internal/llm/agent/tools.go index dba437bd2..157b5bf59 100644 --- a/internal/llm/agent/tools.go +++ b/internal/llm/agent/tools.go @@ -21,30 +21,41 @@ func PrimaryAgentTools( ctx := context.Background() mcpTools := GetMcpTools(ctx, permissions) - return append( - []tools.BaseTool{ - tools.NewBashTool(permissions), - tools.NewEditTool(lspClients, permissions, history), - tools.NewFetchTool(permissions), - tools.NewGlobTool(), - tools.NewGrepTool(), - tools.NewLsTool(), - tools.NewViewTool(lspClients), - tools.NewPatchTool(lspClients, permissions, history), - tools.NewWriteTool(lspClients, permissions, history), - tools.NewDiagnosticsTool(lspClients), - tools.NewDefinitionTool(lspClients), - tools.NewReferencesTool(lspClients), - tools.NewDocSymbolsTool(lspClients), - tools.NewWorkspaceSymbolsTool(lspClients), - tools.NewCodeActionTool(lspClients), - NewAgentTool(sessions, messages, lspClients), - }, mcpTools..., - ) + // Create the list of tools + toolsList := []tools.BaseTool{ + tools.NewBashTool(permissions), + tools.NewEditTool(lspClients, permissions, history), + tools.NewFetchTool(permissions), + tools.NewGlobTool(), + tools.NewGrepTool(), + tools.NewLsTool(), + tools.NewViewTool(lspClients), + tools.NewPatchTool(lspClients, permissions, history), + tools.NewWriteTool(lspClients, permissions, history), + tools.NewDiagnosticsTool(lspClients), + tools.NewDefinitionTool(lspClients), + tools.NewReferencesTool(lspClients), + tools.NewDocSymbolsTool(lspClients), + tools.NewWorkspaceSymbolsTool(lspClients), + tools.NewCodeActionTool(lspClients), + NewAgentTool(sessions, messages, lspClients), + } + + // Create a map of tools for the batch tool + toolsMap := make(map[string]tools.BaseTool) + for _, tool := range toolsList { + toolsMap[tool.Info().Name] = tool + } + + // Add the batch tool with access to all other tools + toolsList = append(toolsList, tools.NewBatchTool(toolsMap)) + + return append(toolsList, mcpTools...) } func TaskAgentTools(lspClients map[string]*lsp.Client) []tools.BaseTool { - return []tools.BaseTool{ + // Create the list of tools + toolsList := []tools.BaseTool{ tools.NewGlobTool(), tools.NewGrepTool(), tools.NewLsTool(), @@ -54,4 +65,15 @@ func TaskAgentTools(lspClients map[string]*lsp.Client) []tools.BaseTool { tools.NewDocSymbolsTool(lspClients), tools.NewWorkspaceSymbolsTool(lspClients), } + + // Create a map of tools for the batch tool + toolsMap := make(map[string]tools.BaseTool) + for _, tool := range toolsList { + toolsMap[tool.Info().Name] = tool + } + + // Add the batch tool with access to all other tools + toolsList = append(toolsList, tools.NewBatchTool(toolsMap)) + + return toolsList } |
