Skip to content

Commit 58270ec

Browse files
committed
fix(agents): move ensureContextWindowCacheLoaded to top of if(ref) to cover all resolver paths
1 parent 44ffb37 commit 58270ec

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/agents/context.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ export function resolveContextTokensForModel(params: {
391391
});
392392
const explicitProvider = params.provider?.trim();
393393
if (ref) {
394+
// Kick off background model discovery for read-only paths that
395+
// otherwise never trigger async loading (cfg + allowAsyncLoad: false).
396+
// Move this to the top of if(ref) so discovery fires for ALL resolvable
397+
// model references, not just the fallback path.
398+
void ensureContextWindowCacheLoaded();
399+
394400
if (explicitProvider) {
395401
const fixedContextWindow = resolveAnthropicFixedContextWindow(ref.provider, ref.model);
396402
if (fixedContextWindow !== undefined) {
@@ -414,9 +420,6 @@ export function resolveContextTokensForModel(params: {
414420
return configuredWindow;
415421
}
416422
}
417-
// Kick off background model discovery for read-only paths that
418-
// otherwise never trigger async loading (cfg + allowAsyncLoad: false).
419-
void ensureContextWindowCacheLoaded();
420423
}
421424

422425
// When provider is explicitly given and the model ID is bare (no slash),

0 commit comments

Comments
 (0)