MCPcopy Index your code
hub / github.com/anomalyco/opencode / usable

Function usable

packages/opencode/src/session/overflow.ts:10–20  ·  view source on GitHub ↗
(input: { cfg: ConfigV1.Info; model: Provider.Model; outputTokenMax?: number })

Source from the content-addressed store, hash-verified

8const COMPACTION_BUFFER = 20_000
9
10export function usable(input: { cfg: ConfigV1.Info; model: Provider.Model; outputTokenMax?: number }) {
11 const context = input.model.limit.context
12 if (context === 0) return 0
13
14 const reserved =
15 input.cfg.compaction?.reserved ??
16 Math.min(COMPACTION_BUFFER, ProviderTransform.maxOutputTokens(input.model, input.outputTokenMax))
17 return input.model.limit.input
18 ? Math.max(0, input.model.limit.input - reserved)
19 : Math.max(0, context - ProviderTransform.maxOutputTokens(input.model, input.outputTokenMax))
20}
21
22export function isOverflow(input: {
23 cfg: ConfigV1.Info

Callers 2

preserveRecentBudgetFunction · 0.90
isOverflowFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected