perf(LLM 併發): 角色分析與誤報/補行號裁決改為並行 sub-agent(預設不限併發)
This commit is contained in:
+11
-4
@@ -9,6 +9,7 @@ import { getRunUsage, getRateLimit, fetchAccountQuota, formatUsageStats, formatU
|
||||
import { cloneRepo, commitAndPush, getRepoState } from './git.js';
|
||||
import { validateJSONArrayFile, ensureJSONArrayFileExists } from './json.js';
|
||||
import { runPreflight } from './preflight.js';
|
||||
import { mapWithConcurrency, LLM_CONCURRENCY } from './llm.js';
|
||||
import { section, step, line, input, output, result, warn, error } from './log.js';
|
||||
|
||||
const WORKSPACE = process.env.GITHUB_WORKSPACE || '/workspace';
|
||||
@@ -120,15 +121,21 @@ async function main() {
|
||||
} catch (e) {
|
||||
warn(`角色介紹 comment 發布失敗(繼續執行): ${e.message}`);
|
||||
}
|
||||
// 各角色以獨立 LLM 子行程並行分析(併發上限見 LLM_CONCURRENCY),單一角色失敗僅 warn 後跳過。
|
||||
const newFindings = [];
|
||||
let fulfilledAnalyses = 0;
|
||||
for (const role of roles) {
|
||||
const roleResults = await mapWithConcurrency(roles, LLM_CONCURRENCY, async (role) => {
|
||||
try {
|
||||
const findings = await analyzeWithRole(role, diff);
|
||||
fulfilledAnalyses += 1;
|
||||
newFindings.push(...findings);
|
||||
return await analyzeWithRole(role, diff);
|
||||
} catch (e) {
|
||||
warn(`[${role.name}] 分析失敗(跳過): ${e.message}`);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
for (const findings of roleResults) {
|
||||
if (findings) {
|
||||
fulfilledAnalyses += 1;
|
||||
newFindings.push(...findings);
|
||||
}
|
||||
}
|
||||
if (fulfilledAnalyses === 0) {
|
||||
|
||||
Reference in New Issue
Block a user