Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(codex): treat usage-limit stops as quota, not errors #9236

Closedvitalyiegorov(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/9236/headopened View on GitHub

Showing 3 changed files with 210 additions and 2 deletions.

x
0 of 3 viewed, 3 left
169 additions and 0 deletionsapps/server/src/provider/Layers/CodexAdapter.test.tsModified
View file
@@ -970,6 +970,175 @@
}),
​
+ const usageLimitErrorCases = [
+ ["plan-limit", "You've hit your usage limit. Your limit will reset at 6:00 PM."],
+ [
+ "workspace-credits",
+ "Your workspace is out of credits. Ask your workspace owner to refill in order to continue.",
+ ],
+ ] as const;
+​
+ for (const [label, message] of usageLimitErrorCases) {
+ it.effect(
+ `maps a ${label} usage-limit error to runtime.warning with the provider message`,
+ () =>
+ Effect.gen(function* () {
+ const { adapter, runtime } = yield* startLifecycleRuntime();
+ const firstEventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(
+ Effect.forkChild,
+ );
+​
+ yield* runtime.emit({
+ id: asEventId(`evt-usage-limit-${label}`),
+ kind: "notification",
+ provider: ProviderDriverKind.make("codex"),
+ threadId: asThreadId("thread-1"),
+ createdAt: "2026-01-01T00:00:00.000Z",
+ method: "error",
+ turnId: asTurnId("turn-1"),