From 5dc190ee63174be71208609309f0b36a5fe070e0 Mon Sep 17 00:00:00 2001 From: weichen Date: Sat, 3 Oct 2026 17:28:40 +0000 Subject: [PATCH] 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 --- model.go | 2 ++ ts/types.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/model.go b/model.go index b67a6fc..c71f6b1 100644 --- a/model.go +++ b/model.go @@ -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"` } // ---- 工件 ---- diff --git a/ts/types.ts b/ts/types.ts index 165c1f4..becbeb6 100644 --- a/ts/types.ts +++ b/ts/types.ts @@ -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 { -- 2.54.0