























@@ -42,6 +42,7 @@ import { stripFormattedReasoningMessage } from "../../shared/text/formatted-reas
4242import { parseInlineDirectives } from "../../utils/directive-tags.js";
4343import {
4444INTERNAL_MESSAGE_CHANNEL,
45+normalizeMessageChannel,
4546type GatewayClientMode,
4647type GatewayClientName,
4748} from "../../utils/message-channel.js";
@@ -630,17 +631,39 @@ function hasCurrentSourceReplyContext(input: RunMessageActionParams): boolean {
630631);
631632}
632633633-function shouldUseInternalSourceReplySink(
634+async function hasConfiguredCurrentSourceChannel(input: RunMessageActionParams): Promise<boolean> {
635+const provider =
636+normalizeMessageChannel(input.toolContext?.currentChannelProvider) ??
637+normalizeOptionalLowercaseString(input.toolContext?.currentChannelProvider);
638+if (!provider || provider === INTERNAL_MESSAGE_CHANNEL) {
639+return false;
640+}
641+if (!resolveOutboundChannelPlugin({ channel: provider, cfg: input.cfg, allowBootstrap: true })) {
642+return false;
643+}
644+const configuredChannels = await listConfiguredMessageChannels(input.cfg);
645+return configuredChannels.some((channel) => channel === provider);
646+}
647+648+async function shouldUseInternalSourceReplySink(
634649input: RunMessageActionParams,
635650params: Record<string, unknown>,
636651) {
637-return (
652+const hasImplicitCurrentSourceRoute =
638653input.action === "send" &&
639654input.sourceReplyDeliveryMode === "message_tool_only" &&
640655hasCurrentSourceReplyContext(input) &&
641656Boolean(input.sessionKey?.trim()) &&
642-!hasExplicitRouteParam(params)
643-);
657+!hasExplicitRouteParam(params);
658+if (!hasImplicitCurrentSourceRoute) {
659+return false;
660+}
661+if (!normalizeOptionalString(input.toolContext?.currentChannelId)) {
662+return true;
663+}
664+// Configured current-source channels can infer the target and deliver through
665+// the normal plugin path; the sink is only the private fallback.
666+return !(await hasConfiguredCurrentSourceChannel(input));
644667}
645668646669async function runGatewayPluginMessageActionOrNull(params: {
@@ -1404,7 +1427,7 @@ export async function runMessageAction(
14041427if (action === "send" && hasPollCreationParams(params)) {
14051428throw new Error('Poll fields require action "poll"; use action "poll" instead of "send".');
14061429}
1407-if (shouldUseInternalSourceReplySink(input, params)) {
1430+if (await shouldUseInternalSourceReplySink(input, params)) {
14081431return handleInternalSourceReplySendAction({ ...input, agentId: resolvedAgentId }, params);
14091432}
14101433applyImplicitSourceReplySendPolicy(input, params);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。