Release: v2.36.1 - Action Queue Optimization

This commit is contained in:
g1nation
2026-05-02 16:34:45 +09:00
parent f874ae6152
commit 04e81c3abf
5 changed files with 35 additions and 101 deletions
-100
View File
@@ -234,21 +234,6 @@ export class AgentExecutor {
await this.context.workspaceState.update('lastActionStr', undefined);
}
if (prompt !== null && loopDepth === 0 && !hasVisionContent) {
const localReply = await this.tryHandleLocalTask(prompt);
if (this.isStaleRun(runId)) return;
if (localReply) {
this.chatHistory.push({ role: 'user', content: prompt });
this.emitHistoryChanged();
this.webview.postMessage({ type: 'streamStart' });
this.webview.postMessage({ type: 'streamChunk', value: localReply });
this.webview.postMessage({ type: 'streamEnd' });
this.chatHistory.push({ role: 'assistant', content: localReply });
this.emitHistoryChanged();
return;
}
}
// 1. Prepare Context
const workspaceFolders = vscode.workspace.workspaceFolders;
const rootPath = workspaceFolders ? workspaceFolders[0].uri.fsPath : '';
@@ -449,15 +434,6 @@ export class AgentExecutor {
return;
}
if (report.length === 0 && loopDepth === 0 && this.isUnproductiveWaitingReply(assistantContent)) {
assistantMessage.internal = false;
const correctedReply = await this.buildUnproductiveReplyCorrection(prompt || '');
assistantMessage.content = traceMarkdown ? `${correctedReply}\n${traceMarkdown}` : correctedReply;
this.emitHistoryChanged();
this.webview.postMessage({ type: 'streamChunk', value: assistantMessage.content });
return;
}
if (report.length > 0) {
this.emitHistoryChanged();
logInfo('Agent actions executed.', { loopDepth: loopDepth + 1, report });
@@ -506,17 +482,6 @@ export class AgentExecutor {
}
}
private async tryHandleLocalTask(prompt: string): Promise<string | null> {
const normalized = prompt.trim().toLowerCase();
if (!normalized) return null;
if (this.isBrainOverviewRequest(normalized)) {
return this.buildBrainOverviewReply();
}
return null;
}
public async executeMultiAgentWorkflow(
prompt: string,
modelName: string,
@@ -627,75 +592,10 @@ export class AgentExecutor {
return responseText;
}
private isUnproductiveWaitingReply(reply: string): boolean {
const normalized = reply.replace(/\s+/g, ' ').trim();
return /(준비되었습니다|다음 지시|말씀해 주세요|명령을 기다|작업을 도와드릴까요)/.test(normalized)
&& !/<(list_files|read_file|list_brain|read_brain|run_command|edit_file|create_file)/i.test(reply);
}
private async buildUnproductiveReplyCorrection(prompt: string): Promise<string> {
return '방금 답변은 잘못된 응답입니다. 사용자의 말은 “다음 지시를 달라”가 아니라 지금 바로 처리해야 하는 작업 지시입니다. 제가 먼저 관련 자료를 확인하고, 확인한 내용 기준으로 답변하겠습니다. 가능하면 프로젝트명 대신 정확한 폴더 경로를 함께 주시면 더 안정적으로 분석할 수 있습니다.';
}
private isBrainOverviewRequest(normalized: string): boolean {
const mentionsBrain = /(제2뇌|second brain|local brain|브레인|brain)/.test(normalized);
const asksOverview = /(어떠|뭐가|무엇|내용|정보|구성|준비|분석|정리|파악)/.test(normalized);
return mentionsBrain && asksOverview;
}
private isExplicitSecondBrainRequest(prompt: string): boolean {
return /(second brain|2nd brain|제2뇌|브레인|brain|기억|기록|노트|문서|참고해서|사용해서|검색해서|근거|출처)/i.test(prompt);
}
private buildBrainOverviewReply(): string {
const activeBrain = getActiveBrainProfile();
const brainDir = activeBrain.localBrainPath;
const files = findBrainFiles(brainDir);
if (!fs.existsSync(brainDir)) {
return `현재 선택된 제2뇌는 **${activeBrain.name}**인데, 폴더가 아직 존재하지 않습니다.\n\n경로: \`${brainDir}\`\n\n상단의 Brain 설정에서 실제 지식 폴더를 연결하면 제가 그 자료를 먼저 참고해서 답변하겠습니다.`;
}
const entries = fs.readdirSync(brainDir, { withFileTypes: true })
.filter((entry) => !entry.name.startsWith('.') && !EXCLUDED_DIRS.has(entry.name));
const directorySummaries = entries
.filter((entry) => entry.isDirectory())
.slice(0, 12)
.map((entry) => {
const dirPath = path.join(brainDir, entry.name);
const count = findBrainFiles(dirPath).length;
return `| \`${entry.name}/\` | ${count}개 문서 |`;
});
const fileSummaries = entries
.filter((entry) => entry.isFile() && entry.name.endsWith('.md'))
.slice(0, 10)
.map((entry) => `- ${entry.name}`);
const sections = [
`현재 연결된 제2뇌 **${activeBrain.name}**의 개요입니다.`,
'',
'### 🧠 지식 베이스 현황',
'| 항목 | 정보 |',
'| :--- | :--- |',
`| **위치** | \`${brainDir}\` |`,
`| **문서 총계** | **${files.length}개** |`,
activeBrain.description ? `| **설명** | ${activeBrain.description} |` : '| **설명** | 설정된 설명 없음 |',
'',
'### 📂 주요 카테고리',
'| 폴더명 | 문서 수 |',
'| :--- | :--- |',
...(directorySummaries.length ? directorySummaries : ['| - | - |']),
'',
fileSummaries.length ? `### 📄 최근/주요 문서\n${fileSummaries.join('\n')}` : '',
'',
'이 자료들을 기반으로 답변을 최적화하겠습니다. 특정 주제에 대해 깊이 있는 분석이 필요하시면 말씀해 주세요.'
].filter(Boolean);
return sections.join('\n');
}
private isStaleRun(runId: number): boolean {
return runId !== this.activeRunId;
}