diff --git a/coderd/x/chatd/chatd.go b/coderd/x/chatd/chatd.go index 3def4d708b2..26ac9caf39c 100644 --- a/coderd/x/chatd/chatd.go +++ b/coderd/x/chatd/chatd.go @@ -2475,14 +2475,6 @@ type runChatResult struct { HistoryTipMessageID int64 } -func allToolNames(allTools []fantasy.AgentTool) []string { - toolNames := make([]string, 0, len(allTools)) - for _, tool := range allTools { - toolNames = append(toolNames, tool.Info().Name) - } - return toolNames -} - func isExploreSubagentMode(mode database.NullChatMode) bool { return mode.Valid && mode.ChatMode == database.ChatModeExplore } @@ -2651,19 +2643,6 @@ func allowedExploreToolNames(allTools []fantasy.AgentTool) []string { return toolNames } -// allowedBehaviorToolNames runs only on non-plan turns because -// appendDynamicTools returns early for plan mode. Within that boundary, -// Explore mode wins over the default behavior that allows all tools. -func allowedBehaviorToolNames( - allTools []fantasy.AgentTool, - chatMode database.NullChatMode, -) []string { - if isExploreSubagentMode(chatMode) { - return allowedExploreToolNames(allTools) - } - return allToolNames(allTools) -} - func stopAfterPlanTools( planMode database.NullChatPlanMode, parentChatID uuid.NullUUID, @@ -3057,15 +3036,8 @@ func appendDynamicTools( } } - activeToolNames := make(map[string]struct{}, len(tools)) - for _, name := range allowedBehaviorToolNames(tools, chatMode) { - activeToolNames[name] = struct{}{} - } for _, t := range tools { info := t.Info() - if _, active := activeToolNames[info.Name]; !active { - continue - } if dynamicToolNames[info.Name] { logger.Warn(ctx, "dynamic tool name collides with built-in tool, built-in takes precedence", slog.F("tool_name", info.Name)) diff --git a/coderd/x/chatd/chatd_internal_test.go b/coderd/x/chatd/chatd_internal_test.go index fc3401b408b..cc3c6a94927 100644 --- a/coderd/x/chatd/chatd_internal_test.go +++ b/coderd/x/chatd/chatd_internal_test.go @@ -905,40 +905,6 @@ func TestAllowedExploreToolNames(t *testing.T) { require.NotContains(t, got, chattool.FindToolsName) } -func TestAllowedBehaviorToolNames(t *testing.T) { - t.Parallel() - - makeTools := func(names ...string) []fantasy.AgentTool { - tools := make([]fantasy.AgentTool, 0, len(names)) - for _, name := range names { - tools = append(tools, newTestAgentTool(name)) - } - return tools - } - - allTools := makeTools("read_file", "custom_tool", "spawn_agent") - exploreMode := database.NullChatMode{ - ChatMode: database.ChatModeExplore, - Valid: true, - } - - t.Run("DefaultModeReturnsAllTools", func(t *testing.T) { - t.Parallel() - require.Equal(t, []string{"read_file", "custom_tool", "spawn_agent"}, allowedBehaviorToolNames( - allTools, - database.NullChatMode{}, - )) - }) - - t.Run("ExploreModeUsesExploreAllowlist", func(t *testing.T) { - t.Parallel() - require.Equal(t, []string{"read_file"}, allowedBehaviorToolNames( - allTools, - exploreMode, - )) - }) -} - func TestStopAfterPlanTools(t *testing.T) { t.Parallel()