Record the model that served a run's usage

Why: a fallback chain can answer with a different model than the one that was requested, and usage has to name the model that actually served.
Evidence: go test .
Impact: the field is omitted when empty, so existing usage JSON stays the same.
Refs: feature/durable-rewind
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-03 17:28:40 +00:00
co-authored by Cursor
parent b7e5baf15c
commit 5dc190ee63
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -201,6 +201,8 @@ type Usage struct {
TotalTokens int `json:"totalTokens"`
DurationMs float64 `json:"durationMs"`
ToolCalls int `json:"toolCalls"`
// Model 是实际给出这段用量的模型。空表示当时没有记录。
Model string `json:"model,omitempty"`
}
// ---- 工件 ----
+1
View File
@@ -54,6 +54,7 @@ export type RunPhase = 'thinking' | 'acting' | 'responding' | 'finalizing' | 'do
export interface Usage {
promptTokens: number; completionTokens: number; totalTokens: number;
durationMs: number; toolCalls: number;
model?: string;
}
export interface Run {