Elffuss BraidHub

kikocis/continue public

Merge pull request #6445 from continuedev/dallin/plan-mode

Plan Mode
Changesetd717cb1b1923a244dfdd5b6b17d84332a114e702d014178f27855bedb99b5dc8
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-07-07 13:05 -07:00
CommitterGitHub <noreply@github.com> · 2025-07-07 13:05 -07:00
Parentsf77b04d88949, 0a8d03b3c064

Browse the files at this changeset

21 files changed

modified core/config/load.ts +1 −0
@@ -643,6 +643,7 @@
643643 template: llm.template,
644644 completionOptions: llm.completionOptions,
645645 baseAgentSystemMessage: llm.baseAgentSystemMessage,
646+ basePlanSystemMessage: llm.basePlanSystemMessage,
646647 baseChatSystemMessage: llm.baseChatSystemMessage,
647648 requestOptions: llm.requestOptions,
648649 promptTemplates: serializePromptTemplates(llm.promptTemplates),
modified core/config/yaml/models.ts +1 −0
@@ -63,6 +63,7 @@
6363 template: model.promptTemplates?.chat,
6464 promptTemplates: model.promptTemplates,
6565 baseAgentSystemMessage: model.chatOptions?.baseAgentSystemMessage,
66+ basePlanSystemMessage: model.chatOptions?.basePlanSystemMessage,
6667 baseChatSystemMessage: model.chatOptions?.baseSystemMessage,
6768 capabilities: {
6869 tools: model.capabilities?.includes("tool_use"),
modified core/index.d.ts +7 −3
@@ -428,7 +428,7 @@
428428 completion: string;
429429 }
430430
431-export type MessageModes = "chat" | "agent";
431+export type MessageModes = "chat" | "agent" | "plan";
432432
433433 export type ToolStatus =
434434 | "generating"
@@ -568,6 +568,7 @@
568568 title?: string;
569569 uniqueId?: string;
570570 baseAgentSystemMessage?: string;
571+ basePlanSystemMessage?: string;
571572 baseChatSystemMessage?: string;
572573 autocompleteOptions?: Partial<TabAutocompleteOptions>;
573574 contextLength?: number;
@@ -1091,6 +1092,7 @@
10911092 template?: TemplateType;
10921093 completionOptions?: BaseCompletionOptions;
10931094 baseAgentSystemMessage?: string;
1095+ basePlanSystemMessage?: string;
10941096 baseChatSystemMessage?: string;
10951097 requestOptions?: RequestOptions;
10961098 promptTemplates?: { [key: string]: string };
@@ -1637,9 +1639,11 @@
16371639
16381640 export type RuleSource =
16391641 | "default-chat"
1642+ | "default-plan"
16401643 | "default-agent"
1641- | "model-chat-options"
1642- | "model-agent-options"
1644+ | "model-options-chat"
1645+ | "model-options-plan"
1646+ | "model-options-agent"
16431647 | "rules-block"
16441648 | "json-systemMessage"
16451649 | ".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 =
52 "https://github.com/continuedev/continue/blob/main/core/llm/defaultSystemMessages.ts";
63
74 export const CODEBLOCK_FORMATTING_INSTRUCTIONS = `\
@@ -66,3 +63,17 @@
6663
6764 ${CODEBLOCK_FORMATTING_INSTRUCTIONS}
6865 </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 @@
141141
142142 title?: string;
143143 baseChatSystemMessage?: string;
144+ basePlanSystemMessage?: string;
144145 baseAgentSystemMessage?: string;
145146 contextLength: number;
146147 maxStopWords?: number | undefined;
@@ -209,6 +210,7 @@
209210 this.title = options.title;
210211 this.uniqueId = options.uniqueId ?? "None";
211212 this.baseAgentSystemMessage = options.baseAgentSystemMessage;
213+ this.basePlanSystemMessage = options.basePlanSystemMessage;
212214 this.baseChatSystemMessage = options.baseChatSystemMessage;
213215 this.contextLength =
214216 options.contextLength ?? llmInfo?.contextLength ?? DEFAULT_CONTEXT_LENGTH;
modified core/llm/llms/index.ts +4 −4
@@ -8,7 +8,6 @@
88 LLMOptions,
99 } from "../..";
1010 import { renderTemplatedString } from "../../util/handlebars/renderTemplatedString";
11-import { DEFAULT_CHAT_SYSTEM_MESSAGE } from "../defaultSystemMessages";
1211 import { BaseLLM } from "../index";
1312 import Anthropic from "./Anthropic";
1413 import Asksage from "./Asksage";
@@ -141,9 +140,9 @@
141140
142141 let baseChatSystemMessage: string | undefined = undefined;
143142 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(
147146 Handlebars,
148147 desc.systemMessage,
149148 {},
@@ -163,6 +162,7 @@
163162 cls.defaultOptions?.completionOptions?.maxTokens,
164163 },
165164 baseChatSystemMessage,
165+ basePlanSystemMessage: baseChatSystemMessage,
166166 baseAgentSystemMessage: baseChatSystemMessage,
167167 logger: llmLogger,
168168 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";
26 import { MessageModes } from "core";
37
48 interface ModeIconProps {
@@ -13,6 +17,8 @@
1317 switch (mode) {
1418 case "agent":
1519 return <SparklesIcon className={className} />;
20+ case "plan":
21+ return <SwatchIcon className={className} />;
1622 case "chat":
1723 return <ChatBubbleLeftIcon className={className} />;
1824 }
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";
26 import { MessageModes } from "core";
37 import { modelSupportsTools } from "core/llm/autodetect";
48 import { useCallback, useEffect, useMemo } from "react";
@@ -6,6 +10,7 @@
610 import { selectSelectedChatModel } from "../../redux/slices/configSlice";
711 import { setMode } from "../../redux/slices/sessionSlice";
812 import { getFontSize, getMetaKeyLabel } from "../../util";
13+import { ToolTip } from "../gui/Tooltip";
914 import { useMainEditor } from "../mainInput/TipTapEditor";
1015 import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../ui";
1116 import { ModeIcon } from "./ModeIcon";
@@ -27,13 +32,19 @@
2732 if (!selectedModel) {
2833 return;
2934 }
30- if (mode === "agent" && !agentModeSupported) {
35+ if (mode !== "chat" && !agentModeSupported) {
3136 dispatch(setMode("chat"));
3237 }
3338 }, [mode, agentModeSupported, dispatch, selectedModel]);
3439
3540 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+ }
3748 // Only focus main editor if another one doesn't already have focus
3849 if (!document.activeElement?.classList?.contains("ProseMirror")) {
3950 mainEditor?.commands.focus();
@@ -74,7 +85,7 @@
7485 >
7586 <ModeIcon mode={mode} />
7687 <span className="hidden sm:block">
77- {mode.charAt(0).toUpperCase() + mode.slice(1)}
88+ {mode === "chat" ? "Chat" : mode === "agent" ? "Agent" : "Plan"}
7889 </span>
7990 <ChevronDownIcon
8091 className="h-2 w-2 flex-shrink-0"
@@ -94,7 +105,35 @@
94105 </div>
95106 {mode === "chat" && <CheckIcon className="ml-auto h-3 w-3" />}
96107 </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>
98137 <ListboxOption
99138 value="agent"
100139 disabled={!agentModeSupported}
@@ -103,9 +142,23 @@
103142 <div className="flex flex-row items-center gap-1.5">
104143 <ModeIcon mode="agent" />
105144 <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>
106157 </div>
107158 {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+ />
109162 ) : (
110163 <span>(Not supported)</span>
111164 )}
modified gui/src/components/gui/Switch.tsx +6 −2
@@ -7,6 +7,7 @@
77 text: string;
88 size?: number;
99 showIfToggled?: ReactNode;
10+ disabled?: boolean;
1011 };
1112
1213 const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
@@ -15,15 +16,18 @@
1516 text,
1617 size = 16,
1718 showIfToggled,
19+ disabled = false,
1820 }) => {
1921 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+ >
2125 <span className="truncate-right">{text}</span>
2226 <div className="flex flex-row items-center gap-1">
2327 {isToggled && !!showIfToggled && showIfToggled}
2428 <div
2529 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}
2731 style={{
2832 height: size,
2933 width: size * 2,
modified gui/src/components/mainInput/Lump/sections/RulesSection.tsx +32 −15
@@ -7,9 +7,8 @@
77 import { RuleWithSource } from "core";
88 import {
99 DEFAULT_AGENT_SYSTEM_MESSAGE,
10- DEFAULT_AGENT_SYSTEM_MESSAGE_URL,
1110 DEFAULT_CHAT_SYSTEM_MESSAGE,
12- DEFAULT_CHAT_SYSTEM_MESSAGE_URL,
11+ DEFAULT_SYSTEM_MESSAGES_URL,
1312 } from "core/llm/defaultSystemMessages";
1413 import { useContext, useMemo } from "react";
1514 import { useAuth } from "../../../../context/Auth";
@@ -52,10 +51,12 @@
5251 ideMessenger.post("openFile", {
5352 path: rule.ruleFile,
5453 });
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);
5960 } else {
6061 ideMessenger.post("config/openProfile", {
6162 profileId: undefined,
@@ -81,9 +82,11 @@
8182 return "Default agent system message";
8283 } else if (rule.source === "json-systemMessage") {
8384 return "JSON systemMessage)";
84- } else if (rule.source === "model-agent-options") {
85+ } else if (rule.source === "model-options-agent") {
8586 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") {
8790 return "Base System Chat Message";
8891 } else {
8992 return "Assistant rule";
@@ -215,11 +218,24 @@
215218 }
216219 }
217220
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
219235 if (config.selectedModelByRole.chat?.baseAgentSystemMessage) {
220236 rules.unshift({
221237 rule: config.selectedModelByRole.chat?.baseAgentSystemMessage,
222- source: "model-agent-options",
238+ source: "model-options-agent",
223239 });
224240 } else {
225241 rules.unshift({
@@ -228,15 +244,16 @@
228244 });
229245 }
230246 } else {
231- if (config.selectedModelByRole.chat?.baseChatSystemMessage) {
247+ // plan
248+ if (config.selectedModelByRole.chat?.basePlanSystemMessage) {
232249 rules.unshift({
233- rule: config.selectedModelByRole.chat?.baseChatSystemMessage,
234- source: "model-chat-options",
250+ rule: config.selectedModelByRole.chat?.basePlanSystemMessage,
251+ source: "model-options-plan",
235252 });
236253 } else {
237254 rules.unshift({
238- rule: DEFAULT_CHAT_SYSTEM_MESSAGE,
239- source: "default-chat",
255+ rule: DEFAULT_AGENT_SYSTEM_MESSAGE,
256+ source: "default-agent",
240257 });
241258 }
242259 }
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";
12 import { Tool } from "core";
23 import { useMemo } from "react";
34 import { useAppDispatch, useAppSelector } from "../../../../../redux/hooks";
@@ -6,7 +7,26 @@
67 import ToggleSwitch from "../../../../gui/Switch";
78 import ToolPolicyItem from "./ToolPolicyItem";
89
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+
928 export const ToolPoliciesSection = () => {
29+ const mode = useAppSelector((state) => state.session.mode);
1030 const availableTools = useAppSelector((state) => state.config.config.tools);
1131 const toolGroupSettings = useAppSelector(
1232 (store) => store.ui.toolGroupSettings,
@@ -39,38 +59,56 @@
3959 );
4060 }, [availableTools]);
4161
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+
4271 return (
4372 <>
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}
6997 />
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>
71109 </div>
72- </div>
73- ))}
110+ );
111+ })}
74112 </>
75113 );
76114 };
modified gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx +21 −8
@@ -3,6 +3,7 @@
33 InformationCircleIcon,
44 } from "@heroicons/react/24/outline";
55 import { Tool } from "core";
6+import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn";
67 import { useEffect, useMemo, useState } from "react";
78 import { useDispatch } from "react-redux";
89 import { useAppSelector } from "../../../../../redux/hooks";
@@ -16,7 +17,7 @@
1617 interface ToolDropdownItemProps {
1718 tool: Tool;
1819 duplicatesDetected: boolean;
19- excluded: boolean;
20+ isGroupEnabled: boolean;
2021 }
2122
2223 function ToolPolicyItem(props: ToolDropdownItemProps) {
@@ -25,6 +26,7 @@
2526 (state) => state.ui.toolSettings[props.tool.function.name],
2627 );
2728 const [isExpanded, setIsExpanded] = useState(false);
29+ const mode = useAppSelector((state) => state.session.mode);
2830
2931 useEffect(() => {
3032 if (!policy) {
@@ -44,6 +46,12 @@
4446
4547 const fontSize = useFontSize(-2);
4648
49+ const disabled =
50+ !props.isGroupEnabled ||
51+ (mode === "plan" &&
52+ props.tool.group === BUILT_IN_GROUP_NAME &&
53+ !props.tool.readonly);
54+
4755 if (!policy) {
4856 return null;
4957 }
@@ -106,16 +114,21 @@
106114 </span>
107115 </div>
108116 </div>
117+
109118 <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"}`}
111120 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+ }
117130 >
118- {props.excluded || policy === "disabled" ? (
131+ {disabled || policy === "disabled" ? (
119132 <>
120133 <span className="text-lightgray sm:hidden">Off</span>
121134 <span className="text-lightgray hidden sm:inline-block">
modified gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +4 −2
@@ -19,9 +19,11 @@
1919 return "Default Chat";
2020 case "default-agent":
2121 return "Default Agent";
22- case "model-chat-options":
22+ case "model-options-chat":
2323 return "Model Chat Options";
24- case "model-agent-options":
24+ case "model-options-plan":
25+ return "Model Plan Options";
26+ case "model-options-agent":
2527 return "Model Agent Options";
2628 case "rules-block":
2729 return "Rules Block";
modified gui/src/pages/gui/chat-tests/Chat.test.tsx +12 −0
@@ -27,6 +27,18 @@
2727 );
2828 });
2929
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+
3042 // Check that it switched to Agent mode
3143 await getElementByText("Agent");
3244
modified gui/src/redux/selectors/selectActiveTools.ts +9 −4
@@ -1,5 +1,6 @@
11 import { createSelector } from "@reduxjs/toolkit";
22 import { Tool } from "core";
3+import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn";
34 import { RootState } from "../store";
45
56 export const selectActiveTools = createSelector(
@@ -12,14 +13,18 @@
1213 (mode, tools, policies, groupPolicies): Tool[] => {
1314 if (mode === "chat") {
1415 return [];
15- } else if (mode === "agent") {
16- return tools.filter(
16+ } else {
17+ const enabledTools = tools.filter(
1718 (tool) =>
1819 policies[tool.function.name] !== "disabled" &&
1920 groupPolicies[tool.group] !== "exclude",
2021 );
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;
2328 }
2429 },
2530 );
modified gui/src/redux/thunks/edit.ts +35 −38
@@ -75,52 +75,49 @@
7575
7676 export const exitEdit = createAsyncThunk<
7777 void,
78- { goToMode?: MessageModes; openNewSession?: boolean },
78+ { openNewSession?: boolean },
7979 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;
8886
89- if (!isInEdit) {
90- return;
91- }
87+ if (!isInEdit) {
88+ return;
89+ }
9290
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+ }
9896
99- extra.ideMessenger.post("edit/clearDecorations", undefined);
97+ extra.ideMessenger.post("edit/clearDecorations", undefined);
10098
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));
104102
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+ }
110108
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+ }
120118
121- dispatch(setMode(goToMode ?? state.editModeState.returnToMode));
122- },
123-);
119+ dispatch(setMode(state.editModeState.returnToMode));
120+});
124121
125122 export const enterEdit = createAsyncThunk<
126123 void,
modified gui/src/redux/thunks/streamNormalInput.ts +13 −15
@@ -115,21 +115,19 @@
115115 dispatch(addPromptCompletionPair([next.value]));
116116
117117 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+ });
133131 // else if (state.session.mode === "edit") {
134132 // extra.ideMessenger.post("devdata/log", {
135133 // name: "editInteraction",
modified gui/src/redux/thunks/streamThunkWrapper.tsx +1 −1
@@ -17,7 +17,7 @@
1717 try {
1818 await runStream();
1919 const state = getState();
20- if (state.session.mode === "chat" || state.session.mode === "agent") {
20+ if (!state.session.isInEdit) {
2121 await dispatch(
2222 saveCurrentSession({
2323 openNewSession: false,
modified gui/src/redux/util/constructMessages.test.ts +13 −1
@@ -12,6 +12,7 @@
1212 import {
1313 DEFAULT_AGENT_SYSTEM_MESSAGE,
1414 DEFAULT_CHAT_SYSTEM_MESSAGE,
15+ DEFAULT_PLAN_SYSTEM_MESSAGE,
1516 } from "core/llm/defaultSystemMessages";
1617 import { renderChatMessage } from "core/util/messageContent";
1718 import { beforeEach, describe, expect, test, vi } from "vitest";
@@ -90,8 +91,9 @@
9091
9192 test("getBaseSystemMessage should return the correct system message based on mode", () => {
9293 const mockModel = {
93- baseAgentSystemMessage: "Custom Agent System Message",
9494 baseChatSystemMessage: "Custom Chat System Message",
95+ basePlanSystemMessage: "Custom Plan System Message",
96+ baseAgentSystemMessage: "Custom Agent System Message",
9597 } as ModelDescription;
9698
9799 // Test agent mode with custom message
@@ -99,6 +101,11 @@
99101 "Custom Agent System Message",
100102 );
101103
104+ // Test plan mode with custom message
105+ expect(getBaseSystemMessage("plan", mockModel)).toBe(
106+ "Custom Plan System Message",
107+ );
108+
102109 // Test chat mode with custom message
103110 expect(getBaseSystemMessage("chat", mockModel)).toBe(
104111 "Custom Chat System Message",
@@ -109,6 +116,11 @@
109116 DEFAULT_AGENT_SYSTEM_MESSAGE,
110117 );
111118
119+ // Test agent mode with default message
120+ expect(getBaseSystemMessage("plan", {} as ModelDescription)).toBe(
121+ DEFAULT_PLAN_SYSTEM_MESSAGE,
122+ );
123+
112124 // Test chat mode with default message
113125 expect(getBaseSystemMessage("chat", {} as ModelDescription)).toBe(
114126 DEFAULT_CHAT_SYSTEM_MESSAGE,
modified gui/src/redux/util/constructMessages.ts +3 −0
@@ -11,6 +11,7 @@
1111 import {
1212 DEFAULT_AGENT_SYSTEM_MESSAGE,
1313 DEFAULT_CHAT_SYSTEM_MESSAGE,
14+ DEFAULT_PLAN_SYSTEM_MESSAGE,
1415 } from "core/llm/defaultSystemMessages";
1516 import { chatMessageIsEmpty } from "core/llm/messages";
1617 import { getSystemMessageWithRules } from "core/llm/rules/getSystemMessageWithRules";
@@ -167,6 +168,8 @@
167168 ): string {
168169 if (messageMode === "agent") {
169170 return model.baseAgentSystemMessage ?? DEFAULT_AGENT_SYSTEM_MESSAGE;
171+ } else if (messageMode === "plan") {
172+ return model.basePlanSystemMessage ?? DEFAULT_PLAN_SYSTEM_MESSAGE;
170173 } else {
171174 return model.baseChatSystemMessage ?? DEFAULT_CHAT_SYSTEM_MESSAGE;
172175 }
modified packages/config-yaml/src/schemas/models.ts +1 −0
@@ -85,6 +85,7 @@
8585 export const chatOptionsSchema = z.object({
8686 baseSystemMessage: z.string().optional(),
8787 baseAgentSystemMessage: z.string().optional(),
88+ basePlanSystemMessage: z.string().optional(),
8889 });
8990 export type ChatOptions = z.infer<typeof chatOptionsSchema>;
9091