Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(server): compact idle Claude threads before the prompt cache expires (beta) #21682

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/21682/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 14 changed files with 34 additions and 2 deletions (loading 12).

x
0 of 14 viewed, 14 left
15 additions and 0 deletionsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsModified
View file
@@ -996,6 +996,21 @@
undefined,
});
+​
+ it("dates cache expiry from the request start, not the response end", () => {
+ const usage = ClaudeAdapterV2.claudeProviderTurnTokenUsage(
+ {
+ input_tokens: 1,
+ output_tokens: 1,
+ cache_creation: { ephemeral_1h_input_tokens: 0, ephemeral_5m_input_tokens: 300 },
+ },
+ CLAUDE_TEST_MODEL_SELECTION,
+ "2026-08-29T00:03:00.000Z",
+ "",
+ DateTime.makeUnsafe("2026-08-29T00:00:00.000Z"),
+ );
+ assert.strictEqual(usage.promptCacheExpiresAt, "2026-08-29T00:05:00.000Z");
+ });
describe("ClaudeAdapterV2 session permissions", () => {
19 additions and 2 deletionsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsModified
View file
@@ -236,11 +236,17 @@
modelSelection: ModelSelection,
updatedAt: string,
autoCompactWindow = "",