GeezerVison is showing github.com — fix(server): Antigravity usage stays priced when agy names one model … · patroza/t3code@0d2b8ed
File treeExpand file treeCollapse file tree Open diff view settings apps/server/src/provider/Drivers
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Drivers/antigravityUsageReader.test.ts +56Lines changed: 56 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -386,6 +386,10 @@ describe("readAntigravityUsage", () => { | 386 | 386 | "gemini-pro-orchestrator-neon", | 387 | 387 | "gemini-4-hydrogen-orchestrator", | 388 | 388 | "gemini-pro-orchestrator-g1-pro", | | 389 | + "gemini-pro-orchestrator", | | 390 | + "gemini-3.8-flash-n", | | 391 | + "gemini-4-argon-r", | | 392 | + "gemini-4-argon-trial", | 389 | 393 | ].entries()) { | 390 | 394 | yield* db.run("INSERT INTO gen_metadata VALUES (?, ?)", [ | 391 | 395 | idx, | @@ -401,6 +405,14 @@ describe("readAntigravityUsage", () => { | 401 | 405 | 20, | 402 | 406 | new Uint8Array(protoBytes(9, [...protoNumber(1, 1537), ...protoNumber(2, 30)])), | 403 | 407 | ]); | | 408 | + for (const [offset, id] of [1525, 1527].entries()) { | | 409 | + yield* db.run("INSERT INTO steps VALUES (?, ?)", [ | | 410 | + 21 + offset, | | 411 | + new Uint8Array( | | 412 | + protoBytes(9, [...protoNumber(1, id), ...protoNumber(2, 31 + offset)]), | | 413 | + ), | | 414 | + ]); | | 415 | + } | 404 | 416 | }), | 405 | 417 | ); | 406 | 418 | const result = yield* readAntigravityUsage(dir, 0); | @@ -416,12 +428,56 @@ describe("readAntigravityUsage", () => { | 416 | 428 | ["gemini-pro-orchestrator-neon", "gemini-4-neon"], | 417 | 429 | ["gemini-4-hydrogen-orchestrator", "gemini-4-hydrogen"], | 418 | 430 | ["gemini-pro-orchestrator-g1-pro", "gemini-4-argon"], | | 431 | + ["gemini-pro-orchestrator", "gemini-4-carbon"], | | 432 | + ["gemini-3.8-flash-n", "gemini-3.8-flash"], | | 433 | + ["gemini-4-argon-r", "gemini-4-argon"], | | 434 | + ["gemini-4-argon-trial", "gemini-4-argon"], | 419 | 435 | ["gemini-pro-orchestrator-neon", "gemini-4-neon"], | | 436 | + ["gemini-4-hydrogen", undefined], | | 437 | + ["gemini-4-hydrogen", undefined], | 420 | 438 | ], | 421 | 439 | ); | 422 | 440 | }).pipe(Effect.provide(NodeServices.layer)), | 423 | 441 | ); | 424 | 442 |
| | 443 | + it.effect("learns one model for an id seen as both its bare and effort-suffixed name", () => | | 444 | + Effect.gen(function* () { | | 445 | + const path = yield* Path.Path; | | 446 | + const dir = yield* tempDir; | | 447 | + yield* seedDatabase(path.join(dir, "effort-names.db"), (db) => | | 448 | + Effect.gen(function* () { | | 449 | + yield* createTables(db); | | 450 | + // agy sometimes leaves field 19 empty and only the display name in field 21 names the model. | | 451 | + for (const [idx, [id, field, name]] of ( | | 452 | + [ | | 453 | + [1532, 19, "gemini-4-neon"], | | 454 | + [1532, 21, "Gemini 4 Neon (High)"], | | 455 | + [1318, 19, "gemini-3.8-flash"], | | 456 | + [1318, 21, "Gemini 3.8 Flash (High)"], | | 457 | + ] as const | | 458 | + ).entries()) { | | 459 | + yield* db.run("INSERT INTO gen_metadata VALUES (?, ?)", [ | | 460 | + idx, | | 461 | + new Uint8Array(protoBytes(1, [...protoNumber(3, id), ...protoText(field, name)])), | | 462 | + ]); | | 463 | + } | | 464 | + for (const [offset, id] of [1532, 1318].entries()) { | | 465 | + yield* db.run("INSERT INTO steps VALUES (?, ?)", [ | | 466 | + 50 + offset, | | 467 | + new Uint8Array(protoBytes(9, [...protoNumber(1, id), ...protoNumber(2, 10)])), | | 468 | + ]); | | 469 | + } | | 470 | + }), | | 471 | + ); | | 472 | + const result = yield* readAntigravityUsage(dir, 0); | | 473 | + assert.deepStrictEqual(result.errors, []); | | 474 | + assert.deepStrictEqual( | | 475 | + records(result).map(({ model, rateModel }) => rateModel ?? model), | | 476 | + ["gemini-4-neon", "gemini-3.8-flash"], | | 477 | + ); | | 478 | + }).pipe(Effect.provide(NodeServices.layer)), | | 479 | + ); | | 480 | + | 425 | 481 | it.effect("merges Antigravity aliases that bridge previously separate step records", () => | 426 | 482 | Effect.gen(function* () { | 427 | 483 | const path = yield* Path.Path; | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Drivers/antigravityUsageReader.ts +23-5Lines changed: 23 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -126,13 +126,22 @@ const MODEL_IDS: Record<number, string> = { | 126 | 126 | 1417: "gemini-4-argon", | 127 | 127 | 1418: "gemini-4-argon", | 128 | 128 | 1419: "gemini-4-argon", | | 129 | + 1427: "gemini-4-carbon", | | 130 | + 1437: "gemini-4-carbon", | | 131 | + 1525: "gemini-4-hydrogen", | | 132 | + 1526: "gemini-4-hydrogen", | | 133 | + 1527: "gemini-4-hydrogen", | | 134 | + 1532: "gemini-4-neon", | | 135 | + 1533: "gemini-4-neon", | 129 | 136 | 1537: "gemini-pro-orchestrator-neon", | | 137 | + 1667: "gemini-pro-orchestrator", | | 138 | + 1669: "gemini-4-hydrogen-orchestrator", | 130 | 139 | }; | 131 | 140 |
| 132 | 141 | // Effort and routing variants share the base model's price. | 133 | 142 | export const antigravityRateModel = (model: string) => { | 134 | 143 | const base = model.replace( | 135 | | - /-(?:extra-low|low|medium|high|tiered|control|thinking|agent|orchestrator)$/, | | 144 | + /-(?:extra-low|low|medium|high|tiered|control|thinking|agent|orchestrator|trial|n|r)$/, | 136 | 145 | "", | 137 | 146 | ); | 138 | 147 | return /^gemini-3-flash-(?:agent(?:-[ab])?|[ab])$/.test(model) | @@ -143,9 +152,11 @@ export const antigravityRateModel = (model: string) => { | 143 | 152 | ? "gemini-4-neon" | 144 | 153 | : model === "gemini-pro-orchestrator-g1-pro" | 145 | 154 | ? "gemini-4-argon" | 146 | | - : base === "gemini-3-flash" | 147 | | - ? "gemini-3-flash-preview" | 148 | | - : base; | | 155 | + : model === "gemini-pro-orchestrator" | | 156 | + ? "gemini-4-carbon" | | 157 | + : base === "gemini-3-flash" | | 158 | + ? "gemini-3-flash-preview" | | 159 | + : base; | 149 | 160 | }; | 150 | 161 |
| 151 | 162 | function withRateModel(record: UsageRecord): UsageRecord { | @@ -178,7 +189,14 @@ function isConcreteModel(model: string): boolean { | 178 | 189 |
| 179 | 190 | function rememberModel(models: Map<number, string | null>, id: number, model: string | null) { | 180 | 191 | const previous = models.get(id); | 181 | | - models.set(id, previous === undefined || previous === model ? model : null); | | 192 | + if (previous === undefined) models.set(id, model); | | 193 | + else if ( | | 194 | + previous !== model && | | 195 | + (previous === null || | | 196 | + model === null || | | 197 | + antigravityRateModel(previous) !== antigravityRateModel(model)) | | 198 | + ) | | 199 | + models.set(id, null); | 182 | 200 | } | 183 | 201 |
| 184 | 202 | interface Metadata { | |
|