@@ -63,7 +63,10 @@ import {
6363 parseThreadSessionSuffix ,
6464} from "../../routing/session-key.js" ;
6565import { stripFormattedReasoningMessage } from "../../shared/text/formatted-reasoning-message.js" ;
66- import { normalizeMessageChannel } from "../../utils/message-channel.js" ;
66+ import {
67+ INTERNAL_MESSAGE_CHANNEL ,
68+ normalizeMessageChannel ,
69+ } from "../../utils/message-channel.js" ;
6770import { resolveSessionAgentId } from "../agent-scope.js" ;
6871import { listAllChannelSupportedActions , listChannelSupportedActions } from "../channel-tools.js" ;
6972import { stripInternalRuntimeContext } from "../internal-runtime-context.js" ;
@@ -1175,6 +1178,12 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
11751178 const replyToMode = options ?. replyToMode ?? ( currentThreadTs ? "all" : undefined ) ;
11761179 const agentAccountId =
11771180 resolveAgentAccountId ( options ?. agentAccountId ) ?? effectiveCurrentChannel . accountId ;
1181+ const currentChannelIsInternal =
1182+ normalizeMessageChannel ( effectiveCurrentChannel . currentChannelProvider ) ===
1183+ INTERNAL_MESSAGE_CHANNEL ;
1184+ const sourceReplyDeliveryMode =
1185+ options ?. sourceReplyDeliveryMode ??
1186+ ( currentChannelIsInternal ? "message_tool_only" : undefined ) ;
11781187 const resolvedAgentId =
11791188 options ?. agentId ??
11801189 ( options ?. agentSessionKey
@@ -1209,7 +1218,7 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
12091218 sessionId : options ?. sessionId ,
12101219 agentId : resolvedAgentId ,
12111220 requireExplicitTarget : options ?. requireExplicitTarget ,
1212- sourceReplyDeliveryMode : options ?. sourceReplyDeliveryMode ,
1221+ sourceReplyDeliveryMode,
12131222 requesterSenderId : options ?. requesterSenderId ,
12141223 senderIsOwner : options ?. senderIsOwner ,
12151224 } ) ;
@@ -1415,7 +1424,7 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
14151424 sessionId : options ?. sessionId ,
14161425 agentId : resolvedAgentId ,
14171426 sandboxRoot : options ?. sandboxRoot ,
1418- sourceReplyDeliveryMode : options ?. sourceReplyDeliveryMode ,
1427+ sourceReplyDeliveryMode,
14191428 inboundEventKind : options ?. inboundEventKind ,
14201429 inboundAudio : options ?. currentInboundAudio ,
14211430 abortSignal : signal ,
0 commit comments