






















@@ -1,4 +1,5 @@
11import { Type, type TSchema } from "typebox";
2+import type { SourceReplyDeliveryMode } from "../../auto-reply/get-reply-options.types.js";
23import { listChannelPlugins } from "../../channels/plugins/index.js";
34import {
45channelSupportsMessageCapability,
@@ -520,6 +521,7 @@ type MessageToolOptions = {
520521hasRepliedRef?: { value: boolean };
521522sandboxRoot?: string;
522523requireExplicitTarget?: boolean;
524+sourceReplyDeliveryMode?: SourceReplyDeliveryMode;
523525requesterSenderId?: string;
524526senderIsOwner?: boolean;
525527};
@@ -648,6 +650,8 @@ function buildMessageToolDescription(options?: {
648650sessionKey?: string;
649651sessionId?: string;
650652agentId?: string;
653+requireExplicitTarget?: boolean;
654+sourceReplyDeliveryMode?: SourceReplyDeliveryMode;
651655requesterSenderId?: string;
652656senderIsOwner?: boolean;
653657}): string {
@@ -679,13 +683,35 @@ function buildMessageToolDescription(options?: {
679683ChannelMessageActionName | "send"
680684>;
681685return appendMessageToolReadHint(
682-`${baseDescription} Supports actions: ${sortedActions.join(", ")}.`,
686+appendMessageToolVisibleReplyHint(
687+`${baseDescription} Supports actions: ${sortedActions.join(", ")}.`,
688+resolvedOptions.sourceReplyDeliveryMode,
689+resolvedOptions.requireExplicitTarget,
690+),
683691sortedActions,
684692);
685693}
686694}
687695688-return `${baseDescription} Supports actions: send, delete, react, poll, pin, threads, and more.`;
696+return appendMessageToolVisibleReplyHint(
697+`${baseDescription} Supports actions: send, delete, react, poll, pin, threads, and more.`,
698+resolvedOptions.sourceReplyDeliveryMode,
699+resolvedOptions.requireExplicitTarget,
700+);
701+}
702+703+function appendMessageToolVisibleReplyHint(
704+description: string,
705+sourceReplyDeliveryMode?: SourceReplyDeliveryMode,
706+requireExplicitTarget?: boolean,
707+): string {
708+if (sourceReplyDeliveryMode !== "message_tool_only") {
709+return description;
710+}
711+const targetGuidance = requireExplicitTarget
712+ ? "Include target when sending."
713+ : "The target defaults to the current source conversation, so omit target unless sending elsewhere.";
714+return `${description} For this turn, visible replies to the current source conversation must use action="send" with message. ${targetGuidance} Normal final answers are private and are not posted.`;
689715}
690716691717function appendMessageToolReadHint(
@@ -743,6 +769,8 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
743769sessionKey: options?.agentSessionKey,
744770sessionId: options?.sessionId,
745771agentId: resolvedAgentId,
772+requireExplicitTarget: options?.requireExplicitTarget,
773+sourceReplyDeliveryMode: options?.sourceReplyDeliveryMode,
746774requesterSenderId: options?.requesterSenderId,
747775senderIsOwner: options?.senderIsOwner,
748776});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。