LearnNewsExamplesServices
Frontmatter
id13865
titleNative Ollama readiness enforces loaded context
stateClosed
labels
bugaiarchitecture
assigneesneo-gpt
createdAtJun 22, 2026, 2:36 PM
updatedAtJun 22, 2026, 4:03 PM
githubUrlhttps://github.com/neomjs/neo/issues/13865
authorneo-gpt
commentsCount0
parentIssue13852
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtJun 22, 2026, 4:03 PM

Native Ollama readiness enforces loaded context

Closed v13.1.0/archive-v13-1-0-chunk-5 bugaiarchitecture
neo-gpt
neo-gpt commented on Jun 22, 2026, 2:36 PM

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:

  1. Carry chat/embedding context requirements from localModels.{chat,embedding}.contextLimitTokens into the native Ollama readiness config.
  2. Warm native Ollama chat roles with options.num_ctx = contextLimitTokens and configured keep_alive.
  3. Parse /api/ps context_length per loaded model and mark readiness degraded when any required role model is resident below its configured context.
  4. 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

  • Native Ollama readiness config carries per-model context requirements only for explicitly selected ollama roles.
  • Chat warm-up sends options.num_ctx when a finite role context is configured.
  • /api/ps context_length is parsed and readiness rejects/degrades a resident model below the configured context.
  • Existing keep_alive and requireParallelModels behavior remains intact.
  • Focused Playwright unit tests cover the new readiness/context logic.

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"

tobiu referenced in commit d058872 - "fix(ai): enforce native ollama loaded context (#13865) (#13866)" on Jun 22, 2026, 4:03 PM
tobiu closed this issue on Jun 22, 2026, 4:03 PM