Changesets · Branches · Tags · Compare
| Changeset | d717cb1b1923a244dfdd5b6b17d84332a114e702d014178f27855bedb99b5dc8 |
|---|---|
| Author | Nate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-07-07 13:05 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-07-07 13:05 -07:00 |
| Parents | f77b04d88949, 0a8d03b3c064 |
21 files changed
modified core/config/load.ts +1 −0
| @@ -643,6 +643,7 @@ | ||
| 643 | 643 | template: llm.template, |
| 644 | 644 | completionOptions: llm.completionOptions, |
| 645 | 645 | baseAgentSystemMessage: llm.baseAgentSystemMessage, |
| 646 | + basePlanSystemMessage: llm.basePlanSystemMessage, | |
| 646 | 647 | baseChatSystemMessage: llm.baseChatSystemMessage, |
| 647 | 648 | requestOptions: llm.requestOptions, |
| 648 | 649 | promptTemplates: serializePromptTemplates(llm.promptTemplates), |
modified core/config/yaml/models.ts +1 −0
| @@ -63,6 +63,7 @@ | ||
| 63 | 63 | template: model.promptTemplates?.chat, |
| 64 | 64 | promptTemplates: model.promptTemplates, |
| 65 | 65 | baseAgentSystemMessage: model.chatOptions?.baseAgentSystemMessage, |
| 66 | + basePlanSystemMessage: model.chatOptions?.basePlanSystemMessage, | |
| 66 | 67 | baseChatSystemMessage: model.chatOptions?.baseSystemMessage, |
| 67 | 68 | capabilities: { |
| 68 | 69 | tools: model.capabilities?.includes("tool_use"), |
modified core/index.d.ts +7 −3
| @@ -428,7 +428,7 @@ | ||
| 428 | 428 | completion: string; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | -export type MessageModes = "chat" | "agent"; | |
| 431 | +export type MessageModes = "chat" | "agent" | "plan"; | |
| 432 | 432 | |
| 433 | 433 | export type ToolStatus = |
| 434 | 434 | | "generating" |
| @@ -568,6 +568,7 @@ | ||
| 568 | 568 | title?: string; |
| 569 | 569 | uniqueId?: string; |
| 570 | 570 | baseAgentSystemMessage?: string; |
| 571 | + basePlanSystemMessage?: string; | |
| 571 | 572 | baseChatSystemMessage?: string; |
| 572 | 573 | autocompleteOptions?: Partial<TabAutocompleteOptions>; |
| 573 | 574 | contextLength?: number; |
| @@ -1091,6 +1092,7 @@ | ||
| 1091 | 1092 | template?: TemplateType; |
| 1092 | 1093 | completionOptions?: BaseCompletionOptions; |
| 1093 | 1094 | baseAgentSystemMessage?: string; |
| 1095 | + basePlanSystemMessage?: string; | |
| 1094 | 1096 | baseChatSystemMessage?: string; |
| 1095 | 1097 | requestOptions?: RequestOptions; |
| 1096 | 1098 | promptTemplates?: { [key: string]: string }; |
| @@ -1637,9 +1639,11 @@ | ||
| 1637 | 1639 | |
| 1638 | 1640 | export type RuleSource = |
| 1639 | 1641 | | "default-chat" |
| 1642 | + | "default-plan" | |
| 1640 | 1643 | | "default-agent" |
| 1641 | - | "model-chat-options" | |
| 1642 | - | "model-agent-options" | |
| 1644 | + | "model-options-chat" | |
| 1645 | + | "model-options-plan" | |
| 1646 | + | "model-options-agent" | |
| 1643 | 1647 | | "rules-block" |
| 1644 | 1648 | | "json-systemMessage" |
| 1645 | 1649 | | ".continuerules"; |
modified core/llm/defaultSystemMessages.ts +15 −4
| @@ -1,7 +1,4 @@ | ||
| 1 | -export const DEFAULT_CHAT_SYSTEM_MESSAGE_URL = | |
| 2 | - "https://github.com/continuedev/continue/blob/main/core/llm/defaultSystemMessages.ts"; | |
| 3 | - | |
| 4 | -export const DEFAULT_AGENT_SYSTEM_MESSAGE_URL = | |
| 1 | +export const DEFAULT_SYSTEM_MESSAGES_URL = | |
| 5 | 2 | "https://github.com/continuedev/continue/blob/main/core/llm/defaultSystemMessages.ts"; |
| 6 | 3 | |
| 7 | 4 | export const CODEBLOCK_FORMATTING_INSTRUCTIONS = `\ |
| @@ -66,3 +63,17 @@ | ||
| 66 | 63 | |
| 67 | 64 | ${CODEBLOCK_FORMATTING_INSTRUCTIONS} |
| 68 | 65 | </important_rules>`; |
| 66 | + | |
| 67 | +// The note about read-only tools is for MCP servers | |
| 68 | +// For now, all MCP tools are included so model can decide if they are read-only | |
| 69 | +export const DEFAULT_PLAN_SYSTEM_MESSAGE = `\ | |
| 70 | +<important_rules> | |
| 71 | + You are in plan mode, in which you help the user understand and construct a plan. | |
| 72 | + Only use read-only tools. Do not use any tools that would write to non-temporary files. | |
| 73 | + If the user wants to make changes, offer that they can switch to Agent mode to give you access to write tools to make the suggested updates. | |
| 74 | + | |
| 75 | +${CODEBLOCK_FORMATTING_INSTRUCTIONS} | |
| 76 | +${EDIT_CODE_INSTRUCTIONS} | |
| 77 | + | |
| 78 | + In plan mode, only write code when directly suggesting changes. Prioritize understanding and developing a plan. | |
| 79 | +</important_rules>`; |
modified core/llm/index.ts +2 −0
| @@ -141,6 +141,7 @@ | ||
| 141 | 141 | |
| 142 | 142 | title?: string; |
| 143 | 143 | baseChatSystemMessage?: string; |
| 144 | + basePlanSystemMessage?: string; | |
| 144 | 145 | baseAgentSystemMessage?: string; |
| 145 | 146 | contextLength: number; |
| 146 | 147 | maxStopWords?: number | undefined; |
| @@ -209,6 +210,7 @@ | ||
| 209 | 210 | this.title = options.title; |
| 210 | 211 | this.uniqueId = options.uniqueId ?? "None"; |
| 211 | 212 | this.baseAgentSystemMessage = options.baseAgentSystemMessage; |
| 213 | + this.basePlanSystemMessage = options.basePlanSystemMessage; | |
| 212 | 214 | this.baseChatSystemMessage = options.baseChatSystemMessage; |
| 213 | 215 | this.contextLength = |
| 214 | 216 | options.contextLength ?? llmInfo?.contextLength ?? DEFAULT_CONTEXT_LENGTH; |
modified core/llm/llms/index.ts +4 −4
| @@ -8,7 +8,6 @@ | ||
| 8 | 8 | LLMOptions, |
| 9 | 9 | } from "../.."; |
| 10 | 10 | import { renderTemplatedString } from "../../util/handlebars/renderTemplatedString"; |
| 11 | -import { DEFAULT_CHAT_SYSTEM_MESSAGE } from "../defaultSystemMessages"; | |
| 12 | 11 | import { BaseLLM } from "../index"; |
| 13 | 12 | import Anthropic from "./Anthropic"; |
| 14 | 13 | import Asksage from "./Asksage"; |
| @@ -141,9 +140,9 @@ | ||
| 141 | 140 | |
| 142 | 141 | let baseChatSystemMessage: string | undefined = undefined; |
| 143 | 142 | if (desc.systemMessage !== undefined) { |
| 144 | - baseChatSystemMessage = DEFAULT_CHAT_SYSTEM_MESSAGE; | |
| 145 | - baseChatSystemMessage += "\n\n"; | |
| 146 | - baseChatSystemMessage += await renderTemplatedString( | |
| 143 | + // baseChatSystemMessage = DEFAULT_CHAT_SYSTEM_MESSAGE; | |
| 144 | + // baseChatSystemMessage += "\n\n"; | |
| 145 | + baseChatSystemMessage = await renderTemplatedString( | |
| 147 | 146 | Handlebars, |
| 148 | 147 | desc.systemMessage, |
| 149 | 148 | {}, |
| @@ -163,6 +162,7 @@ | ||
| 163 | 162 | cls.defaultOptions?.completionOptions?.maxTokens, |
| 164 | 163 | }, |
| 165 | 164 | baseChatSystemMessage, |
| 165 | + basePlanSystemMessage: baseChatSystemMessage, | |
| 166 | 166 | baseAgentSystemMessage: baseChatSystemMessage, |
| 167 | 167 | logger: llmLogger, |
| 168 | 168 | uniqueId, |
modified gui/src/components/ModeSelect/ModeIcon.tsx +7 −1
| @@ -1,4 +1,8 @@ | ||
| 1 | -import { ChatBubbleLeftIcon, SparklesIcon } from "@heroicons/react/24/outline"; | |
| 1 | +import { | |
| 2 | + ChatBubbleLeftIcon, | |
| 3 | + SparklesIcon, | |
| 4 | + SwatchIcon, | |
| 5 | +} from "@heroicons/react/24/outline"; | |
| 2 | 6 | import { MessageModes } from "core"; |
| 3 | 7 | |
| 4 | 8 | interface ModeIconProps { |
| @@ -13,6 +17,8 @@ | ||
| 13 | 17 | switch (mode) { |
| 14 | 18 | case "agent": |
| 15 | 19 | return <SparklesIcon className={className} />; |
| 20 | + case "plan": | |
| 21 | + return <SwatchIcon className={className} />; | |
| 16 | 22 | case "chat": |
| 17 | 23 | return <ChatBubbleLeftIcon className={className} />; |
| 18 | 24 | } |
modified gui/src/components/ModeSelect/ModeSelect.tsx +59 −6
| @@ -1,4 +1,8 @@ | ||
| 1 | -import { CheckIcon, ChevronDownIcon } from "@heroicons/react/24/outline"; | |
| 1 | +import { | |
| 2 | + CheckIcon, | |
| 3 | + ChevronDownIcon, | |
| 4 | + InformationCircleIcon, | |
| 5 | +} from "@heroicons/react/24/outline"; | |
| 2 | 6 | import { MessageModes } from "core"; |
| 3 | 7 | import { modelSupportsTools } from "core/llm/autodetect"; |
| 4 | 8 | import { useCallback, useEffect, useMemo } from "react"; |
| @@ -6,6 +10,7 @@ | ||
| 6 | 10 | import { selectSelectedChatModel } from "../../redux/slices/configSlice"; |
| 7 | 11 | import { setMode } from "../../redux/slices/sessionSlice"; |
| 8 | 12 | import { getFontSize, getMetaKeyLabel } from "../../util"; |
| 13 | +import { ToolTip } from "../gui/Tooltip"; | |
| 9 | 14 | import { useMainEditor } from "../mainInput/TipTapEditor"; |
| 10 | 15 | import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../ui"; |
| 11 | 16 | import { ModeIcon } from "./ModeIcon"; |
| @@ -27,13 +32,19 @@ | ||
| 27 | 32 | if (!selectedModel) { |
| 28 | 33 | return; |
| 29 | 34 | } |
| 30 | - if (mode === "agent" && !agentModeSupported) { | |
| 35 | + if (mode !== "chat" && !agentModeSupported) { | |
| 31 | 36 | dispatch(setMode("chat")); |
| 32 | 37 | } |
| 33 | 38 | }, [mode, agentModeSupported, dispatch, selectedModel]); |
| 34 | 39 | |
| 35 | 40 | const cycleMode = useCallback(() => { |
| 36 | - dispatch(setMode(mode === "chat" ? "agent" : "chat")); | |
| 41 | + if (mode === "chat") { | |
| 42 | + dispatch(setMode("plan")); | |
| 43 | + } else if (mode === "plan") { | |
| 44 | + dispatch(setMode("agent")); | |
| 45 | + } else { | |
| 46 | + dispatch(setMode("chat")); | |
| 47 | + } | |
| 37 | 48 | // Only focus main editor if another one doesn't already have focus |
| 38 | 49 | if (!document.activeElement?.classList?.contains("ProseMirror")) { |
| 39 | 50 | mainEditor?.commands.focus(); |
| @@ -74,7 +85,7 @@ | ||
| 74 | 85 | > |
| 75 | 86 | <ModeIcon mode={mode} /> |
| 76 | 87 | <span className="hidden sm:block"> |
| 77 | - {mode.charAt(0).toUpperCase() + mode.slice(1)} | |
| 88 | + {mode === "chat" ? "Chat" : mode === "agent" ? "Agent" : "Plan"} | |
| 78 | 89 | </span> |
| 79 | 90 | <ChevronDownIcon |
| 80 | 91 | className="h-2 w-2 flex-shrink-0" |
| @@ -94,7 +105,35 @@ | ||
| 94 | 105 | </div> |
| 95 | 106 | {mode === "chat" && <CheckIcon className="ml-auto h-3 w-3" />} |
| 96 | 107 | </ListboxOption> |
| 97 | - | |
| 108 | + <ListboxOption | |
| 109 | + value="plan" | |
| 110 | + disabled={!agentModeSupported} | |
| 111 | + className={"gap-1"} | |
| 112 | + > | |
| 113 | + <div className="flex flex-row items-center gap-1.5"> | |
| 114 | + <ModeIcon mode="plan" /> | |
| 115 | + <span className="">Plan</span> | |
| 116 | + <InformationCircleIcon | |
| 117 | + data-tooltip-id="plan-tip" | |
| 118 | + className="h-2.5 w-2.5 flex-shrink-0" | |
| 119 | + /> | |
| 120 | + <ToolTip | |
| 121 | + id="plan-tip" | |
| 122 | + style={{ | |
| 123 | + zIndex: 200001, | |
| 124 | + }} | |
| 125 | + > | |
| 126 | + In Plan mode, only read-only and MCP tools are enabled | |
| 127 | + </ToolTip> | |
| 128 | + </div> | |
| 129 | + {agentModeSupported ? ( | |
| 130 | + <CheckIcon | |
| 131 | + className={`ml-auto h-3 w-3 ${mode === "plan" ? "" : "opacity-0"}`} | |
| 132 | + /> | |
| 133 | + ) : ( | |
| 134 | + <span>(Not supported)</span> | |
| 135 | + )} | |
| 136 | + </ListboxOption> | |
| 98 | 137 | <ListboxOption |
| 99 | 138 | value="agent" |
| 100 | 139 | disabled={!agentModeSupported} |
| @@ -103,9 +142,23 @@ | ||
| 103 | 142 | <div className="flex flex-row items-center gap-1.5"> |
| 104 | 143 | <ModeIcon mode="agent" /> |
| 105 | 144 | <span className="">Agent</span> |
| 145 | + <InformationCircleIcon | |
| 146 | + data-tooltip-id="agent-tip" | |
| 147 | + className="h-2.5 w-2.5 flex-shrink-0" | |
| 148 | + /> | |
| 149 | + <ToolTip | |
| 150 | + id="agent-tip" | |
| 151 | + style={{ | |
| 152 | + zIndex: 200001, | |
| 153 | + }} | |
| 154 | + > | |
| 155 | + All tools are enabled based on policies | |
| 156 | + </ToolTip> | |
| 106 | 157 | </div> |
| 107 | 158 | {agentModeSupported ? ( |
| 108 | - mode === "agent" && <CheckIcon className="ml-auto h-3 w-3" /> | |
| 159 | + <CheckIcon | |
| 160 | + className={`ml-auto h-3 w-3 ${mode === "agent" ? "" : "opacity-0"}`} | |
| 161 | + /> | |
| 109 | 162 | ) : ( |
| 110 | 163 | <span>(Not supported)</span> |
| 111 | 164 | )} |
modified gui/src/components/gui/Switch.tsx +6 −2
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | text: string; |
| 8 | 8 | size?: number; |
| 9 | 9 | showIfToggled?: ReactNode; |
| 10 | + disabled?: boolean; | |
| 10 | 11 | }; |
| 11 | 12 | |
| 12 | 13 | const ToggleSwitch: React.FC<ToggleSwitchProps> = ({ |
| @@ -15,15 +16,18 @@ | ||
| 15 | 16 | text, |
| 16 | 17 | size = 16, |
| 17 | 18 | showIfToggled, |
| 19 | + disabled = false, | |
| 18 | 20 | }) => { |
| 19 | 21 | return ( |
| 20 | - <div className="flex cursor-pointer select-none items-center justify-between gap-3"> | |
| 22 | + <div | |
| 23 | + className={`flex select-none items-center justify-between gap-3 ${disabled ? "cursor-not-allowed" : "cursor-pointer"}`} | |
| 24 | + > | |
| 21 | 25 | <span className="truncate-right">{text}</span> |
| 22 | 26 | <div className="flex flex-row items-center gap-1"> |
| 23 | 27 | {isToggled && !!showIfToggled && showIfToggled} |
| 24 | 28 | <div |
| 25 | 29 | className={`border-vsc-input-border bg-vsc-input-background flex items-center rounded-full border border-solid`} |
| 26 | - onClick={onToggle} | |
| 30 | + onClick={disabled ? undefined : onToggle} | |
| 27 | 31 | style={{ |
| 28 | 32 | height: size, |
| 29 | 33 | width: size * 2, |
modified gui/src/components/mainInput/Lump/sections/RulesSection.tsx +32 −15
| @@ -7,9 +7,8 @@ | ||
| 7 | 7 | import { RuleWithSource } from "core"; |
| 8 | 8 | import { |
| 9 | 9 | DEFAULT_AGENT_SYSTEM_MESSAGE, |
| 10 | - DEFAULT_AGENT_SYSTEM_MESSAGE_URL, | |
| 11 | 10 | DEFAULT_CHAT_SYSTEM_MESSAGE, |
| 12 | - DEFAULT_CHAT_SYSTEM_MESSAGE_URL, | |
| 11 | + DEFAULT_SYSTEM_MESSAGES_URL, | |
| 13 | 12 | } from "core/llm/defaultSystemMessages"; |
| 14 | 13 | import { useContext, useMemo } from "react"; |
| 15 | 14 | import { useAuth } from "../../../../context/Auth"; |
| @@ -52,10 +51,12 @@ | ||
| 52 | 51 | ideMessenger.post("openFile", { |
| 53 | 52 | path: rule.ruleFile, |
| 54 | 53 | }); |
| 55 | - } else if (rule.source === "default-chat" && mode === "chat") { | |
| 56 | - ideMessenger.post("openUrl", DEFAULT_CHAT_SYSTEM_MESSAGE_URL); | |
| 57 | - } else if (rule.source === "default-agent" && mode === "agent") { | |
| 58 | - ideMessenger.post("openUrl", DEFAULT_AGENT_SYSTEM_MESSAGE_URL); | |
| 54 | + } else if ( | |
| 55 | + rule.source === "default-chat" || | |
| 56 | + rule.source === "default-plan" || | |
| 57 | + rule.source === "default-agent" | |
| 58 | + ) { | |
| 59 | + ideMessenger.post("openUrl", DEFAULT_SYSTEM_MESSAGES_URL); | |
| 59 | 60 | } else { |
| 60 | 61 | ideMessenger.post("config/openProfile", { |
| 61 | 62 | profileId: undefined, |
| @@ -81,9 +82,11 @@ | ||
| 81 | 82 | return "Default agent system message"; |
| 82 | 83 | } else if (rule.source === "json-systemMessage") { |
| 83 | 84 | return "JSON systemMessage)"; |
| 84 | - } else if (rule.source === "model-agent-options") { | |
| 85 | + } else if (rule.source === "model-options-agent") { | |
| 85 | 86 | return "Base System Agent Message"; |
| 86 | - } else if (rule.source === "model-chat-options") { | |
| 87 | + } else if (rule.source === "model-options-plan") { | |
| 88 | + return "Base System Plan Message"; | |
| 89 | + } else if (rule.source === "model-options-chat") { | |
| 87 | 90 | return "Base System Chat Message"; |
| 88 | 91 | } else { |
| 89 | 92 | return "Assistant rule"; |
| @@ -215,11 +218,24 @@ | ||
| 215 | 218 | } |
| 216 | 219 | } |
| 217 | 220 | |
| 218 | - if (mode === "agent") { | |
| 221 | + if (mode === "chat") { | |
| 222 | + if (config.selectedModelByRole.chat?.baseChatSystemMessage) { | |
| 223 | + rules.unshift({ | |
| 224 | + rule: config.selectedModelByRole.chat?.baseChatSystemMessage, | |
| 225 | + source: "model-options-chat", | |
| 226 | + }); | |
| 227 | + } else { | |
| 228 | + rules.unshift({ | |
| 229 | + rule: DEFAULT_CHAT_SYSTEM_MESSAGE, | |
| 230 | + source: "default-chat", | |
| 231 | + }); | |
| 232 | + } | |
| 233 | + } else if (mode === "agent") { | |
| 234 | + // agent | |
| 219 | 235 | if (config.selectedModelByRole.chat?.baseAgentSystemMessage) { |
| 220 | 236 | rules.unshift({ |
| 221 | 237 | rule: config.selectedModelByRole.chat?.baseAgentSystemMessage, |
| 222 | - source: "model-agent-options", | |
| 238 | + source: "model-options-agent", | |
| 223 | 239 | }); |
| 224 | 240 | } else { |
| 225 | 241 | rules.unshift({ |
| @@ -228,15 +244,16 @@ | ||
| 228 | 244 | }); |
| 229 | 245 | } |
| 230 | 246 | } else { |
| 231 | - if (config.selectedModelByRole.chat?.baseChatSystemMessage) { | |
| 247 | + // plan | |
| 248 | + if (config.selectedModelByRole.chat?.basePlanSystemMessage) { | |
| 232 | 249 | rules.unshift({ |
| 233 | - rule: config.selectedModelByRole.chat?.baseChatSystemMessage, | |
| 234 | - source: "model-chat-options", | |
| 250 | + rule: config.selectedModelByRole.chat?.basePlanSystemMessage, | |
| 251 | + source: "model-options-plan", | |
| 235 | 252 | }); |
| 236 | 253 | } else { |
| 237 | 254 | rules.unshift({ |
| 238 | - rule: DEFAULT_CHAT_SYSTEM_MESSAGE, | |
| 239 | - source: "default-chat", | |
| 255 | + rule: DEFAULT_AGENT_SYSTEM_MESSAGE, | |
| 256 | + source: "default-agent", | |
| 240 | 257 | }); |
| 241 | 258 | } |
| 242 | 259 | } |
modified gui/src/components/mainInput/Lump/sections/tool-policies/ToolPoliciesSection.tsx +66 −28
| @@ -1,3 +1,4 @@ | ||
| 1 | +import { InformationCircleIcon } from "@heroicons/react/24/outline"; | |
| 1 | 2 | import { Tool } from "core"; |
| 2 | 3 | import { useMemo } from "react"; |
| 3 | 4 | import { useAppDispatch, useAppSelector } from "../../../../../redux/hooks"; |
| @@ -6,7 +7,26 @@ | ||
| 6 | 7 | import ToggleSwitch from "../../../../gui/Switch"; |
| 7 | 8 | import ToolPolicyItem from "./ToolPolicyItem"; |
| 8 | 9 | |
| 10 | +interface ModeBadgeProps { | |
| 11 | + text: string; | |
| 12 | + icon: React.ReactNode; | |
| 13 | + onClick: () => void; | |
| 14 | + isSelected: boolean; | |
| 15 | +} | |
| 16 | +const ModeBadge = ({ text, onClick, isSelected, icon }: ModeBadgeProps) => { | |
| 17 | + return ( | |
| 18 | + <div | |
| 19 | + className="flex flex-1 items-center justify-center gap-1.5 text-sm" | |
| 20 | + onClick={isSelected ? undefined : onClick} | |
| 21 | + > | |
| 22 | + {icon} | |
| 23 | + {text} | |
| 24 | + </div> | |
| 25 | + ); | |
| 26 | +}; | |
| 27 | + | |
| 9 | 28 | export const ToolPoliciesSection = () => { |
| 29 | + const mode = useAppSelector((state) => state.session.mode); | |
| 10 | 30 | const availableTools = useAppSelector((state) => state.config.config.tools); |
| 11 | 31 | const toolGroupSettings = useAppSelector( |
| 12 | 32 | (store) => store.ui.toolGroupSettings, |
| @@ -39,38 +59,56 @@ | ||
| 39 | 59 | ); |
| 40 | 60 | }, [availableTools]); |
| 41 | 61 | |
| 62 | + const allToolsOff = mode === "chat"; | |
| 63 | + | |
| 64 | + const message = | |
| 65 | + mode === "chat" | |
| 66 | + ? "All tools are disabled in Chat mode" | |
| 67 | + : mode === "plan" | |
| 68 | + ? "Plan mode: only read-only and MCP tools" | |
| 69 | + : "Agent mode: all tool policies apply"; | |
| 70 | + | |
| 42 | 71 | return ( |
| 43 | 72 | <> |
| 44 | - {toolsByGroup.map(([groupName, tools]) => ( | |
| 45 | - <div key={groupName} className="mt-2 flex flex-col pr-1"> | |
| 46 | - <div className="flex flex-row items-center justify-between px-1"> | |
| 47 | - <h3 | |
| 48 | - className="m-0 p-0 font-bold" | |
| 49 | - style={{ | |
| 50 | - fontSize: fontSize(-2), | |
| 51 | - }} | |
| 52 | - > | |
| 53 | - {groupName} | |
| 54 | - </h3> | |
| 55 | - <ToggleSwitch | |
| 56 | - isToggled={toolGroupSettings[groupName] !== "exclude"} | |
| 57 | - onToggle={() => dispatch(toggleToolGroupSetting(groupName))} | |
| 58 | - text="" | |
| 59 | - size={10} | |
| 60 | - /> | |
| 61 | - </div> | |
| 62 | - <div className={`relative flex flex-col p-1`}> | |
| 63 | - {tools.map((tool) => ( | |
| 64 | - <ToolPolicyItem | |
| 65 | - key={tool.uri + tool.function.name} | |
| 66 | - tool={tool} | |
| 67 | - duplicatesDetected={duplicateDetection[tool.function.name]} | |
| 68 | - excluded={toolGroupSettings[groupName] === "exclude"} | |
| 73 | + <div className="mb-3 px-1"> | |
| 74 | + <InformationCircleIcon className="text-description-muted mr-1.5 inline-block h-2.5 w-2.5 flex-shrink-0" /> | |
| 75 | + <span className="text-description text-xs italic">{message}</span> | |
| 76 | + </div> | |
| 77 | + {toolsByGroup.map(([groupName, tools]) => { | |
| 78 | + const isGroupEnabled = | |
| 79 | + !allToolsOff && toolGroupSettings[groupName] !== "exclude"; | |
| 80 | + return ( | |
| 81 | + <div key={groupName} className="mt-2 flex flex-col pr-1"> | |
| 82 | + <div className="flex flex-row items-center justify-between px-1"> | |
| 83 | + <h3 | |
| 84 | + className="m-0 p-0 font-bold" | |
| 85 | + style={{ | |
| 86 | + fontSize: fontSize(-2), | |
| 87 | + }} | |
| 88 | + > | |
| 89 | + {groupName} | |
| 90 | + </h3> | |
| 91 | + <ToggleSwitch | |
| 92 | + isToggled={isGroupEnabled} | |
| 93 | + onToggle={() => dispatch(toggleToolGroupSetting(groupName))} | |
| 94 | + text="" | |
| 95 | + size={10} | |
| 96 | + disabled={allToolsOff} | |
| 69 | 97 | /> |
| 70 | - ))} | |
| 98 | + </div> | |
| 99 | + <div className={`relative flex flex-col p-1`}> | |
| 100 | + {tools.map((tool) => ( | |
| 101 | + <ToolPolicyItem | |
| 102 | + key={tool.uri + tool.function.name} | |
| 103 | + tool={tool} | |
| 104 | + duplicatesDetected={duplicateDetection[tool.function.name]} | |
| 105 | + isGroupEnabled={isGroupEnabled} | |
| 106 | + /> | |
| 107 | + ))} | |
| 108 | + </div> | |
| 71 | 109 | </div> |
| 72 | - </div> | |
| 73 | - ))} | |
| 110 | + ); | |
| 111 | + })} | |
| 74 | 112 | </> |
| 75 | 113 | ); |
| 76 | 114 | }; |
modified gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx +21 −8
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | InformationCircleIcon, |
| 4 | 4 | } from "@heroicons/react/24/outline"; |
| 5 | 5 | import { Tool } from "core"; |
| 6 | +import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn"; | |
| 6 | 7 | import { useEffect, useMemo, useState } from "react"; |
| 7 | 8 | import { useDispatch } from "react-redux"; |
| 8 | 9 | import { useAppSelector } from "../../../../../redux/hooks"; |
| @@ -16,7 +17,7 @@ | ||
| 16 | 17 | interface ToolDropdownItemProps { |
| 17 | 18 | tool: Tool; |
| 18 | 19 | duplicatesDetected: boolean; |
| 19 | - excluded: boolean; | |
| 20 | + isGroupEnabled: boolean; | |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | function ToolPolicyItem(props: ToolDropdownItemProps) { |
| @@ -25,6 +26,7 @@ | ||
| 25 | 26 | (state) => state.ui.toolSettings[props.tool.function.name], |
| 26 | 27 | ); |
| 27 | 28 | const [isExpanded, setIsExpanded] = useState(false); |
| 29 | + const mode = useAppSelector((state) => state.session.mode); | |
| 28 | 30 | |
| 29 | 31 | useEffect(() => { |
| 30 | 32 | if (!policy) { |
| @@ -44,6 +46,12 @@ | ||
| 44 | 46 | |
| 45 | 47 | const fontSize = useFontSize(-2); |
| 46 | 48 | |
| 49 | + const disabled = | |
| 50 | + !props.isGroupEnabled || | |
| 51 | + (mode === "plan" && | |
| 52 | + props.tool.group === BUILT_IN_GROUP_NAME && | |
| 53 | + !props.tool.readonly); | |
| 54 | + | |
| 47 | 55 | if (!policy) { |
| 48 | 56 | return null; |
| 49 | 57 | } |
| @@ -106,16 +114,21 @@ | ||
| 106 | 114 | </span> |
| 107 | 115 | </div> |
| 108 | 116 | </div> |
| 117 | + | |
| 109 | 118 | <div |
| 110 | - className={`flex w-8 flex-row items-center justify-end gap-2 px-2 py-0.5 sm:w-16 ${props.excluded ? "cursor-not-allowed" : "hover:bg-list-active hover:text-list-active-foreground cursor-pointer"}`} | |
| 119 | + className={`flex w-8 flex-row items-center justify-end gap-2 px-2 py-0.5 sm:w-16 ${disabled ? "cursor-not-allowed" : "hover:bg-list-active hover:text-list-active-foreground cursor-pointer"}`} | |
| 111 | 120 | data-testid={`tool-policy-item-${props.tool.function.name}`} |
| 112 | - onClick={(e) => { | |
| 113 | - dispatch(toggleToolSetting(props.tool.function.name)); | |
| 114 | - e.stopPropagation(); | |
| 115 | - e.preventDefault(); | |
| 116 | - }} | |
| 121 | + onClick={ | |
| 122 | + disabled | |
| 123 | + ? undefined | |
| 124 | + : (e) => { | |
| 125 | + dispatch(toggleToolSetting(props.tool.function.name)); | |
| 126 | + e.stopPropagation(); | |
| 127 | + e.preventDefault(); | |
| 128 | + } | |
| 129 | + } | |
| 117 | 130 | > |
| 118 | - {props.excluded || policy === "disabled" ? ( | |
| 131 | + {disabled || policy === "disabled" ? ( | |
| 119 | 132 | <> |
| 120 | 133 | <span className="text-lightgray sm:hidden">Off</span> |
| 121 | 134 | <span className="text-lightgray hidden sm:inline-block"> |
modified gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +4 −2
| @@ -19,9 +19,11 @@ | ||
| 19 | 19 | return "Default Chat"; |
| 20 | 20 | case "default-agent": |
| 21 | 21 | return "Default Agent"; |
| 22 | - case "model-chat-options": | |
| 22 | + case "model-options-chat": | |
| 23 | 23 | return "Model Chat Options"; |
| 24 | - case "model-agent-options": | |
| 24 | + case "model-options-plan": | |
| 25 | + return "Model Plan Options"; | |
| 26 | + case "model-options-agent": | |
| 25 | 27 | return "Model Agent Options"; |
| 26 | 28 | case "rules-block": |
| 27 | 29 | return "Rules Block"; |
modified gui/src/pages/gui/chat-tests/Chat.test.tsx +12 −0
| @@ -27,6 +27,18 @@ | ||
| 27 | 27 | ); |
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | + // Check that it switched to Plan mode | |
| 31 | + await getElementByText("Plan"); | |
| 32 | + | |
| 33 | + act(() => { | |
| 34 | + document.dispatchEvent( | |
| 35 | + new KeyboardEvent("keydown", { | |
| 36 | + key: ".", | |
| 37 | + metaKey: true, // cmd key on Mac | |
| 38 | + }), | |
| 39 | + ); | |
| 40 | + }); | |
| 41 | + | |
| 30 | 42 | // Check that it switched to Agent mode |
| 31 | 43 | await getElementByText("Agent"); |
| 32 | 44 |
modified gui/src/redux/selectors/selectActiveTools.ts +9 −4
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { createSelector } from "@reduxjs/toolkit"; |
| 2 | 2 | import { Tool } from "core"; |
| 3 | +import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn"; | |
| 3 | 4 | import { RootState } from "../store"; |
| 4 | 5 | |
| 5 | 6 | export const selectActiveTools = createSelector( |
| @@ -12,14 +13,18 @@ | ||
| 12 | 13 | (mode, tools, policies, groupPolicies): Tool[] => { |
| 13 | 14 | if (mode === "chat") { |
| 14 | 15 | return []; |
| 15 | - } else if (mode === "agent") { | |
| 16 | - return tools.filter( | |
| 16 | + } else { | |
| 17 | + const enabledTools = tools.filter( | |
| 17 | 18 | (tool) => |
| 18 | 19 | policies[tool.function.name] !== "disabled" && |
| 19 | 20 | groupPolicies[tool.group] !== "exclude", |
| 20 | 21 | ); |
| 21 | - } else { | |
| 22 | - return []; | |
| 22 | + if (mode === "plan") { | |
| 23 | + return enabledTools.filter( | |
| 24 | + (t) => t.group !== BUILT_IN_GROUP_NAME || t.readonly, | |
| 25 | + ); | |
| 26 | + } | |
| 27 | + return enabledTools; | |
| 23 | 28 | } |
| 24 | 29 | }, |
| 25 | 30 | ); |
modified gui/src/redux/thunks/edit.ts +35 −38
| @@ -75,52 +75,49 @@ | ||
| 75 | 75 | |
| 76 | 76 | export const exitEdit = createAsyncThunk< |
| 77 | 77 | void, |
| 78 | - { goToMode?: MessageModes; openNewSession?: boolean }, | |
| 78 | + { openNewSession?: boolean }, | |
| 79 | 79 | ThunkApiType |
| 80 | ->( | |
| 81 | - "edit/exit", | |
| 82 | - async ({ goToMode, openNewSession }, { dispatch, extra, getState }) => { | |
| 83 | - const state = getState(); | |
| 84 | - const codeToEdit = state.editModeState.codeToEdit; | |
| 85 | - const isInEdit = state.session.isInEdit; | |
| 86 | - const previousModeEditorContent = | |
| 87 | - state.editModeState.previousModeEditorContent; | |
| 80 | +>("edit/exit", async ({ openNewSession }, { dispatch, extra, getState }) => { | |
| 81 | + const state = getState(); | |
| 82 | + const codeToEdit = state.editModeState.codeToEdit; | |
| 83 | + const isInEdit = state.session.isInEdit; | |
| 84 | + const previousModeEditorContent = | |
| 85 | + state.editModeState.previousModeEditorContent; | |
| 88 | 86 | |
| 89 | - if (!isInEdit) { | |
| 90 | - return; | |
| 91 | - } | |
| 87 | + if (!isInEdit) { | |
| 88 | + return; | |
| 89 | + } | |
| 92 | 90 | |
| 93 | - if (codeToEdit[0] && state.editModeState.applyState.numDiffs) { | |
| 94 | - extra.ideMessenger.post("rejectDiff", { | |
| 95 | - filepath: codeToEdit[0].filepath, | |
| 96 | - }); | |
| 97 | - } | |
| 91 | + if (codeToEdit[0] && state.editModeState.applyState.numDiffs) { | |
| 92 | + extra.ideMessenger.post("rejectDiff", { | |
| 93 | + filepath: codeToEdit[0].filepath, | |
| 94 | + }); | |
| 95 | + } | |
| 98 | 96 | |
| 99 | - extra.ideMessenger.post("edit/clearDecorations", undefined); | |
| 97 | + extra.ideMessenger.post("edit/clearDecorations", undefined); | |
| 100 | 98 | |
| 101 | - dispatch(clearCodeToEdit()); | |
| 102 | - dispatch(updateEditStateApplyState(INITIAL_EDIT_APPLY_STATE)); | |
| 103 | - dispatch(setIsInEdit(false)); | |
| 99 | + dispatch(clearCodeToEdit()); | |
| 100 | + dispatch(updateEditStateApplyState(INITIAL_EDIT_APPLY_STATE)); | |
| 101 | + dispatch(setIsInEdit(false)); | |
| 104 | 102 | |
| 105 | - // Restore the previous editor content if available | |
| 106 | - if (previousModeEditorContent) { | |
| 107 | - dispatch(setMainEditorContentTrigger(previousModeEditorContent)); | |
| 108 | - dispatch(setPreviousModeEditorContent(undefined)); | |
| 109 | - } | |
| 103 | + // Restore the previous editor content if available | |
| 104 | + if (previousModeEditorContent) { | |
| 105 | + dispatch(setMainEditorContentTrigger(previousModeEditorContent)); | |
| 106 | + dispatch(setPreviousModeEditorContent(undefined)); | |
| 107 | + } | |
| 110 | 108 | |
| 111 | - if (openNewSession || state.editModeState.lastNonEditSessionWasEmpty) { | |
| 112 | - dispatch(newSession()); | |
| 113 | - } else { | |
| 114 | - await dispatch( | |
| 115 | - loadLastSession({ | |
| 116 | - saveCurrentSession: false, | |
| 117 | - }), | |
| 118 | - ); | |
| 119 | - } | |
| 109 | + if (openNewSession || state.editModeState.lastNonEditSessionWasEmpty) { | |
| 110 | + dispatch(newSession()); | |
| 111 | + } else { | |
| 112 | + await dispatch( | |
| 113 | + loadLastSession({ | |
| 114 | + saveCurrentSession: false, | |
| 115 | + }), | |
| 116 | + ); | |
| 117 | + } | |
| 120 | 118 | |
| 121 | - dispatch(setMode(goToMode ?? state.editModeState.returnToMode)); | |
| 122 | - }, | |
| 123 | -); | |
| 119 | + dispatch(setMode(state.editModeState.returnToMode)); | |
| 120 | +}); | |
| 124 | 121 | |
| 125 | 122 | export const enterEdit = createAsyncThunk< |
| 126 | 123 | void, |
modified gui/src/redux/thunks/streamNormalInput.ts +13 −15
| @@ -115,21 +115,19 @@ | ||
| 115 | 115 | dispatch(addPromptCompletionPair([next.value])); |
| 116 | 116 | |
| 117 | 117 | try { |
| 118 | - if (state.session.mode === "chat" || state.session.mode === "agent") { | |
| 119 | - extra.ideMessenger.post("devdata/log", { | |
| 120 | - name: "chatInteraction", | |
| 121 | - data: { | |
| 122 | - prompt: next.value.prompt, | |
| 123 | - completion: next.value.completion, | |
| 124 | - modelProvider: selectedChatModel.underlyingProviderName, | |
| 125 | - modelTitle: selectedChatModel.title, | |
| 126 | - sessionId: state.session.id, | |
| 127 | - ...(state.session.mode === "agent" && { | |
| 128 | - tools: activeTools.map((tool) => tool.function.name), | |
| 129 | - }), | |
| 130 | - }, | |
| 131 | - }); | |
| 132 | - } | |
| 118 | + extra.ideMessenger.post("devdata/log", { | |
| 119 | + name: "chatInteraction", | |
| 120 | + data: { | |
| 121 | + prompt: next.value.prompt, | |
| 122 | + completion: next.value.completion, | |
| 123 | + modelProvider: selectedChatModel.underlyingProviderName, | |
| 124 | + modelTitle: selectedChatModel.title, | |
| 125 | + sessionId: state.session.id, | |
| 126 | + ...(!!activeTools.length && { | |
| 127 | + tools: activeTools.map((tool) => tool.function.name), | |
| 128 | + }), | |
| 129 | + }, | |
| 130 | + }); | |
| 133 | 131 | // else if (state.session.mode === "edit") { |
| 134 | 132 | // extra.ideMessenger.post("devdata/log", { |
| 135 | 133 | // name: "editInteraction", |
modified gui/src/redux/thunks/streamThunkWrapper.tsx +1 −1
| @@ -17,7 +17,7 @@ | ||
| 17 | 17 | try { |
| 18 | 18 | await runStream(); |
| 19 | 19 | const state = getState(); |
| 20 | - if (state.session.mode === "chat" || state.session.mode === "agent") { | |
| 20 | + if (!state.session.isInEdit) { | |
| 21 | 21 | await dispatch( |
| 22 | 22 | saveCurrentSession({ |
| 23 | 23 | openNewSession: false, |
modified gui/src/redux/util/constructMessages.test.ts +13 −1
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | import { |
| 13 | 13 | DEFAULT_AGENT_SYSTEM_MESSAGE, |
| 14 | 14 | DEFAULT_CHAT_SYSTEM_MESSAGE, |
| 15 | + DEFAULT_PLAN_SYSTEM_MESSAGE, | |
| 15 | 16 | } from "core/llm/defaultSystemMessages"; |
| 16 | 17 | import { renderChatMessage } from "core/util/messageContent"; |
| 17 | 18 | import { beforeEach, describe, expect, test, vi } from "vitest"; |
| @@ -90,8 +91,9 @@ | ||
| 90 | 91 | |
| 91 | 92 | test("getBaseSystemMessage should return the correct system message based on mode", () => { |
| 92 | 93 | const mockModel = { |
| 93 | - baseAgentSystemMessage: "Custom Agent System Message", | |
| 94 | 94 | baseChatSystemMessage: "Custom Chat System Message", |
| 95 | + basePlanSystemMessage: "Custom Plan System Message", | |
| 96 | + baseAgentSystemMessage: "Custom Agent System Message", | |
| 95 | 97 | } as ModelDescription; |
| 96 | 98 | |
| 97 | 99 | // Test agent mode with custom message |
| @@ -99,6 +101,11 @@ | ||
| 99 | 101 | "Custom Agent System Message", |
| 100 | 102 | ); |
| 101 | 103 | |
| 104 | + // Test plan mode with custom message | |
| 105 | + expect(getBaseSystemMessage("plan", mockModel)).toBe( | |
| 106 | + "Custom Plan System Message", | |
| 107 | + ); | |
| 108 | + | |
| 102 | 109 | // Test chat mode with custom message |
| 103 | 110 | expect(getBaseSystemMessage("chat", mockModel)).toBe( |
| 104 | 111 | "Custom Chat System Message", |
| @@ -109,6 +116,11 @@ | ||
| 109 | 116 | DEFAULT_AGENT_SYSTEM_MESSAGE, |
| 110 | 117 | ); |
| 111 | 118 | |
| 119 | + // Test agent mode with default message | |
| 120 | + expect(getBaseSystemMessage("plan", {} as ModelDescription)).toBe( | |
| 121 | + DEFAULT_PLAN_SYSTEM_MESSAGE, | |
| 122 | + ); | |
| 123 | + | |
| 112 | 124 | // Test chat mode with default message |
| 113 | 125 | expect(getBaseSystemMessage("chat", {} as ModelDescription)).toBe( |
| 114 | 126 | DEFAULT_CHAT_SYSTEM_MESSAGE, |
modified gui/src/redux/util/constructMessages.ts +3 −0
| @@ -11,6 +11,7 @@ | ||
| 11 | 11 | import { |
| 12 | 12 | DEFAULT_AGENT_SYSTEM_MESSAGE, |
| 13 | 13 | DEFAULT_CHAT_SYSTEM_MESSAGE, |
| 14 | + DEFAULT_PLAN_SYSTEM_MESSAGE, | |
| 14 | 15 | } from "core/llm/defaultSystemMessages"; |
| 15 | 16 | import { chatMessageIsEmpty } from "core/llm/messages"; |
| 16 | 17 | import { getSystemMessageWithRules } from "core/llm/rules/getSystemMessageWithRules"; |
| @@ -167,6 +168,8 @@ | ||
| 167 | 168 | ): string { |
| 168 | 169 | if (messageMode === "agent") { |
| 169 | 170 | return model.baseAgentSystemMessage ?? DEFAULT_AGENT_SYSTEM_MESSAGE; |
| 171 | + } else if (messageMode === "plan") { | |
| 172 | + return model.basePlanSystemMessage ?? DEFAULT_PLAN_SYSTEM_MESSAGE; | |
| 170 | 173 | } else { |
| 171 | 174 | return model.baseChatSystemMessage ?? DEFAULT_CHAT_SYSTEM_MESSAGE; |
| 172 | 175 | } |
modified packages/config-yaml/src/schemas/models.ts +1 −0
| @@ -85,6 +85,7 @@ | ||
| 85 | 85 | export const chatOptionsSchema = z.object({ |
| 86 | 86 | baseSystemMessage: z.string().optional(), |
| 87 | 87 | baseAgentSystemMessage: z.string().optional(), |
| 88 | + basePlanSystemMessage: z.string().optional(), | |
| 88 | 89 | }); |
| 89 | 90 | export type ChatOptions = z.infer<typeof chatOptionsSchema>; |
| 90 | 91 |