fix(usage): dedupe streaming request-details log entries
handleStreamingResponse and buildOnStreamComplete each generated their own streamDetailId for what should be one logical record — the placeholder row (0 tokens) and the final row (real usage) never shared an id, so the DB's ON CONFLICT(id) upsert never merged them, leaving a permanent 0-token stub for every streaming request. Share the id from buildOnStreamComplete with handleStreamingResponse so both writes hit the same row. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -326,8 +326,8 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
|
||||
}
|
||||
|
||||
// Streaming response
|
||||
const { onStreamComplete } = buildOnStreamComplete({ ...sharedCtx });
|
||||
return handleStreamingResponse({ ...sharedCtx, providerResponse, sourceFormat, targetFormat, userAgent, reqLogger, toolNameMap, streamController, onStreamComplete });
|
||||
const { onStreamComplete, streamDetailId } = buildOnStreamComplete({ ...sharedCtx });
|
||||
return handleStreamingResponse({ ...sharedCtx, providerResponse, sourceFormat, targetFormat, userAgent, reqLogger, toolNameMap, streamController, onStreamComplete, streamDetailId });
|
||||
}
|
||||
|
||||
export function isTokenExpiringSoon(expiresAt, bufferMs = 5 * 60 * 1000) {
|
||||
|
||||
Reference in New Issue
Block a user