fix: bind observed models and calibrate every model dispatch budget

This commit is contained in:
Agent Workbench Dev
2026-11-02 20:50:42 +08:00
parent 30c318bf20
commit bb45dabac4
23 changed files with 526 additions and 29 deletions
+2 -1
View File
@@ -209,7 +209,7 @@ export class Store extends EventEmitter {
if (plan.workerDispatchedAt && !plan.workerUsageAccounted && !plan.engineStepOnly) {
const run = this.core.run.get(plan.runId);
if (run && this.core.task.get(run.taskId)?.workerId) {
this.recordResponse(session, run, null, plan.estimatedInputTokens + (run.model.maxOutputTokens ?? 2048));
this.recordResponse(session, run, null, plan.tokenReservation?.reservedTokens??plan.estimatedInputTokens + (run.model.maxOutputTokens ?? 2048));
plan.workerUsageAccounted = true; plan.workerUsageRecovered = true; changed = true;
}
}
@@ -553,6 +553,7 @@ export class Store extends EventEmitter {
model: receipt.model, endpoint: receipt.endpoint, protocol: receipt.protocol,
startedAt: receipt.startedAt, finishedAt: receipt.finishedAt, outcome: receipt.outcome,
usageStatus: receipt.usage ? 'reported' : 'unknown', usage: receipt.usage ?? null,
...(receipt.localEstimate?{localEstimate:structuredClone(receipt.localEstimate)}:{}),
estimatedUnknownTokens: receipt.usage ? 0 : Math.max(0, Math.ceil(estimate)) });
this.recordResponse(session, run, receipt.usage, estimate);
this.save(session, { type: 'model.consumption', detail: { attemptId: receipt.attemptId, usageStatus: receipt.usage ? 'reported' : 'unknown' } });