fix(coding-agent): resolve models.json auth per request closes #1835
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user