diff --git a/src/main/services/team/TeamProvisioningService.ts b/src/main/services/team/TeamProvisioningService.ts index 6c844209..a9db5928 100644 --- a/src/main/services/team/TeamProvisioningService.ts +++ b/src/main/services/team/TeamProvisioningService.ts @@ -733,6 +733,7 @@ interface ParsedBootstrapTranscriptTailLine { bootstrapFailureReason?: string | null; bootstrapContextCandidateByTeam?: Map; bootstrapContextMemberMatchByName?: Map; + bootstrapSuccessSourceByTeamMember?: Map; } interface ParsedBootstrapTranscriptTailCacheEntry { @@ -810,6 +811,30 @@ function getCachedBootstrapContextMemberMatchForLine( return value; } +function getCachedBootstrapSuccessSourceForLine( + line: ParsedBootstrapTranscriptTailLine, + normalizedText: string, + normalizedTeamName: string, + normalizedMemberName: string +): BootstrapTranscriptSuccessSource | null { + let sourceByTeamMember = line.bootstrapSuccessSourceByTeamMember; + if (!sourceByTeamMember) { + sourceByTeamMember = new Map(); + line.bootstrapSuccessSourceByTeamMember = sourceByTeamMember; + } + const cacheKey = `${normalizedTeamName}\0${normalizedMemberName}`; + if (sourceByTeamMember.has(cacheKey)) { + return sourceByTeamMember.get(cacheKey) ?? null; + } + const source = getBootstrapTranscriptSuccessSourceFromNormalized( + normalizedText, + normalizedTeamName, + normalizedMemberName + ); + sourceByTeamMember.set(cacheKey, source); + return source; +} + import type { ActiveToolCall, AgentActionMode, @@ -30646,7 +30671,8 @@ export class TeamProvisioningService { outcome = { kind: 'failure', observedAt: candidate.observedAt, reason }; break; } - const successSource = getBootstrapTranscriptSuccessSourceFromNormalized( + const successSource = getCachedBootstrapSuccessSourceForLine( + cachedLine, candidate.normalizedText, normalizedTeamName, normalizedMemberName