fix(repo): restore gate after upstream drift

This commit is contained in:
Peter Steinberger
2026-03-27 02:56:23 +00:00
parent f6de4cd766
commit 158c4c1f4f
2 changed files with 24 additions and 3 deletions

View File

@@ -208,6 +208,22 @@ export function isOversizedForSummary(msg: AgentMessage, contextWindow: number):
return tokens > contextWindow * 0.5;
}
function withSummaryHeaders(
model: NonNullable<ExtensionContext["model"]>,
headers?: Record<string, string>,
): NonNullable<ExtensionContext["model"]> {
if (!headers || Object.keys(headers).length === 0) {
return model;
}
return {
...model,
headers: {
...model.headers,
...headers,
},
};
}
async function summarizeChunks(params: {
messages: AgentMessage[];
model: NonNullable<ExtensionContext["model"]>;
@@ -231,12 +247,13 @@ async function summarizeChunks(params: {
params.customInstructions,
params.summarizationInstructions,
);
const model = withSummaryHeaders(params.model, params.headers);
for (const chunk of chunks) {
summary = await retryAsync(
() =>
generateSummary(
chunk,
params.model,
model,
params.reserveTokens,
params.apiKey,
params.signal,

View File

@@ -614,8 +614,12 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
return { cancel: true };
}
const apiKey = await ctx.modelRegistry.getApiKey(model);
if (!apiKey) {
const apiKey = (await ctx.modelRegistry.getApiKey(model)) ?? "";
const headers =
model.headers && typeof model.headers === "object" && !Array.isArray(model.headers)
? model.headers
: undefined;
if (!apiKey && !headers) {
log.warn(
"Compaction safeguard: no request auth available; cancelling compaction to preserve history.",
);