fix(server): refresh Claude context meter after compact #7249
Closedmatsvarn(GitHub profile, opens in a new tab)wants to merge 11 commits into
main fromrefs/pull/7249/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 4559OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -4536,3 +4556,4 @@45364556 });45374557 context.currentApiModelId = apiModelId;45384558 }4559+ context.lastKnownContextWindow = selectedClaudeContextWindow(modelSelection);
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 2510Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2312,3 +2449,8 @@23122449 : {}),23132450 }23142451 : undefined);2452+ const usageObservation: ClaudeTokenUsageObservation = contextUsageObservation ?? {2453+ modelRevision,2454+ usage: usageSnapshot,2455+ ...(resultContextWindow !== undefined ? { contextWindow: resultContextWindow } : {}),2456+ };apps/server/src/provider/Layers/ClaudeAdapter.ts line 3876OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3709,0 +3856,21 @@3856+ }3857+ const result = yield* Effect.try({3858+ try: () => context.query.close(),3859+ catch: (cause) =>3860+ new ProviderAdapterProcessError({3861+ provider: PROVIDER,3862+ threadId: context.session.threadId,3863+ detail: "Failed to close Claude runtime query.",3864+ cause,3865+ }),3866+ }).pipe(Effect.result);3867+ if (result._tag === "Success" && !terminalOnCloseFailure) {3868+ yield* Deferred.succeed(context.stopSignal, undefined);3869+ }3870+ return result;3871+ }),3872+ );3873+ if (closeResult._tag === "Failure") {3874+ if (!terminalOnCloseFailure) {3875+ context.stopped = false;3876+ return yield* closeResult.failure;
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 3890OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -3709,0 +3870,21 @@3870+ return undefined;3871+ } catch (cause) {3872+ return new ProviderAdapterProcessError({3873+ provider: PROVIDER,3874+ threadId: context.session.threadId,3875+ detail: "Failed to close Claude runtime query.",3876+ cause,3877+ });3878+ } finally {3879+ context.stopInProgress = false;3880+ }3881+ });3882+ if (!error && !terminalOnCloseFailure) {3883+ yield* Deferred.succeed(context.stopSignal, undefined);3884+ }3885+ return error;3886+ }),3887+ );3888+ if (closeError) {3889+ if (!terminalOnCloseFailure) {3890+ return yield* closeError;
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 2509Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2312,3 +2453,10 @@23122453 : {}),23132454 }23142455 : undefined);2456+ const observationContextWindow = contextUsageObservation?.contextWindow ?? resultContextWindow;2457+ const usageObservation: ClaudeTokenUsageObservation = {2458+ modelRevision: contextUsageObservation?.modelRevision ?? modelRevision,2459+ usage: usageSnapshot,2460+ ...(observationContextWindow !== undefined2461+ ? { contextWindow: observationContextWindow }2462+ : {}),
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
9ab65d93-c034-4596-966c-57715190daf9You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.