fix(ollama): set ContextSize via the embedded LLMConfig so the package builds#11049
Merged
Conversation
…e builds The num_ctx clamping specs added in #11032 construct their fixture with `config.ModelConfig{ContextSize: &existing}`, but ContextSize is not a direct field of ModelConfig: it belongs to LLMConfig, which ModelConfig embeds inline. Go allows reading a promoted field but not setting one in a composite literal, so the test file has never compiled: helpers_internal_test.go:33:31: unknown field ContextSize in struct literal of type "github.com/mudler/LocalAI/core/config".ModelConfig This broke `make lint` on master from bf19758 onward, and because the typecheck failure takes down the whole package it also reds tests-linux and tests-apple on every PR branched after that commit. Use the same literal form the rest of the tree already uses for this field (see core/backend/options_internal_test.go). Worth noting the specs were not merely uncompiled but inert: #11032 is a DoS fix (an unauthenticated client raising the context ceiling drives KV-cache allocation), and its regression guard was never actually running. Verified the restored specs are functional by stubbing out the ceiling clamp, which fails the "does not let an oversized num_ctx raise an existing context ceiling" spec as intended. Assisted-by: Claude Code:claude-opus-4-8[1m] [Read] [Edit] [Bash] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
make linthas been failing onmastersince bf19758, and takestests-linux/tests-appledown with it on every PR branched after that commit:ContextSizeis not a direct field ofModelConfig. It lives onLLMConfig(core/config/model_config.go:1059), whichModelConfigembeds inline (core/config/model_config.go:106). Go permits reading a promoted field but not setting one in a composite literal, soconfig.ModelConfig{ContextSize: &existing}has never compiled.Master lint history pins it exactly:
48b7d6d8fbf19758e0(#11032)Fix
Use the literal form already used everywhere else in the tree for this field (see
core/backend/options_internal_test.go:301):Two lines, test-only. No production code touched.
Why this matters beyond a green build
The specs were not merely uncompiled, they were inert. #11032 is a DoS fix: an unauthenticated client raising the context ceiling drives KV-cache allocation, and an oversized
num_ctxcan trigger a catastrophic OOM. The regression guard it shipped was never executing.Confirmed the restored specs are functional rather than vacuous by stubbing out the ceiling clamp in
applyOllamaOptions, which fails the intended spec:The coverage gate corroborates it: coverage rose 54.2% -> 55.3% from this two-line change alone, because a whole package's tests started running.
Verification
go vet ./core/http/endpoints/ollama/- cleango test -count=1 ./core/http/endpoints/ollama/- ok, 5/5num_ctxspecs executemake lint(full repo) - 0 issues--no-verifyNote on process
bf19758 merged carrying a self-contained compile error in its own new test file, so its PR either never ran lint or merged on a stale check. May be worth a look at why the gate allowed it.
Unrelated CI noise (no action needed here)
While diagnosing I checked the other red PRs:
v0.3.0.dev20260722081849#11034, chore: ⬆️ Update CrispStrobe/CrispASR to3ab5f4ac13685966b47cc75dc7fd02f3c4a51beb#11035, chore: ⬆️ Update localai-org/ced.cpp todb5aae02973a745722d6fbd2157cab1999106777#11037, chore: ⬆️ Update leejet/stable-diffusion.cpp to8a51eb92848c1327a5aaeff5ad81a7a9a2435255#11038, chore: ⬆️ Update ServeurpersoCom/qwentts.cpp to82cd05b9f3a175612dc89fd6943e610fab096ef5#11039, chore: ⬆️ Update ServeurpersoCom/omnivoice.cpp to4f33af825d66e6ef1cb185e87b4589cacf747291#11040 are stale. Those branches sit on5c96e097b, before thegallery/index.yamlindentation fix. Running yamllint 1.33 against current master'sgallery/gives zero errors. They need a re-run/rebase, not a code change.object Result can't be used in 'await' expression) is from Jul 21 22:12 and the extras workflow is green on master since. Likely a transient unpinned-dep issue; worth a re-run before treating it as real.