
























@@ -205,8 +205,14 @@ async function restoreSlackAssistantThreadContextFromMetadata(params: {
205205function resolveCachedMentionRegexes(
206206ctx: SlackMonitorContext,
207207agentId: string | undefined,
208+options?: Parameters<typeof buildMentionRegexes>[2],
208209): RegExp[] {
209-const key = normalizeOptionalString(agentId) ?? "__default__";
210+const key = [
211+normalizeOptionalString(agentId) ?? "__default__",
212+normalizeOptionalString(options?.provider),
213+normalizeOptionalString(options?.conversationId ?? undefined),
214+options?.providerPolicy ? JSON.stringify(options.providerPolicy) : "",
215+].join("\u001f");
210216let byAgent = mentionRegexCache.get(ctx);
211217if (!byAgent) {
212218byAgent = new Map<string, RegExp[]>();
@@ -216,7 +222,7 @@ function resolveCachedMentionRegexes(
216222if (cached) {
217223return cached;
218224}
219-const built = buildMentionRegexes(ctx.cfg, agentId);
225+const built = buildMentionRegexes(ctx.cfg, agentId, options);
220226byAgent.set(key, built);
221227return built;
222228}
@@ -721,7 +727,13 @@ export async function prepareSlackMessage(params: {
721727canResolveExplicit: Boolean(ctx.botUserId),
722728},
723729}));
724-let mentionRegexes = resolveCachedMentionRegexes(ctx, routing.route.agentId);
730+const buildPolicyMentionRegexes = (agentId: string | undefined) =>
731+resolveCachedMentionRegexes(ctx, agentId, {
732+provider: "slack",
733+conversationId: message.channel,
734+providerPolicy: account.config.mentionPatterns,
735+});
736+let mentionRegexes = buildPolicyMentionRegexes(routing.route.agentId);
725737let wasMentioned = resolveWasMentioned(mentionRegexes);
726738const hasBoundSession = Boolean(
727739routing.runtimeBoundSessionKey || routing.configuredBindingSessionKey,
@@ -746,7 +758,7 @@ export async function prepareSlackMessage(params: {
746758seedTopLevelRoomThread: true,
747759assistantThreadTs: assistantThreadContext?.threadTs,
748760});
749-mentionRegexes = resolveCachedMentionRegexes(ctx, routing.route.agentId);
761+mentionRegexes = buildPolicyMentionRegexes(routing.route.agentId);
750762wasMentioned = resolveWasMentioned(mentionRegexes);
751763}
752764const {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。