fix: compaction safeguard falls through when ctx.model is unavailable
When extensionRunner.initialize() is not called (e.g. in embedded runner mode), ctx.model resolves to undefined because the default getModel returns undefined. Previously this caused the safeguard to return a fallback summary with no actual content, effectively discarding all conversation history on every compaction. Instead of returning an empty fallback, return undefined so the built-in compaction code in AgentSession handles summarization. The built-in path correctly accesses the model via this.model (AgentSession.agent.state.model) and produces a proper summary. Same fix applied to the apiKey null case -- falling through is safer than producing an empty summary that causes cascading re-compactions.
This commit is contained in:
parent
4583f88626
commit
a1a268c222
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user