Skip to content

Commit d63c264

Browse files
fix: enhance system prompts and improve embedding configuration extraction (#207)
Co-authored-by: Magesh <mageshmscss@gmail.com>
1 parent b53004e commit d63c264

File tree

5 files changed

+83
-25
lines changed

5 files changed

+83
-25
lines changed

src/core/prompts/system-prompt/build-system-prompt.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,23 @@ export const buildSystemPrompt = async (
2727
if (providerInfo.customPrompt === "compact" && isLocalModelFamily(providerInfo.providerId)) {
2828
return SYSTEM_PROMPT_COMPACT(cwd, supportsBrowserUse, mcpHub, browserSettings, focusChainSettings)
2929
}
30+
3031
// New prompts per family can be added as granularly as we like by adding a folder in the "families" folder
3132
// We then discriminate between families with a functions in the utils.
3233
if (isNextGenModelFamily(apiHandlerModel.id)) {
33-
return SYSTEM_PROMPT_NEXT_GEN(cwd, supportsBrowserUse, mcpHub, browserSettings, focusChainSettings)
34+
return SYSTEM_PROMPT_NEXT_GEN(
35+
cwd,
36+
supportsBrowserUse,
37+
mcpHub,
38+
browserSettings,
39+
focusChainSettings,
40+
supportsCodeIndex,
41+
expertPrompt,
42+
isDeepCrawlEnabled,
43+
expertName,
44+
)
3445
}
46+
3547
return haiSystemPrompt(
3648
cwd,
3749
supportsBrowserUse,

src/core/prompts/system-prompt/families/local-models/compact-system-prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const SYSTEM_PROMPT_COMPACT = async (
1212
_browserSettings: BrowserSettings,
1313
_focusChainSettings: FocusChainSettings,
1414
) => {
15-
return `**CLINE — Identity & Mission**
15+
return `**HAI — Identity & Mission**
1616
Senior software engineer + precise task runner. Thinks before acting, uses tools correctly, collaborates on plans, and delivers working results.
1717
1818
====

src/core/prompts/system-prompt/families/next-gen-models/next-gen-system-prompt.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,28 @@ import { FocusChainSettings } from "@shared/FocusChainSettings"
44
import { getShell } from "@utils/shell"
55
import os from "os"
66
import osName from "os-name"
7+
import {
8+
customCapabilitiesPrompt,
9+
customObjectivePrompt,
10+
customRulesPrompt,
11+
customToolsPrompt,
12+
customToolUseGuidelinePrompt,
13+
} from "@/core/prompts/custom"
714

815
export const SYSTEM_PROMPT_NEXT_GEN = async (
916
cwd: string,
1017
supportsBrowserUse: boolean,
1118
mcpHub: McpHub,
1219
browserSettings: BrowserSettings,
1320
focusChainSettings: FocusChainSettings,
21+
22+
// TAG:HAI
23+
supportsCodeIndex: boolean,
24+
expertPrompt?: string,
25+
isDeepCrawlEnabled?: boolean,
26+
expertName?: string,
1427
) => {
15-
return `You are HAI, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.
28+
return ` ${expertPrompt || "You are HAI, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices"}.
1629
1730
====
1831
@@ -47,6 +60,8 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
4760
4861
# Tools
4962
63+
${customToolsPrompt(supportsCodeIndex, isDeepCrawlEnabled, expertName)}
64+
5065
## execute_command
5166
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: ${cwd.toPosix()}
5267
Parameters:
@@ -552,6 +567,8 @@ ${
552567
- Any other relevant feedback or information related to the tool use.
553568
6. ALWAYS wait for user confirmation after each tool use before proceeding. Never assume the success of a tool use without explicit confirmation of the result from the user.
554569
570+
${customToolUseGuidelinePrompt(supportsCodeIndex)}
571+
555572
It is crucial to proceed step-by-step, waiting for the user's message after each tool use before moving forward with the task. This approach allows you to:
556573
1. Confirm the success of each step before proceeding.
557574
2. Address any issues or errors that arise immediately.
@@ -768,6 +785,7 @@ CAPABILITIES
768785
? "\n- You can use the browser_action tool to interact with websites (including html files and locally running development servers) through a Puppeteer-controlled browser when you feel it is necessary in accomplishing the user's task. This tool is particularly useful for web development tasks as it allows you to launch a browser, navigate to pages, interact with elements through clicks and keyboard input, and capture the results through screenshots and console logs. This tool may be useful at key stages of web development tasks-such as after implementing new features, making substantial changes, when troubleshooting issues, or to verify the result of your work. You can analyze the provided screenshots to ensure correct rendering or identify errors, and review console logs for runtime issues.\n - For example, if asked to add a component to a react website, you might create the necessary files, use execute_command to run the site locally, then use browser_action to launch the browser, navigate to the local server, and verify the component renders & functions correctly before closing the browser."
769786
: ""
770787
}
788+
${customCapabilitiesPrompt(supportsCodeIndex)}
771789
- You have access to MCP servers that may provide additional tools and resources. Each server may provide different capabilities that you can use to accomplish tasks more effectively.
772790
773791
====
@@ -776,7 +794,7 @@ If the user asks for help or wants to give feedback inform them of the following
776794
- To give feedback, users should report the issue using the /reportbug slash command in the chat.
777795
778796
When the user directly asks about HAI (eg 'can HAI do...', 'does HAI have...') or asks in second person (eg 'are you able...', 'can you do...'), first use the web_fetch tool to gather information to answer the question from HAI docs at https://docs.cline.bot.
779-
- The available sub-pages are \`getting-started\` (Intro for new coders, installing HAI and dev essentials), \`model-selection\` (Model Selection Guide, Custom Model Configs, Bedrock, Vertex, Codestral, LM Studio, Ollama), \`features\` (Auto approve, Checkpoints, HAI rules, Drag & Drop, Plan & Act, Workflows, etc), \`task-management\` (Task and Context Management in HAI), \`prompt-engineering\` (Improving your prompting skills, Prompt Engineering Guide), \`cline-tools\` (HAI Tools Reference Guide, New Task Tool, Remote Browser Support, Slash Commands), \`mcp\` (MCP Overview, Adding/Configuring Servers, Transport Mechanisms, MCP Dev Protocol), \`enterprise\` (Cloud provider integration, Security concerns, Custom instructions), \`more-info\` (Telemetry and other reference content)
797+
- The available sub-pages are \`getting-started\` (Intro for new coders, installing HAI and dev essentials), \`model-selection\` (Model Selection Guide, Custom Model Configs, Bedrock, Vertex, Codestral, LM Studio, Ollama), \`features\` (Auto approve, Checkpoints, HAI rules, Drag & Drop, Plan & Act, Workflows, etc), \`task-management\` (Task and Context Management in HAI), \`prompt-engineering\` (Improving your prompting skills, Prompt Engineering Guide), \`hai-tools\` (HAI Tools Reference Guide, New Task Tool, Remote Browser Support, Slash Commands), \`mcp\` (MCP Overview, Adding/Configuring Servers, Transport Mechanisms, MCP Dev Protocol), \`enterprise\` (Cloud provider integration, Security concerns, Custom instructions), \`more-info\` (Telemetry and other reference content)
780798
- Example: https://docs.cline.bot/features/auto-approve
781799
782800
====
@@ -816,6 +834,7 @@ RULES
816834
? " Then if you want to test your work, you might use browser_action to launch the site, wait for the user's response confirming the site was launched along with a screenshot, then perhaps e.g., click a button to test functionality if needed, wait for the user's response confirming the button was clicked along with a screenshot of the new state, before finally closing the browser."
817835
: ""
818836
}
837+
${customRulesPrompt(supportsCodeIndex, isDeepCrawlEnabled)}
819838
- MCP operations should be used one at a time, similar to other tool usage. Wait for confirmation of success before proceeding with additional operations.
820839
821840
====
@@ -837,5 +856,6 @@ You accomplish a given task iteratively, breaking it down into clear steps and w
837856
2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process. You will be informed on the work completed and what's remaining as you go.
838857
3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value. If all of the required parameters are present or can be reasonably inferred, close the thinking tag and proceed with the tool use. BUT, if one of the values for a required parameter is missing, DO NOT invoke the tool (not even with fillers for the missing params) and instead, ask the user to provide the missing parameters using the ask_followup_question tool. DO NOT ask for more information on optional parameters if it is not provided.
839858
4. Once you've completed the user's task, you must use the attempt_completion tool to present the result of the task to the user. You may also provide a CLI command to showcase the result of your task; this can be particularly useful for web development tasks, where you can run e.g. \`open index.html\` to show the website you've built.
840-
5. The user may provide feedback, which you can use to make improvements and try again. But DO NOT continue in pointless back and forth conversations, i.e. don't end your responses with questions or offers for further assistance.`
859+
5. The user may provide feedback, which you can use to make improvements and try again. But DO NOT continue in pointless back and forth conversations, i.e. don't end your responses with questions or offers for further assistance.
860+
${customObjectivePrompt(supportsCodeIndex)}`
841861
}

src/core/storage/CacheService.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -852,25 +852,25 @@ export class CacheService {
852852

853853
// Extract embedding configuration fields
854854
const {
855-
embeddingProvider,
856-
embeddingModelId,
857-
embeddingApiKey,
858-
embeddingOpenRouterApiKey,
859-
embeddingAwsAccessKey,
860-
embeddingAwsSecretKey,
861-
embeddingAwsSessionToken,
862-
embeddingAwsRegion,
863-
embeddingOpenAiBaseUrl,
864-
embeddingOpenAiApiKey,
865-
embeddingOpenAiModelId,
866-
embeddingOpenAiNativeApiKey,
867-
embeddingAzureOpenAIApiKey,
868-
embeddingAzureOpenAIApiInstanceName,
869-
embeddingAzureOpenAIApiEmbeddingsDeploymentName,
870-
embeddingAzureOpenAIApiVersion,
871-
embeddingOllamaBaseUrl,
872-
embeddingOllamaModelId,
873-
embeddingMaxRetries,
855+
provider: embeddingProvider,
856+
modelId: embeddingModelId,
857+
apiKey: embeddingApiKey,
858+
openRouterApiKey: embeddingOpenRouterApiKey,
859+
awsAccessKey: embeddingAwsAccessKey,
860+
awsSecretKey: embeddingAwsSecretKey,
861+
awsSessionToken: embeddingAwsSessionToken,
862+
awsRegion: embeddingAwsRegion,
863+
openAiBaseUrl: embeddingOpenAiBaseUrl,
864+
openAiApiKey: embeddingOpenAiApiKey,
865+
openAiModelId: embeddingOpenAiModelId,
866+
openAiNativeApiKey: embeddingOpenAiNativeApiKey,
867+
azureOpenAIApiKey: embeddingAzureOpenAIApiKey,
868+
azureOpenAIApiInstanceName: embeddingAzureOpenAIApiInstanceName,
869+
azureOpenAIApiEmbeddingsDeploymentName: embeddingAzureOpenAIApiEmbeddingsDeploymentName,
870+
azureOpenAIApiVersion: embeddingAzureOpenAIApiVersion,
871+
ollamaBaseUrl: embeddingOllamaBaseUrl,
872+
ollamaModelId: embeddingOllamaModelId,
873+
maxRetries: embeddingMaxRetries,
874874
} = state.embeddingConfiguration || {}
875875

876876
// TAG:HAI - Extract HAI-specific fields

webview-ui/src/components/experts/ExpertsView.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const ExpertsView: React.FC<ExpertsViewProps> = ({ onDone }) => {
6464
setDefaultExperts(message.grpc_response.message.experts)
6565
}
6666
if (message.grpc_response?.message?.key === "customExpertsLoaded") {
67-
console.log("Custom experts loaded:", message.grpc_response.message.experts)
6867
setCustomExperts(message.grpc_response.message.experts)
6968
}
7069
}
@@ -734,6 +733,33 @@ const ExpertsView: React.FC<ExpertsViewProps> = ({ onDone }) => {
734733
<p className="description-text">
735734
Enabling deep crawl can explore websites beyond a single page by following internal links.
736735
</p>
736+
<div
737+
className="info-message"
738+
style={{
739+
display: "flex",
740+
alignItems: "flex-start",
741+
gap: "8px",
742+
color: "var(--vscode-foreground)",
743+
fontSize: "12px",
744+
padding: "8px",
745+
backgroundColor: "var(--vscode-editorWidget-background)",
746+
border: "1px solid var(--vscode-widget-border)",
747+
borderRadius: "4px",
748+
marginBottom: "16px",
749+
}}>
750+
<i
751+
className="codicon codicon-info"
752+
style={{
753+
fontSize: "14px",
754+
marginTop: "2px",
755+
color: "var(--vscode-textLink-foreground)",
756+
}}
757+
/>
758+
<span>
759+
Please note: Experts feature won't work when 'Auto Compact' is enabled or when using a
760+
local LLM model.
761+
</span>
762+
</div>
737763
</FormGroup>
738764
{deepCrawl && (
739765
<>

0 commit comments

Comments
 (0)