@devries-cameron20 / t3code-1 / commits / 255ac27d52
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Claude limits load again for users with large transcript histories (#16358)

The Claude capabilities probe now asks for usage with skipBehaviors, so it no longer scans every local transcript and misses its 4 s deadline. Takes over #14456. Co-authored-by: Ashkaan <a@ashkaan.me>

Theo Browne committed Oct 5, 2026 at 21:28 UTC 255ac27d5200b01c50acef105ab0ec8bb6ab8345
2 files changed +25 -1
apps/server/src/provider/ClaudeCapabilitiesProbe.test.ts
+22
@@ -353,3 +353,25 @@ it.effect("preserves initialized capabilities when optional usage times out", ()
353 assert.equal(abortSignal?.aborted, true);
354 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
355 );
356 +
357 +it.effect("asks for usage without the local transcript scan", () =>
358 + Effect.gen(function* () {
359 + let usageOptions: unknown;
360 + const query = vi.spyOn(ClaudeSdk, "query").mockImplementation(
361 + () =>
362 + ({
363 + initializationResult: async () => ({
364 + account: { email: "dev@example.com", subscriptionType: "max", tokenSource: "oauth" },
365 + commands: [],
366 + }),
367 + usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET: async (options?: unknown) => {
368 + usageOptions = options;
369 + return { rate_limits_available: true, rate_limits: null };
370 + },
371 + }) as unknown as ReturnType<typeof ClaudeSdk.query>,
372 + );
373 + yield* Effect.addFinalizer(() => Effect.sync(() => query.mockRestore()));
374 + yield* probeClaudeCapabilities(decodeClaudeSettings({ binaryPath: "claude" }));
375 + assert.deepEqual(usageOptions, { skipBehaviors: true });
376 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
377 +);
apps/server/src/provider/ClaudeProvider.ts
+3 -1
@@ -367,9 +367,11 @@ const probeClaudeCapabilities = (
367 Effect.flatMap(({ q, init }) =>
368 Effect.gen(function* () {
369 // Usage has its own deadline so a slow optional request cannot discard initialization.
370 + // Only the rate limits are read, so skip the local transcript scan that fills
371 + // `behaviors`: with a few GB of transcripts it outlasts the deadline.
372 const usageResult = includeUsage
373 ? yield* Effect.tryPromise(() =>
372 - q.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET(),
374 + q.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET({ skipBehaviors: true }),
375 ).pipe(Effect.timeout(DEFAULT_TIMEOUT_MS), Effect.result)
376 : undefined;
377 const usage =