fix(cron): keep runner-owned delivery off message tool

This commit is contained in:
Ayaan Zaidi
2026-04-18 14:28:13 +05:30
parent 49ae60d6ca
commit 13a0d7a9e0
2 changed files with 12 additions and 1 deletions

View File

@@ -92,6 +92,14 @@ describe("runCronIsolatedAgentTurn message tool policy", () => {
});
});
it("disables the message tool when webhook delivery is active", async () => {
await expectMessageToolDisabledForPlan({
requested: false,
mode: "webhook",
to: "https://example.invalid/cron",
});
});
it("keeps the message tool enabled for shared callers when delivery is not requested", async () => {
mockRunCronFallbackPassthrough();
resolveCronDeliveryPlanMock.mockReturnValue({

View File

@@ -124,13 +124,14 @@ type IsolatedDeliveryContract = "cron-owned" | "shared";
function resolveCronToolPolicy(params: {
deliveryRequested: boolean;
resolvedDelivery: ResolvedCronDeliveryTarget;
deliveryMode: "announce" | "webhook" | "none";
}) {
return {
// Only enforce an explicit message target when the cron delivery target
// was successfully resolved. When resolution fails the agent should not
// be blocked by a target it cannot satisfy (#27898).
requireExplicitMessageTarget: params.deliveryRequested && params.resolvedDelivery.ok,
disableMessageTool: params.deliveryRequested,
disableMessageTool: params.deliveryMode !== "none",
};
}
@@ -158,6 +159,7 @@ async function resolveCronDeliveryContext(params: {
toolPolicy: resolveCronToolPolicy({
deliveryRequested: false,
resolvedDelivery,
deliveryMode: deliveryPlan.mode,
}),
};
}
@@ -176,6 +178,7 @@ async function resolveCronDeliveryContext(params: {
toolPolicy: resolveCronToolPolicy({
deliveryRequested: deliveryPlan.requested,
resolvedDelivery,
deliveryMode: deliveryPlan.mode,
}),
};
}