diff --git a/src/analyze.ts b/src/analyze.ts index 7c60e6d..7e0edc6 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -273,6 +273,8 @@ export async function analyze( }, ): Promise { const llm = opts.llm; + const primaryTimeout = llm.requestTimeoutMs ?? 180000; + const compressedTimeout = Math.max(Math.round(primaryTimeout * (2 / 3)), 45000); const allItems = profiles.flatMap((p) => p.items); const username = profiles[0]?.username ?? "(unknown)"; @@ -307,9 +309,7 @@ export async function analyze( chunks.length, ); const totalChunks = chunks.length; - // Default to running every chunk concurrently (capped to avoid API rate - // limits). Chunk analysis is independent, so serial rounds were the main - // source of wall-clock latency. + const maxConcurrency = Math.max( 1, Math.min(opts.chunkConcurrency ?? 8, totalChunks || 1), @@ -373,7 +373,7 @@ ${SCHEMA_HINT}`; maxTokens: 2200, json: true, }), - llm.requestTimeoutMs ?? 70000, + primaryTimeout, `chunk ${currentChunk}/${totalChunks}`, ); } catch { @@ -409,7 +409,7 @@ ${SCHEMA_HINT}`; maxTokens: 1100, json: true, }), - llm.requestTimeoutMs ? Math.round(llm.requestTimeoutMs * 0.6) : 45000, + compressedTimeout, `compressed chunk ${currentChunk}/${totalChunks}`, ); } finally { @@ -486,7 +486,10 @@ ${SCHEMA_HINT}`; } } - for (const url of parsed.identity?.publicProofUrls ?? []) { + const allProofUrls = parsedChunks.flatMap( + (c) => c.identity?.publicProofUrls ?? [], + ); + for (const url of allProofUrls) { if (typeof url === "string" && /^https?:\/\//i.test(url)) { knownProofUrls.add(url.trim()); }