fix(core): honor Codex input limits

This commit is contained in:
Kit Langton 2026-07-26 17:29:43 +00:00
commit b1a61aaf55
10 changed files with 112 additions and 15 deletions

View file

@ -29,9 +29,10 @@ export function contextUsage(
last.tokens.input + last.tokens.output + last.tokens.reasoning + last.tokens.cache.read + last.tokens.cache.write
if (tokens <= 0) return
const model = models?.find((model) => model.providerID === last.model.providerID && model.id === last.model.id)
const limit = model?.limit.input ?? model?.limit.context
return {
tokens,
percent: model?.limit.context ? Math.round((tokens / model.limit.context) * 100) : undefined,
percent: limit ? Math.round((tokens / limit) * 100) : undefined,
}
}