fix(coding-agent): resolve models.json auth per request closes #1835

This commit is contained in:
Mario Zechner
2026-03-27 00:19:00 +01:00
parent fb10d9aef9
commit 7a786d88aa
18 changed files with 396 additions and 228 deletions

View File

@@ -31,9 +31,13 @@ export default function (pi: ExtensionAPI) {
return;
}
// Resolve API key for the summarization model
const apiKey = await ctx.modelRegistry.getApiKey(model);
if (!apiKey) {
// Resolve request auth for the summarization model
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
if (!auth.ok) {
ctx.ui.notify(`Compaction auth failed: ${auth.error}`, "warning");
return;
}
if (!auth.apiKey) {
ctx.ui.notify(`No API key for ${model.provider}, using default compaction`, "warning");
return;
}
@@ -83,7 +87,16 @@ ${conversationText}
try {
// Pass signal to honor abort requests (e.g., user cancels compaction)
const response = await complete(model, { messages: summaryMessages }, { apiKey, maxTokens: 8192, signal });
const response = await complete(
model,
{ messages: summaryMessages },
{
apiKey: auth.apiKey,
headers: auth.headers,
maxTokens: 8192,
signal,
},
);
const summary = response.content
.filter((c): c is { type: "text"; text: string } => c.type === "text")