From bd8497f8dd9f73c6f67c7ec4af5d4dae9d1c318a Mon Sep 17 00:00:00 2001 From: "Keita A." Date: Thu, 19 Mar 2026 18:20:49 +0900 Subject: [PATCH] =?UTF-8?q?heartbeat-runner.cost-cap.test.ts=20=E3=82=92?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/infra/heartbeat-runner.cost-cap.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/infra/heartbeat-runner.cost-cap.test.ts b/src/infra/heartbeat-runner.cost-cap.test.ts index f91e7b7157b..53b74212fc8 100644 --- a/src/infra/heartbeat-runner.cost-cap.test.ts +++ b/src/infra/heartbeat-runner.cost-cap.test.ts @@ -327,10 +327,11 @@ describe("runHeartbeatOnce – maxCostPerRun", () => { expect(replyCallCount).toBe(1); }); - it("proceeds for free catalog model when maxCostPerRun is 0", async () => { - // Free model: estimated cost = $0. maxCostPerRun = 0. 0 > 0 = false, so run proceeds. - // This uses heartbeat.model override which goes through the hardcoded table, - // not the catalog. A truly free model via catalog would also return $0. + it("skips cheap (non-free) model when maxCostPerRun is 0", async () => { + // gemini-2.0-flash costs $0.10/M input — non-zero — so with maxCostPerRun = 0 + // the condition (estimatedCost > 0) is true and the run is skipped. + // Note: a *truly* free model (cost.input = 0 in catalog) would NOT be skipped + // because 0 > 0 === false. That scenario is covered by the unit tests above. const { result, replyCallCount } = await runWithCostCap({ maxCostPerRun: 0, model: "gemini-2.0-flash", // cheapest in table, but still > $0 for non-empty prompt