fix: preserve cron telegram topic delivery after timeout (#72317)

This commit is contained in:
Josh Lehman
2026-04-26 13:30:54 -07:00
committed by GitHub
parent ffa84cdc02
commit 8ba82534e6
3 changed files with 48 additions and 0 deletions

View File

@@ -363,6 +363,18 @@ describe("runCronIsolatedAgentTurn telegram forum-topic direct delivery", () =>
});
});
it("preserves explicit supergroup topic targets for cron announce delivery", async () => {
await expectTelegramAnnounceDelivery({
to: "-1003774691294:topic:47",
payloads: [{ text: "topic 47 completion" }],
expected: {
chatId: "-1003774691294",
text: "topic 47 completion",
messageThreadId: 47,
},
});
});
it("delivers only the final assistant-visible text to forum-topic telegram targets", async () => {
await expectTelegramAnnounceDelivery({
to: "123:topic:42",

View File

@@ -143,6 +143,7 @@ export function createCronPromptExecutor(params: {
cliSessionId,
skillsSnapshot: params.skillsSnapshot,
messageChannel: params.messageChannel,
abortSignal: params.abortSignal,
bootstrapPromptWarningSignaturesSeen,
bootstrapPromptWarningSignature,
senderIsOwner: true,

View File

@@ -6,6 +6,7 @@ import {
} from "./run.suite-helpers.js";
import {
buildWorkspaceSkillSnapshotMock,
dispatchCronDeliveryMock,
getCliSessionIdMock,
isCliProviderMock,
lookupContextTokensMock,
@@ -257,6 +258,40 @@ describe("runCronIsolatedAgentTurn — skill filter", () => {
});
describe("CLI session handoff (issue #29774)", () => {
it("passes the cron abort signal to CLI runs and drops late CLI results", async () => {
const abortController = new AbortController();
let markCliStarted!: () => void;
const cliStarted = new Promise<void>((resolve) => {
markCliStarted = resolve;
});
isCliProviderMock.mockReturnValue(true);
runCliAgentMock.mockImplementationOnce(async (params: { abortSignal?: AbortSignal }) => {
expect(params.abortSignal).toBe(abortController.signal);
markCliStarted();
await new Promise<void>((resolve) => {
params.abortSignal?.addEventListener("abort", () => resolve(), { once: true });
});
return {
payloads: [{ text: "late cli output" }],
meta: { agentMeta: { sessionId: "late-cli-session", usage: { input: 5, output: 10 } } },
};
});
mockCliFallbackInvocation();
const runPromise = runCronIsolatedAgentTurn(
makeSkillParams({ abortSignal: abortController.signal }),
);
await cliStarted;
abortController.abort("cron: job execution timed out");
const result = await runPromise;
expect(result.status).toBe("error");
expect(result.error).toBe("cron: job execution timed out");
expect(dispatchCronDeliveryMock).not.toHaveBeenCalled();
});
it("does not pass stored cliSessionId on fresh isolated runs (isNewSession=true)", async () => {
// Simulate a persisted CLI session ID from a previous run.
getCliSessionIdMock.mockReturnValue("prev-cli-session-abc");