MCPcopy Create free account
hub / github.com/codehamr/codehamr / ResponseReserve

Function ResponseReserve

internal/ctx/ctx.go:74–79  ·  view source on GitHub ↗

ResponseReserve is the slice Budget keeps free for the model's response. Scales as ctxSize/8 so reasoning models get room (262k→32k, 1M→125k), floored at 8k so small-ctx profiles don't collapse history to nothing.

(ctxSize int)

Source from the content-addressed store, hash-verified

72// budgetHeadroomDivisor cuts the history budget by 1/this (10%) below the
73// declared window. The char/4 Tokens heuristic UNDERcounts code- and JSON-heavy
74// histories (the real tokenizer emits more per char), so packing to the literal
75// ceiling risks the true token count spilling past the window: on Ollama a
76// silent front-truncation that drops the system prompt and the anchored task, on
77// llama.cpp a hard 400. The margin keeps an honest context_size safely in-window.
78const budgetHeadroomDivisor = 10
79
80// ResponseReserve is the slice Budget keeps free for the model's response.
81// Scales as ctxSize/8 so reasoning models get room (262k→32k, 1M→125k),
82// floored at 8k so small-ctx profiles don't collapse history to nothing.

Callers 2

BudgetFunction · 0.85

Calls

no outgoing calls

Tested by 1