Skip to content

Commit 0aed3a7

Browse files
ethanperezzclaude
andcommitted
fix(cron): apply responsePrefix to direct delivery payloads
Cron direct delivery (delivery.mode: "announce" with direct path) was sending raw response text without applying the configured responsePrefix. Interactive replies correctly resolve the prefix via resolveEffectiveMessagesConfig, but the cron deliverViaDirect path skipped this step entirely. Resolve responsePrefix for the delivery channel/account and prepend it to payload text, matching the behavior of route-reply and heartbeat delivery paths. Fixes #29600 Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent cc5dad8 commit 0aed3a7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/cron/isolated-agent/delivery-dispatch.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { resolveEffectiveMessagesConfig } from "../../agents/identity.js";
12
import { runSubagentAnnounceFlow } from "../../agents/subagent-announce.js";
23
import { countActiveDescendantRuns } from "../../agents/subagent-registry.js";
34
import { SILENT_REPLY_TOKEN } from "../../auto-reply/tokens.js";
@@ -193,13 +194,28 @@ export async function dispatchCronDelivery(
193194
delivery: SuccessfulDeliveryTarget,
194195
): Promise<RunCronAgentTurnResult | null> => {
195196
const identity = resolveAgentOutboundIdentity(params.cfgWithAgentDefaults, params.agentId);
197+
// Apply responsePrefix to direct delivery payloads (same logic as interactive replies).
198+
const { responsePrefix } = resolveEffectiveMessagesConfig(
199+
params.cfgWithAgentDefaults,
200+
params.agentId,
201+
{ channel: delivery.channel, accountId: delivery.accountId },
202+
);
203+
const applyPrefix = (text: string | undefined): string | undefined => {
204+
if (!responsePrefix || !text || text.startsWith(responsePrefix)) {
205+
return text;
206+
}
207+
return `${responsePrefix} ${text}`;
208+
};
196209
try {
197-
const payloadsForDelivery =
210+
const rawPayloads =
198211
deliveryPayloads.length > 0
199212
? deliveryPayloads
200213
: synthesizedText
201214
? [{ text: synthesizedText }]
202215
: [];
216+
const payloadsForDelivery = responsePrefix
217+
? rawPayloads.map((p) => (p.text ? { ...p, text: applyPrefix(p.text) } : p))
218+
: rawPayloads;
203219
if (payloadsForDelivery.length === 0) {
204220
return null;
205221
}

0 commit comments

Comments
 (0)