perf(main): cache bootstrap transcript context checks
This commit is contained in:
parent
94c09727f1
commit
5a3e59f765
1 changed files with 50 additions and 2 deletions
|
|
@ -731,6 +731,8 @@ interface ParsedBootstrapTranscriptTailLine {
|
|||
// this line's parse-cache entry (filePath + mtime + size); a file change re-parses
|
||||
// into fresh line objects, so the memo cannot drift from the line's text.
|
||||
bootstrapFailureReason?: string | null;
|
||||
bootstrapContextCandidateByTeam?: Map<string, boolean>;
|
||||
bootstrapContextMemberMatchByName?: Map<string, boolean>;
|
||||
}
|
||||
|
||||
interface ParsedBootstrapTranscriptTailCacheEntry {
|
||||
|
|
@ -764,6 +766,50 @@ function isNormalizedBootstrapTranscriptContextMemberText(
|
|||
return !!normalizedMemberName && normalizedText.includes(normalizedMemberName);
|
||||
}
|
||||
|
||||
function getCachedBootstrapContextCandidateForLine(
|
||||
line: ParsedBootstrapTranscriptTailLine,
|
||||
normalizedText: string,
|
||||
normalizedTeamName: string
|
||||
): boolean {
|
||||
let candidateByTeam = line.bootstrapContextCandidateByTeam;
|
||||
if (!candidateByTeam) {
|
||||
candidateByTeam = new Map<string, boolean>();
|
||||
line.bootstrapContextCandidateByTeam = candidateByTeam;
|
||||
}
|
||||
const cached = candidateByTeam.get(normalizedTeamName);
|
||||
if (cached !== undefined) {
|
||||
return cached;
|
||||
}
|
||||
const value = isNormalizedBootstrapTranscriptContextCandidateText(
|
||||
normalizedText,
|
||||
normalizedTeamName
|
||||
);
|
||||
candidateByTeam.set(normalizedTeamName, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
function getCachedBootstrapContextMemberMatchForLine(
|
||||
line: ParsedBootstrapTranscriptTailLine,
|
||||
normalizedText: string,
|
||||
normalizedMemberName: string
|
||||
): boolean {
|
||||
let matchByName = line.bootstrapContextMemberMatchByName;
|
||||
if (!matchByName) {
|
||||
matchByName = new Map<string, boolean>();
|
||||
line.bootstrapContextMemberMatchByName = matchByName;
|
||||
}
|
||||
const cached = matchByName.get(normalizedMemberName);
|
||||
if (cached !== undefined) {
|
||||
return cached;
|
||||
}
|
||||
const value = isNormalizedBootstrapTranscriptContextMemberText(
|
||||
normalizedText,
|
||||
normalizedMemberName
|
||||
);
|
||||
matchByName.set(normalizedMemberName, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
import type {
|
||||
ActiveToolCall,
|
||||
AgentActionMode,
|
||||
|
|
@ -30545,14 +30591,16 @@ export class TeamProvisioningService {
|
|||
}
|
||||
const lineNormalizedText = normalizedText ?? '';
|
||||
if (shouldCollectBootstrapContext) {
|
||||
const isBootstrapContextLine = isNormalizedBootstrapTranscriptContextCandidateText(
|
||||
const isBootstrapContextLine = getCachedBootstrapContextCandidateForLine(
|
||||
parsedLine,
|
||||
lineNormalizedText,
|
||||
normalizedTeamName
|
||||
);
|
||||
if (isBootstrapContextLine) {
|
||||
for (const contextMemberName of normalizedContextMemberNames) {
|
||||
if (
|
||||
isNormalizedBootstrapTranscriptContextMemberText(
|
||||
getCachedBootstrapContextMemberMatchForLine(
|
||||
parsedLine,
|
||||
lineNormalizedText,
|
||||
contextMemberName
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue