File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ import { stripThinkTags } from "@/lib/analyze/sanitize";
2525import { extractStructuredFromProse } from "@/lib/analyze/proseToData" ;
2626import { sortRowsByDateLikeColumn } from "@/lib/analyze/sortByDate" ;
2727import { log } from "@/lib/log" ;
28- import { optionalEnv } from "@/lib/utils" ;
2928
3029/**
3130 * Tools Kimi is allowed to see on the Analyze surface. Doc-grounded
@@ -260,7 +259,7 @@ export async function* runAnalyzeAgent(
260259 inputTokens : ev . inputTokens ,
261260 outputTokens : ev . outputTokens ,
262261 exact : ev . exact ,
263- model : optionalEnv ( "HEROKU_INFERENCE_ONYX_MODEL_ID" ) || "kimi-k2-thinking" ,
262+ model : ev . model ,
264263 } ;
265264 }
266265 }
Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ import type {
2828 FirstPartyDcToolDef ,
2929} from "@/lib/mcp/firstPartyDataCloud" ;
3030import { stripThinkTags } from "@/lib/analyze/sanitize" ;
31- import { optionalEnv } from "@/lib/utils" ;
3231
3332// Soft budget: if the agent hasn't answered after N tool-call iterations
3433// we bail. Heroku router already stalls long requests — this keeps us well
@@ -223,7 +222,7 @@ export async function* runAskDataAgent(
223222 inputTokens : ev . inputTokens ,
224223 outputTokens : ev . outputTokens ,
225224 exact : ev . exact ,
226- model : optionalEnv ( "HEROKU_INFERENCE_ONYX_MODEL_ID" ) || "kimi-k2-thinking" ,
225+ model : ev . model ,
227226 } ;
228227 }
229228 }
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ export type HerokuInferenceEvent =
5151 | { type : "done" ; stopReason : string | null }
5252 | {
5353 type : "usage" ;
54+ model : string ;
5455 inputTokens : number ;
5556 outputTokens : number ;
5657 exact : boolean ;
@@ -297,15 +298,20 @@ export async function* streamHeroku(
297298 } ;
298299 }
299300
301+ // why: stamp the usage event with the tier's RESOLVED model id (from
302+ // clientFor) rather than letting callers guess — otherwise a tier served
303+ // by a non-Kimi backend would be mislabeled in the token-spend panel.
300304 yield usageAcc . exact
301305 ? {
302306 type : "usage" as const ,
307+ model : modelId ,
303308 inputTokens : usageAcc . inputTokens ,
304309 outputTokens : usageAcc . outputTokens ,
305310 exact : true ,
306311 }
307312 : {
308313 type : "usage" as const ,
314+ model : modelId ,
309315 inputTokens : estimateTokens (
310316 messages
311317 . map ( ( m ) =>
@@ -320,9 +326,6 @@ export async function* streamHeroku(
320326 } ;
321327
322328 yield { type : "done" , stopReason } ;
323- // Avoid "modelId was defined but unused" false-negative — it's surfaced
324- // on the caller via inferHeroku's result, not through the stream.
325- void modelId ;
326329}
327330
328331function safeParseJson ( s : string ) : unknown {
You can’t perform that action at this time.
0 commit comments