1512
1513
setSubagentCopilotCredits(subagentCallId: string, copilotCredits: number): void {
1514
>
const currentCredits = this._subagentCopilotCredits.get(subagentCallId);
chatModel.ts
1515
>
if (!Number.isFinite(copilotCredits) || copilotCredits < 0 || (currentCredits !== undefined && copilotCredits <= currentCredits)) {
1516
>
return;
1517
>
}
1518
>
this._subagentCopilotCredits.set(subagentCallId, copilotCredits);
1519
>
const usage = this._parentUsage ?? { kind: 'usage', promptTokens: 0, completionTokens: 0 };
1520
>
this._setUsage(this._withSubagentCopilotCredits(usage), false);
1521
>
}
1522
1523
private _withSubagentCopilotCredits(usage: IChatUsage): IChatUsage {
1524
let subagentCopilotCredits = 0;
1525
for (const credits of this._subagentCopilotCredits.values()) {
1527
>
}
1528
return subagentCopilotCredits === 0
1529
? usage
1530
>
: { ...usage, copilotCredits: (usage.copilotCredits ?? 0) + subagentCopilotCredits };
chatModel.ts
1531
}
1532