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; const model = ctx.model;
if (!model) { if (!model) {
return { // ctx.model may be undefined when extensionRunner.initialize() was not called
compaction: { // (e.g. embedded runner mode). Fall through to built-in compaction which has
summary: fallbackSummary, // correct model access via AgentSession.model.
firstKeptEntryId: preparation.firstKeptEntryId, return undefined;
tokensBefore: preparation.tokensBefore,
details: { readFiles, modifiedFiles },
},
};
} }
const apiKey = await ctx.modelRegistry.getApiKey(model); const apiKey = await ctx.modelRegistry.getApiKey(model);
if (!apiKey) { if (!apiKey) {
return { // Fall through to built-in compaction rather than producing an empty summary.
compaction: { return undefined;
summary: fallbackSummary,
firstKeptEntryId: preparation.firstKeptEntryId,
tokensBefore: preparation.tokensBefore,
details: { readFiles, modifiedFiles },
},
};
} }
try { try {