Skip to content

Commit 28d2f04

Browse files
committed
test: consolidate cron model override coverage
1 parent 0559bc2 commit 28d2f04

3 files changed

Lines changed: 59 additions & 300 deletions

File tree

src/cron/isolated-agent.model-formatting.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,44 @@ describe("cron model formatting and precedence edge cases", () => {
524524
});
525525
});
526526

527+
describe("Gmail hook model precedence", () => {
528+
const gmailModel = {
529+
provider: "openrouter",
530+
model: "meta-llama/llama-3.3-70b:free",
531+
};
532+
533+
it("keeps an allowed hook model ahead of a stored session override", async () => {
534+
resolveHooksGmailModelMock.mockReturnValue(gmailModel);
535+
getModelRefStatusMock.mockReturnValue({ allowed: true });
536+
537+
await expect(
538+
selectModel({
539+
isGmailHook: true,
540+
sessionEntry: {
541+
providerOverride: "anthropic",
542+
modelOverride: "claude-opus-4-6",
543+
},
544+
}),
545+
).resolves.toMatchObject({
546+
ok: true,
547+
...gmailModel,
548+
modelSource: "hook",
549+
});
550+
});
551+
552+
it("keeps the configured default when the hook model is not allowed", async () => {
553+
resolveHooksGmailModelMock.mockReturnValue(gmailModel);
554+
getModelRefStatusMock.mockReturnValue({ allowed: false });
555+
556+
await expect(selectModel({ isGmailHook: true })).resolves.toMatchObject({
557+
ok: true,
558+
provider: DEFAULT_PROVIDER,
559+
model: DEFAULT_MODEL,
560+
modelSource: "default",
561+
});
562+
});
563+
});
564+
527565
describe("whitespace and empty model strings", () => {
528566
it("whitespace-only model treated as unset (falls to default)", async () => {
529567
await expectDefaultSelectedModel({

src/cron/isolated-agent.model-overrides.test.ts

Lines changed: 0 additions & 300 deletions
This file was deleted.

src/cron/isolated-agent/run.cron-model-override-forwarding.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,27 @@ describe("runCronIsolatedAgentTurn — cron model override forwarding (#58065)",
439439
expect(embeddedCall.thinkLevel).toBe("medium");
440440
});
441441

442+
it("passes the resolved default thinking level to the embedded agent runner", async () => {
443+
resolveThinkingDefaultMock.mockReturnValue("low");
444+
isThinkingLevelSupportedMock.mockReturnValue(true);
445+
runWithModelFallbackMock.mockImplementation(async ({ provider, model, run }) => ({
446+
result: await run(provider, model),
447+
provider,
448+
model,
449+
attempts: [],
450+
}));
451+
452+
await runCronIsolatedAgentTurn(makeParams());
453+
454+
expect(resolveThinkingDefaultMock).toHaveBeenCalledWith(
455+
expect.objectContaining({
456+
provider: "google",
457+
model: "gemini-2.0-flash",
458+
}),
459+
);
460+
expect(firstMockArg(runEmbeddedAgentMock).thinkLevel).toBe("low");
461+
});
462+
442463
it("uses a stored cron-session thinking preference before configured defaults", async () => {
443464
resolveAllowedModelRefMock.mockReturnValue({
444465
ref: { provider: "openai", model: "gpt-5.6-luna" },

0 commit comments

Comments
 (0)