Context
Parent #13852 remains too broad to close from one PR after the cloud clarification and #13862/#13863 compose-cap slice. Cloud compose now owns the server-level local-model envelope; the remaining actionable gap is local-dev native Ollama readiness: when a role is explicitly routed to ollama, the orchestrator/readiness layer must not accept a resident model loaded at Ollama's default context.
Live latest-open sweep: checked the latest 20 open issues on 2026-06-22T12:35Z; #13852 is the broad parent, #13851 is the LM Studio sibling, and no narrower native-Ollama context_length/num_ctx child exists. A2A in-flight sweep: checked latest 30 messages; no competing lane-claim for this narrow child.
The Problem
#13851 proved the failure class: a model can be resident but loaded at a context window far below Neo's configured localModels.*.contextLimitTokens, starving REM/tri-vector extraction while readiness appears green. Native Ollama has the same class of hazard unless readiness enforces the loaded context.
Current source reality:
ai/services/graph/providerReadinessHelper.mjs already has native Ollama role selection and warm/readiness helpers.
ai/daemons/orchestrator/taskDefinitions.mjs only has orchestrator-owned LMS supervision/preload; no native Ollama supervised task exists yet.
- Official Ollama API docs show
/api/chat accepts runtime options, including generation/runtime controls, and /api/ps reports loaded context_length for running models.
Architectural Reality
This is not a cloud compose fix. It is local-dev native-Ollama readiness parity with the LM Studio path:
- role selection must stay provider-selector driven (
modelProvider, graphProvider, embeddingProvider), not inferred from non-null ollama leaves;
- warm-up must use native Ollama endpoints, not the OpenAI-compatible LMS path;
- readiness must verify the observed loaded model state from
/api/ps, not just issue a warm call.
The Fix
Extend the native Ollama readiness slice so it can enforce configured context:
- Carry chat/embedding context requirements from
localModels.{chat,embedding}.contextLimitTokens into the native Ollama readiness config.
- Warm native Ollama chat roles with
options.num_ctx = contextLimitTokens and configured keep_alive.
- Parse
/api/ps context_length per loaded model and mark readiness degraded when any required role model is resident below its configured context.
- Cover the behavior with focused unit tests in the existing provider-readiness test surface.
This ticket intentionally does not add a full ollama serve supervised task. That is a sibling slice under #13852 because it changes process supervision/config topology. This child closes only the loaded-context enforcement gap in the already-existing native readiness helper.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback / Edge Case |
Docs |
Evidence |
buildOllamaReadinessConfig(config) |
#13852, providerReadinessHelper.mjs, ai/config.template.mjs local model caps |
Returns selected native-Ollama roles plus per-model context requirements derived from role selectors and localModels caps |
Missing/non-finite context cap is omitted; non-Ollama roles stay excluded |
JSDoc update if shape changes |
Unit test proves Ollama roles receive context requirements while OpenAI-compatible roles do not |
warmOllamaRoleModel() |
Ollama API /api/chat request body supports options; #13851 context-starvation class |
Chat warm-up sends options.num_ctx when a finite context requirement exists; embedding warm-up stays native /api/embed with keep_alive |
Missing context leaves payload unchanged; warm failure remains degraded/failed per existing helper semantics |
JSDoc update |
Unit test captures POST payload for chat vs embedding |
ensureOllamaModelsReady() |
Ollama API /api/ps response includes loaded context_length |
Readiness requires each required model to be resident and, when a configured context exists, loaded at context_length >= required |
If resident below required, return degraded envelope under allowPartial; throw actionable error otherwise |
JSDoc update |
Unit test covers below-context resident model and sufficient-context model |
Decision Record impact
Aligned with ADR-0019 (AiConfig provider SSOT) and ADR-0020 (orchestrator/Agent OS substrate). No ADR amendment required; this is a readiness enforcement leaf under #13852.
Acceptance Criteria
Out of Scope
- Starting or supervising
ollama serve as an orchestrator child task.
- Cloud compose
OLLAMA_CONTEXT_LENGTH / resource caps; handled by #13862/#13863.
- LM Studio enforcement; tracked by #13851.
- Live native-Ollama heavy-session proof; this helper-level PR is unit-testable without requiring a local Ollama daemon.
Related
Parent: #13852. Sibling: #13851. Cloud prevention slice: #13862 / PR #13863. Root system-drain context: #13624 / #13750.
Release classification: boardless; local-dev native-Ollama hardening, not a v13 release blocker.
Origin Session ID: b9a8f817-9a9e-4243-abfb-62e762a94964
Retrieval Hint: "native Ollama readiness context_length num_ctx #13852 providerReadinessHelper"
Context
Parent #13852 remains too broad to close from one PR after the cloud clarification and #13862/#13863 compose-cap slice. Cloud compose now owns the server-level local-model envelope; the remaining actionable gap is local-dev native Ollama readiness: when a role is explicitly routed to
ollama, the orchestrator/readiness layer must not accept a resident model loaded at Ollama's default context.Live latest-open sweep: checked the latest 20 open issues on 2026-06-22T12:35Z; #13852 is the broad parent, #13851 is the LM Studio sibling, and no narrower native-Ollama
context_length/num_ctxchild exists. A2A in-flight sweep: checked latest 30 messages; no competing lane-claim for this narrow child.The Problem
#13851 proved the failure class: a model can be resident but loaded at a context window far below Neo's configured
localModels.*.contextLimitTokens, starving REM/tri-vector extraction while readiness appears green. Native Ollama has the same class of hazard unless readiness enforces the loaded context.Current source reality:
ai/services/graph/providerReadinessHelper.mjsalready has native Ollama role selection and warm/readiness helpers.ai/daemons/orchestrator/taskDefinitions.mjsonly has orchestrator-owned LMS supervision/preload; no native Ollama supervised task exists yet./api/chataccepts runtimeoptions, including generation/runtime controls, and/api/psreports loadedcontext_lengthfor running models.Architectural Reality
This is not a cloud compose fix. It is local-dev native-Ollama readiness parity with the LM Studio path:
modelProvider,graphProvider,embeddingProvider), not inferred from non-nullollamaleaves;/api/ps, not just issue a warm call.The Fix
Extend the native Ollama readiness slice so it can enforce configured context:
localModels.{chat,embedding}.contextLimitTokensinto the native Ollama readiness config.options.num_ctx = contextLimitTokensand configuredkeep_alive./api/pscontext_lengthper loaded model and mark readiness degraded when any required role model is resident below its configured context.This ticket intentionally does not add a full
ollama servesupervised task. That is a sibling slice under #13852 because it changes process supervision/config topology. This child closes only the loaded-context enforcement gap in the already-existing native readiness helper.Contract Ledger Matrix
buildOllamaReadinessConfig(config)providerReadinessHelper.mjs,ai/config.template.mjslocal model capslocalModelscapswarmOllamaRoleModel()/api/chatrequest body supportsoptions; #13851 context-starvation classoptions.num_ctxwhen a finite context requirement exists; embedding warm-up stays native/api/embedwith keep_aliveensureOllamaModelsReady()/api/psresponse includes loadedcontext_lengthcontext_length >= requiredallowPartial; throw actionable error otherwiseDecision Record impact
Aligned with ADR-0019 (AiConfig provider SSOT) and ADR-0020 (orchestrator/Agent OS substrate). No ADR amendment required; this is a readiness enforcement leaf under #13852.
Acceptance Criteria
ollamaroles.options.num_ctxwhen a finite role context is configured./api/pscontext_lengthis parsed and readiness rejects/degrades a resident model below the configured context.keep_aliveandrequireParallelModelsbehavior remains intact.Out of Scope
ollama serveas an orchestrator child task.OLLAMA_CONTEXT_LENGTH/ resource caps; handled by #13862/#13863.Related
Parent: #13852. Sibling: #13851. Cloud prevention slice: #13862 / PR #13863. Root system-drain context: #13624 / #13750.
Release classification: boardless; local-dev native-Ollama hardening, not a v13 release blocker.
Origin Session ID: b9a8f817-9a9e-4243-abfb-62e762a94964
Retrieval Hint: "native Ollama readiness context_length num_ctx #13852 providerReadinessHelper"