MCPcopy Index your code
hub / github.com/codehamr/codehamr / ContextWindowFromHeaders

Function ContextWindowFromHeaders

internal/cloud/cloud.go:118–128  ·  view source on GitHub ↗

ContextWindowFromHeaders reads X-Context-Window. Returns 0 when missing, malformed, or out of sane range; the caller reads 0 as "use the fallback". Local Ollama never sets it, so it keeps its config.yaml value.

(h http.Header)

Source from the content-addressed store, hash-verified

116// malformed, or out of sane range; the caller reads 0 as "use the fallback".
117// Local Ollama never sets it, so it keeps its config.yaml value.
118func ContextWindowFromHeaders(h http.Header) int {
119 raw := h.Get(headerCtxWindow)
120 if raw == "" {
121 return 0
122 }
123 n, err := strconv.Atoi(raw)
124 if err != nil || n < ctxWindowMin || n > ctxWindowMaxSane {
125 return 0
126 }
127 return n
128}

Callers 3

ProbeMethod · 0.92
runMethod · 0.92

Calls

no outgoing calls

Tested by 1