fix(ui): context stale in prompt input (#12695)

This commit is contained in:
Adam
2026-02-08 06:36:53 -06:00
committed by GitHub
parent 4187a5fe7f
commit 7c6b8d7a8a
2 changed files with 6 additions and 17 deletions

View File

@@ -34,8 +34,6 @@ type Metrics = {
context: Context | undefined
}
const cache = new WeakMap<Message[], WeakMap<Provider[], Metrics>>()
const tokenTotal = (msg: AssistantMessage) => {
return msg.tokens.input + msg.tokens.output + msg.tokens.reasoning + msg.tokens.cache.read + msg.tokens.cache.write
}
@@ -80,15 +78,5 @@ const build = (messages: Message[], providers: Provider[]): Metrics => {
}
export function getSessionContextMetrics(messages: Message[], providers: Provider[]) {
const byProvider = cache.get(messages)
if (byProvider) {
const hit = byProvider.get(providers)
if (hit) return hit
}
const value = build(messages, providers)
const next = byProvider ?? new WeakMap<Provider[], Metrics>()
next.set(providers, value)
if (!byProvider) cache.set(messages, next)
return value
return build(messages, providers)
}