Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): refreshing providers re-reads Claude usage older than a minute #28720

Closedryoppippi(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/28720/headopened View on GitHub

Showing 2 changed files with 77 additions and 1 deletion.

x
0 of 2 viewed, 2 left
56 additions and 0 deletionspackages/provider-core/src/server/managedProvider.test.tsModified
View file
@@ -8,6 +8,7 @@
} from "@t3tools/contracts";
import { createModelCapabilities } from "@t3tools/shared/model";
import * as Cache from "effect/Cache";
+import * as DateTime from "effect/DateTime";
import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
import * as Fiber from "effect/Fiber";
@@ -200,6 +201,61 @@
}),
).pipe(Effect.provide(layerAlwaysRunTest)),
+ it.effect("re-reads cached usage on an explicit refresh once the reading passes the floor", () =>
+ Effect.scoped(
+ Effect.gen(function* () {
+ const calls = yield* Ref.make(0);
+ const cache = yield* Cache.makeWith(
+ () =>
+ Effect.gen(function* () {
+ const count = yield* Ref.updateAndGet(calls, (count) => count + 1);
+ const checkedAt = DateTime.formatIso(yield* DateTime.now);
+ return {
+ ...refreshedSnapshot,
+ usageLimits: {
+ checkedAt,
+ windows: [
+ {
+ id: "five_hour",
+ kind: "session",