Skip to content

Commit 8b8a36e

Browse files
fix(cron): keep recovered tool warnings diagnostic
1 parent a9476bf commit 8b8a36e

2 files changed

Lines changed: 4 additions & 52 deletions

File tree

src/cron/isolated-agent.helpers.test.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
import { describe, expect, it } from "vitest";
22
import { setReplyPayloadMetadata } from "../auto-reply/reply-payload.js";
3-
import { detectCronDenialToken, resolveCronPayloadOutcome } from "./isolated-agent/helpers.js";
4-
5-
describe("detectCronDenialToken", () => {
6-
it("matches host denial markers case-sensitively", () => {
7-
expect(detectCronDenialToken("SYSTEM_RUN_DENIED: approval blocked")).toBe("SYSTEM_RUN_DENIED");
8-
expect(detectCronDenialToken("INVALID_REQUEST: denied")).toBe("INVALID_REQUEST");
9-
expect(detectCronDenialToken("system_run_denied: approval blocked")).toBeUndefined();
10-
expect(detectCronDenialToken("invalid_request: denied")).toBeUndefined();
11-
});
12-
13-
it("matches model-narrated denial phrases case-insensitively", () => {
14-
expect(detectCronDenialToken("Approval Cannot Safely Bind this runtime command")).toBe(
15-
"approval cannot safely bind",
16-
);
17-
expect(detectCronDenialToken("The runtime denied the operation.")).toBe("runtime denied");
18-
expect(detectCronDenialToken("I could not run the script.")).toBe("could not run");
19-
expect(detectCronDenialToken("The command did not run to completion.")).toBe("did not run");
20-
expect(detectCronDenialToken("The request was denied by policy.")).toBe("was denied");
21-
});
22-
23-
it("ignores empty and non-token text", () => {
24-
expect(detectCronDenialToken(undefined)).toBeUndefined();
25-
expect(
26-
detectCronDenialToken("The denied claim was reviewed, then the job succeeded."),
27-
).toBeUndefined();
28-
});
29-
});
3+
import { resolveCronPayloadOutcome } from "./isolated-agent/helpers.js";
304

315
describe("resolveCronPayloadOutcome", () => {
326
it("uses the last non-empty non-error payload as summary and output", () => {

src/cron/isolated-agent/helpers.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -293,35 +293,15 @@ export function resolveCronPayloadOutcome(params: {
293293
: synthesizedText
294294
? [{ text: synthesizedText }]
295295
: [];
296-
const denialSignal = resolveCronDenialSignal([
297-
{ field: "summary", text: summary },
298-
{ field: "outputText", text: outputText },
299-
{ field: "synthesizedText", text: synthesizedText },
300-
{ field: "fallbackSummary", text: fallbackSummary },
301-
{ field: "fallbackOutputText", text: fallbackOutputText },
302-
...params.payloads
303-
.map((payload, index) => ({ payload, index }))
304-
.filter(({ payload }) => !isNonTerminalToolErrorWarning(payload))
305-
.map(({ payload, index }) => ({
306-
field: `payloads[${index}].text`,
307-
text: payload?.text,
308-
})),
309-
]);
310296
const failureSignal = normalizeCronFailureSignal(params.failureSignal);
311297
const runLevelError = formatCronRunLevelError(params.runLevelError);
312298
const hasFatalErrorPayload =
313-
hasFatalStructuredErrorPayload ||
314-
failureSignal !== undefined ||
315-
denialSignal !== undefined ||
316-
runLevelError !== undefined;
299+
hasFatalStructuredErrorPayload || failureSignal !== undefined || runLevelError !== undefined;
317300
const structuredErrorText = hasFatalStructuredErrorPayload
318301
? (lastErrorPayloadText ?? "cron isolated run returned an error payload")
319302
: undefined;
320303
const shouldUseRunLevelErrorPayload =
321-
runLevelError !== undefined &&
322-
structuredErrorText === undefined &&
323-
failureSignal === undefined &&
324-
denialSignal === undefined;
304+
runLevelError !== undefined && structuredErrorText === undefined && failureSignal === undefined;
325305
const fatalDeliveryText =
326306
structuredErrorText ??
327307
failureSignal?.message ??
@@ -343,9 +323,7 @@ export function resolveCronPayloadOutcome(params: {
343323
? structuredErrorText
344324
: failureSignal
345325
? formatCronFailureSignal(failureSignal)
346-
: denialSignal
347-
? formatCronDenialSignal(denialSignal)
348-
: runLevelError,
326+
: runLevelError,
349327
pendingPresentationWarningError: hasPendingPresentationWarning
350328
? lastErrorPayloadText
351329
: undefined,

0 commit comments

Comments
 (0)