Elffuss BraidHub

kikocis/continue public

add isInAgentMode in retreival pipeline
Changeset7ecdd34674859875b7aad4a833add4187af8da55cda025adc9994d57cf6c087d
Authoruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-07-01 13:11 +05:30
Committeruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-07-01 13:11 +05:30
Parents58de0f436bd6

Browse the files at this changeset

9 files changed

modified core/context/retrieval/retrieval.ts +9 −6
@@ -85,12 +85,15 @@
8585 );
8686 return [];
8787 }
88- return [
89- {
90- ...INSTRUCTIONS_BASE_ITEM,
91- content: "No results were found. Try using other tools.",
92- },
93- ];
88+ if (extras.isInAgentMode) {
89+ return [
90+ {
91+ ...INSTRUCTIONS_BASE_ITEM,
92+ content: "No results were found. Try using other tools.",
93+ },
94+ ];
95+ }
96+ return [];
9497 }
9598
9699 return [
modified core/core.ts +2 −0
@@ -1021,6 +1021,7 @@
10211021 query: string;
10221022 fullInput: string;
10231023 selectedCode: RangeInFile[];
1024+ isInAgentMode: boolean;
10241025 }>,
10251026 ) => {
10261027 const { config } = await this.configHandler.loadConfig();
@@ -1068,6 +1069,7 @@
10681069 reranker: config.selectedModelByRole.rerank,
10691070 fetch: (url, init) =>
10701071 fetchwithRequestOptions(url, init, config.requestOptions),
1072+ isInAgentMode: msg.data.isInAgentMode,
10711073 });
10721074
10731075 void Telemetry.capture(
modified core/index.d.ts +1 −0
@@ -186,6 +186,7 @@
186186 ide: IDE;
187187 selectedCode: RangeInFile[];
188188 fetch: FetchFunction;
189+ isInAgentMode: boolean;
189190 }
190191
191192 export interface LoadSubmenuItemsArgs {
modified core/protocol/core.ts +1 −0
@@ -109,6 +109,7 @@
109109 query: string;
110110 fullInput: string;
111111 selectedCode: RangeInFile[];
112+ isInAgentMode: boolean;
112113 },
113114 ContextItemWithId[],
114115 ];
modified gui/src/components/mainInput/AtMentionDropdown/index.tsx +5 −0
@@ -25,6 +25,7 @@
2525 vscQuickInputBackground,
2626 } from "../..";
2727 import { IdeMessengerContext } from "../../../context/IdeMessenger";
28+import { useAppSelector } from "../../../redux/hooks";
2829 import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
2930 import { fontSize } from "../../../util";
3031 import FileIcon from "../../FileIcon";
@@ -159,6 +160,9 @@
159160 const dispatch = useDispatch();
160161
161162 const ideMessenger = useContext(IdeMessengerContext);
163+ const isInAgentMode = useAppSelector(
164+ (store) => store.session.mode === "agent",
165+ );
162166
163167 const [selectedIndex, setSelectedIndex] = useState(0);
164168
@@ -187,6 +191,7 @@
187191 query,
188192 fullInput: "",
189193 selectedCode,
194+ isInAgentMode,
190195 },
191196 );
192197
modified gui/src/components/mainInput/TipTapEditor/utils/renderPromptv1.ts +1 −0
@@ -26,6 +26,7 @@
2626 name,
2727 query: "",
2828 selectedCode,
29+ isInAgentMode: false,
2930 });
3031 if (response.status === "success") {
3132 return response.content.map((item) => item.content).join("\n\n");
modified gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts +11 −0
@@ -12,6 +12,7 @@
1212 import { stripImages } from "core/util/messageContent";
1313 import { IIdeMessenger } from "../../../../context/IdeMessenger";
1414 import { setIsGatheringContext } from "../../../../redux/slices/sessionSlice";
15+import { RootState } from "../../../../redux/store";
1516 import { processEditorContent } from "./processEditorContent";
1617 import { renderSlashCommandPrompt } from "./renderSlashCommand";
1718 import { GetContextRequest } from "./types";
@@ -23,6 +24,7 @@
2324 defaultContextProviders: DefaultContextProvider[];
2425 availableSlashCommands: SlashCommandDescWithSource[];
2526 dispatch: Dispatch;
27+ getState: () => RootState;
2628 }
2729
2830 interface ResolveEditorContentOutput {
@@ -48,6 +50,7 @@
4850 defaultContextProviders,
4951 availableSlashCommands,
5052 dispatch,
53+ getState,
5154 }: ResolveEditorContentInput): Promise<ResolveEditorContentOutput> {
5255 const {
5356 parts,
@@ -87,6 +90,7 @@
8790 defaultContextProviders,
8891 parts: slashedParts,
8992 selectedCode,
93+ getState,
9094 });
9195
9296 if (shouldGatherContext) {
@@ -111,6 +115,7 @@
111115 defaultContextProviders,
112116 parts,
113117 selectedCode,
118+ getState,
114119 }: {
115120 contextRequests: GetContextRequest[];
116121 modifiers: InputModifiers;
@@ -118,6 +123,7 @@
118123 defaultContextProviders: DefaultContextProvider[];
119124 parts: MessagePart[];
120125 selectedCode: RangeInFile[];
126+ getState: () => RootState;
121127 }): Promise<ContextItemWithId[]> {
122128 const defaultRequests: GetContextRequest[] = defaultContextProviders.map(
123129 (def) => ({
@@ -139,6 +145,8 @@
139145 );
140146 let contextItems: ContextItemWithId[] = [];
141147
148+ const isInAgentMode = getState().session.mode === "agent";
149+
142150 // Process context item attributes
143151 for (const item of deduplicatedInputs) {
144152 const result = await ideMessenger.request("context/getContextItems", {
@@ -146,6 +154,7 @@
146154 query: item.query ?? "",
147155 fullInput: stripImages(parts),
148156 selectedCode,
157+ isInAgentMode,
149158 });
150159 if (result.status === "success") {
151160 contextItems.push(...result.content);
@@ -162,6 +171,7 @@
162171 query: "",
163172 fullInput: stripImages(parts),
164173 selectedCode,
174+ isInAgentMode,
165175 });
166176
167177 if (result.status === "success") {
@@ -181,6 +191,7 @@
181191 query: "non-mention-usage",
182192 fullInput: "",
183193 selectedCode: [],
194+ isInAgentMode,
184195 },
185196 );
186197 if (currentFileResponse.status === "success") {
modified gui/src/redux/thunks/edit.ts +3 −1
@@ -35,10 +35,11 @@
3535 ThunkApiType
3636 >(
3737 "edit/streamResponse",
38- async ({ editorState, codeToEdit }, { dispatch, extra }) => {
38+ async ({ editorState, codeToEdit }, { dispatch, extra, getState }) => {
3939 await dispatch(
4040 streamThunkWrapper(async () => {
4141 dispatch(setActive());
42+
4243 const { selectedContextItems, content } = await resolveEditorContent({
4344 editorState,
4445 modifiers: {
@@ -49,6 +50,7 @@
4950 defaultContextProviders: [],
5051 availableSlashCommands: [],
5152 dispatch,
53+ getState,
5254 });
5355
5456 const prompt = [
modified gui/src/redux/thunks/streamResponse.ts +2 −1
@@ -68,6 +68,7 @@
6868 defaultContextProviders,
6969 availableSlashCommands: state.config.config.slashCommands,
7070 dispatch,
71+ getState,
7172 });
7273
7374 // symbols for both context items AND selected codeblocks
@@ -77,7 +78,7 @@
7778 .map((item) => item.uri!.value),
7879 ...selectedCode.map((rif) => rif.filepath),
7980 ];
80- dispatch(updateFileSymbolsFromFiles(filesForSymbols));
81+ void dispatch(updateFileSymbolsFromFiles(filesForSymbols));
8182
8283 dispatch(
8384 updateHistoryItemAtIndex({