This commit is contained in:
Han Xiao 2026-01-30 04:46:03 -07:00 committed by GitHub
commit 43de6bd3e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -148,26 +148,16 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
const model = ctx.model;
if (!model) {
return {
compaction: {
summary: fallbackSummary,
firstKeptEntryId: preparation.firstKeptEntryId,
tokensBefore: preparation.tokensBefore,
details: { readFiles, modifiedFiles },
},
};
// ctx.model may be undefined when extensionRunner.initialize() was not called
// (e.g. embedded runner mode). Fall through to built-in compaction which has
// correct model access via AgentSession.model.
return undefined;
}
const apiKey = await ctx.modelRegistry.getApiKey(model);
if (!apiKey) {
return {
compaction: {
summary: fallbackSummary,
firstKeptEntryId: preparation.firstKeptEntryId,
tokensBefore: preparation.tokensBefore,
details: { readFiles, modifiedFiles },
},
};
// Fall through to built-in compaction rather than producing an empty summary.
return undefined;
}
try {