Skip to content

Commit 4c5aaf7

Browse files
committed
fix(agent-runner): deliver assistant text as fallback when model skips message tool
When sourceReplyDeliveryMode is message_tool_only (default for Telegram group chats), model responses were silently dropped if the model generated text without calling the message tool. Mark those payloads for fallback delivery so the user always sees the response.
1 parent 3bc728e commit 4c5aaf7

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/auto-reply/reply/agent-runner.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,31 @@ export async function runReplyAgent(params: {
19031903
});
19041904
}
19051905

1906+
// When sourceReplyDeliveryMode is "message_tool_only" the dispatch layer
1907+
// silently drops payloads that lack deliverDespiteSourceReplySuppression.
1908+
// If the model produced visible text but never called the message tool (and
1909+
// no block-streaming or other side-effect delivery occurred), mark the
1910+
// payloads for fallback delivery so the user still sees the response.
1911+
if (
1912+
opts?.sourceReplyDeliveryMode === "message_tool_only" &&
1913+
guardedReplyPayloads.length > 0 &&
1914+
!hasSuccessfulSideEffectDelivery({
1915+
blockReplyPipeline,
1916+
directlySentBlockKeys,
1917+
messagingToolSentTexts: runResult.messagingToolSentTexts,
1918+
messagingToolSentMediaUrls: runResult.messagingToolSentMediaUrls,
1919+
messagingToolSentTargets: runResult.messagingToolSentTargets,
1920+
successfulCronAdds: runResult.successfulCronAdds,
1921+
didSendDeterministicApprovalPrompt: runResult.didSendDeterministicApprovalPrompt,
1922+
})
1923+
) {
1924+
for (let i = 0; i < guardedReplyPayloads.length; i++) {
1925+
guardedReplyPayloads[i] = markReplyPayloadForSourceSuppressionDelivery(
1926+
guardedReplyPayloads[i],
1927+
);
1928+
}
1929+
}
1930+
19061931
// Prepend verbose operational notices. Model fallback notices are prepared
19071932
// earlier so they pass through normal reply threading and stream-dedupe.
19081933
let finalPayloads = guardedReplyPayloads;

0 commit comments

Comments
 (0)