Skip to content

Commit 49ee612

Browse files
committed
Allow adding extra agent invocations during agentic CLI execution
- while agentic search run, we show notification. it should have a button 'Add invocation' and should behave like having invocation count + 1 [Accuracy boost] - on the notification 'add invocation', use text: 'More agentic runs might increase search accuracy.' └── apps └── editor ├── package.json └── src ├── commands │ └── agentic-search-command │ ├── agentic-search-command.ts │ └── index.ts ├── features │ └── agentic-search │ ├── agentic-search-state.ts │ ├── agentic-search.ts │ ├── index.ts │ └── utils │ ├── build-agent-prompt.ts │ ├── index.ts │ └── prompt-for-search-term.ts ├── i18n │ ├── index.ts │ └── translations │ ├── features │ │ └── agentic-search.ts │ └── utils │ ├── agentic-cli-invocation.ts │ └── index.ts ├── utils │ └── agentic-cli-invocation │ ├── index.ts │ └── invoke-agentic-cli.ts └── views └── prompt └── backend └── message-handlers └── handle-agentic-search.ts
1 parent c94a69e commit 49ee612

3 files changed

Lines changed: 82 additions & 7 deletions

File tree

‎apps/editor/src/features/agentic-search/agentic-search.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const agentic_search = async (params: {
7474
default_agent_key: 'isDefaultForAgenticSearch',
7575
show_back_button: false,
7676
invocation_count,
77+
allow_adding_invocations: true,
7778
target_folder: params.folder_path,
7879
build_prompt: async () => {
7980
while (true) {

‎apps/editor/src/i18n/translations/utils/agentic-cli-invocation.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,42 @@ export const translations = {
197197
hu: 'várakozás az ügynökre...',
198198
bg: 'изчакване на агент...'
199199
},
200+
'utils.agentic-cli-invocation.agent.add-invocation-message': {
201+
en: 'More agentic runs might increase search accuracy.',
202+
pl: 'Więcej przebiegów agenta może zwiększyć dokładność wyszukiwania.',
203+
'zh-cn': '更多智能体运行可能会提高搜索准确性。',
204+
ja: 'エージェントの実行回数を増やすと、検索の精度が向上する可能性があります。',
205+
'zh-tw': '更多智能體運行可能會提高搜索準確性。',
206+
de: 'Mehr Agentenläufe könnten die Suchgenauigkeit erhöhen.',
207+
es: 'Más ejecuciones de agentes podrían aumentar la precisión de búsqueda.',
208+
fr: "Plus d'exécutions d'agents pourraient augmenter la précision de la recherche.",
209+
'pt-br': 'Mais execuções de agentes podem aumentar a precisão da pesquisa.',
210+
ru: 'Дополнительные запуски агента могут повысить точность поиска.',
211+
ko: '더 많은 에이전트 실행이 검색 정확도를 높일 수 있습니다.',
212+
it: 'Più esecuzioni di agenti potrebbero aumentare la precisione della ricerca.',
213+
tr: 'Daha fazla aracı çalıştırması arama doğruluğunu artırabilir.',
214+
cs: 'Více běhů agentů může zvýšit přesnost vyhledávání.',
215+
hu: 'Több ügynöki futtatás növelheti a keresés pontosságát.',
216+
bg: 'Повече изпълнения на агенти може да увеличат точността на търсенето.'
217+
},
218+
'utils.agentic-cli-invocation.agent.add-invocation': {
219+
en: 'Add invocation',
220+
pl: 'Dodaj wywołanie',
221+
'zh-cn': '添加调用',
222+
ja: '呼び出しを追加',
223+
'zh-tw': '新增呼叫',
224+
de: 'Aufruf hinzufügen',
225+
es: 'Añadir invocación',
226+
fr: 'Ajouter une invocation',
227+
'pt-br': 'Adicionar invocação',
228+
ru: 'Добавить вызов',
229+
ko: '호출 추가',
230+
it: 'Aggiungi invocazione',
231+
tr: 'Çağrı ekle',
232+
cs: 'Přidat vyvolání',
233+
hu: 'Hívás hozzáadása',
234+
bg: 'Добавяне на извикване'
235+
},
200236
'utils.agentic-cli-invocation.error.not-installed': {
201237
en: 'The {agent} CLI is not installed on this computer.',
202238
pl: 'CLI {agent} nie jest zainstalowane na tym komputerze.',

‎apps/editor/src/utils/agentic-cli-invocation/invoke-agentic-cli.ts‎

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const invoke_agentic_cli = async (params: {
4242
use_quick_pick?: boolean
4343
default_agent_key?: keyof ConfigAgentConfigurationFormat
4444
invocation_count?: number
45+
allow_adding_invocations?: boolean
4546
target_folder?: string
4647
}): Promise<
4748
| {
@@ -627,16 +628,17 @@ export const invoke_agentic_cli = async (params: {
627628
}
628629
}
629630

630-
const invocation_count = params.invocation_count || 1
631+
const initial_invocation_count = params.invocation_count || 1
632+
let total_invocations = 0
633+
let is_finished = false
631634
let cancelled_count = 0
632635
const agent_outputs: string[] = []
633636

634637
output_channel.clear()
635638
const start_time = Date.now()
636639

637640
try {
638-
await Promise.all(
639-
Array.from({ length: invocation_count }).map(async (_, index) => {
641+
const run_invocation = async (index: number) => {
640642
return vscode.window.withProgress(
641643
{
642644
location: vscode.ProgressLocation.Notification,
@@ -756,7 +758,7 @@ export const invoke_agentic_cli = async (params: {
756758
if (
757759
params.generate_diff_for_temp_dir &&
758760
temp_dir_path &&
759-
invocation_count === 1
761+
total_invocations === 1
760762
) {
761763
try {
762764
const diff_markdown = await generate_diff_markdown(
@@ -801,8 +803,43 @@ export const invoke_agentic_cli = async (params: {
801803
})
802804
}
803805
)
804-
})
805-
)
806+
}
807+
808+
const tasks: Promise<void>[] = []
809+
const start_invocation = () => {
810+
const index = tasks.length
811+
total_invocations++
812+
tasks.push(run_invocation(index))
813+
}
814+
815+
const show_add_invocation_button = () => {
816+
const label = t('utils.agentic-cli-invocation.agent.add-invocation')
817+
vscode.window
818+
.showInformationMessage(
819+
t('utils.agentic-cli-invocation.agent.add-invocation-message'),
820+
label
821+
)
822+
.then((selection) => {
823+
if (selection !== label || is_finished) return
824+
start_invocation()
825+
show_add_invocation_button()
826+
})
827+
}
828+
829+
for (let i = 0; i < initial_invocation_count; i++) {
830+
start_invocation()
831+
}
832+
833+
if (params.allow_adding_invocations) {
834+
show_add_invocation_button()
835+
}
836+
837+
let awaited_count = 0
838+
while (awaited_count < tasks.length) {
839+
const batch = tasks.slice(awaited_count)
840+
awaited_count = tasks.length
841+
await Promise.all(batch)
842+
}
806843
} catch (err) {
807844
vscode.window.showErrorMessage(
808845
t('utils.agentic-cli-invocation.error.failed', {
@@ -812,12 +849,13 @@ export const invoke_agentic_cli = async (params: {
812849
go_back_to_caller = true
813850
break
814851
} finally {
852+
is_finished = true
815853
await fs.promises
816854
.rm(temp_prompt_dir, { recursive: true, force: true })
817855
.catch(() => {})
818856
}
819857

820-
if (cancelled_count === invocation_count) {
858+
if (cancelled_count === total_invocations) {
821859
go_back_to_caller = true
822860
break
823861
}

0 commit comments

Comments
 (0)