Skip to content

Lock llama.cpp path to Ministral 8B only; expose Ollama + OpenAI-compatible as open paths #1370

Closed

Description

@malibio

Context

NodeSpace has three inference paths:

  1. Local (llama.cpp / GGUF) — we control the prompt format, parser, and tool-call template end-to-end
  2. Ollama — user's own running instance, any model available locally
  3. OpenAI-compatible — user-supplied API key + base URL (any provider)

After matrix testing, only Ministral 8B achieves 12/12 on the agent tool-call matrix via the llama.cpp path. All other tested models fail.

Decision

  • Local path: expose only Ministral 8B (ministral-8b-q4km). No model picker — single download action. On machines with <16 GB RAM, show it greyed out with an explanation (not hidden).
  • Ollama path: auto-detected at localhost:11434; open model list from running instance.
  • OpenAI-compatible path: fully manual; user-created named configs.

UI: Model Picker Dropdown

Replaces the current two-step provider → model flow. Single dropdown in the AIChatNode header:

Local
  Ministral 8B  [download needed]     ← selectable; badge gone once downloaded
                                       ← greyed out + explanation if <16 GB RAM

Ollama (not running)                  ← greyed out header if not auto-detected
  Qwen 2.5 7B                         ← selectable; shown only if Ollama running
  Gemma 3 12B
  Mistral 7B

─────────────────────────────────────
My Anthropic Key                      ← user-named OpenAI-compat configs (selectable)
Work GPT-4

─────────────────────────────────────
Set up...                             ← opens Settings → AI Models tab in new app tab

Conversation lifecycle:

  • Model is per-AIChatNode; chosen before or at first message
  • Once first message is sent, dropdown becomes read-only (shows active model, no switching)
  • New conversations inherit the user's "default model" setting (configured in Settings)

Download flow (Local, first use):

  • Selecting Ministral 8B and sending → download starts automatically
  • Modal with progress bar appears during download
  • On completion, the message sends automatically

Low-RAM machines (<16 GB):

  • Local section is visible but greyed out
  • Tooltip/label explains: "Requires 16 GB RAM — use Ollama or an external provider"
  • Ollama and OpenAI-compatible remain available

Settings → AI Models (revamp)

Local

  • Shows Ministral 8B: status (Not downloaded / Downloading / Ready), download button, delete button, download progress bar
  • No other GGUF models exposed in this UI (catalog entries for other models remain in Rust for dev/CLI but are hidden from the frontend)

Ollama

OpenAI-compatible

  • Add / edit / remove named provider configs: Name, Base URL, API key
  • Each saved config appears as a selectable entry in the model picker

Default Model

  • Dropdown of all currently available models (same list as the picker)
  • Saved as the app-wide default for new AIChatNodes

Acceptance Criteria

  • Model picker dropdown replaces two-step provider → model flow in AIChatNode header
  • Local section shows only Ministral 8B; greyed out with explanation on <16 GB RAM machines
  • recommended_model_id() returns ministral-8b-q4km as the llama.cpp default
  • Ollama auto-detected at localhost:11434; section greyed out ("Ollama (not running)") if not detected
  • Ollama model list fetched live from running instance when dropdown opens
  • OpenAI-compatible named configs: add/edit/remove in Settings → AI Models
  • Named configs appear as selectable entries in the model picker
  • "Set up..." entry at bottom of picker opens Settings → AI Models tab in a new app tab
  • Model is locked per-AIChatNode after first message is sent (picker becomes read-only)
  • Default model setting in Settings → AI Models; new AIChatNodes inherit it
  • Download modal with progress bar when selecting an undownloaded local model and sending
  • Settings → AI Models: Local section with download/delete/progress for Ministral 8B only
  • Settings → AI Models: Ollama section shows running status + model list, or a clickable link to ollama.com if not detected
  • Non-Ministral catalog entries hidden from frontend (may remain in Rust for dev/CLI)
  • Matrix score remains 12/12 after changes (no prompt regressions)

Activity

  1. malibio commented on Jun 7, 2026

    @malibio
    CollaboratorAuthor

    Code Review — Ministral 8B 12/12 Fix (commits 7853c0f + 0b8e927)

    Review Type: Initial Review
    Commits reviewed: 7853c0f5 + 0b8e9273 (HEAD)
    Reviewer: Principal Engineer AI Reviewer


    Summary

    This changeset is a net positive and demonstrates disciplined, targeted problem-solving: a real behavioral regression (schema-creation retry loops, invisible freshly-created types) was diagnosed empirically via matrix testing, and fixed with minimum-viable targeted changes across five files. The guidance rules are logically sound, the context-injection timing fix is correct, and the filter coercion handles the model-output mismatch cleanly. The snake_case schema ID change is the appropriate greenfield call per CLAUDE.md.

    Recommendation: APPROVE with two improvements that should be addressed before the next feature build on top of this work.


    Findings

    Important Issues

    [Improvement] _history parameter is unused — dead parameter in build_workspace_context signature
    File: packages/daemon/src/services/local_agent_service.rs, function build_workspace_context (line ~1195)

    The parameter was introduced with the commit message "Pass prior_history to build_workspace_context before session creation so context is available from turn one", but the function signature receives _history: &[ChatMessage] and the body never reads it. The actual fix — calling build_workspace_context before create_session — was the meaningful change and that part is correct. However the dead parameter is a CLAUDE.md violation (#[allow(dead_code)] equivalent in parameter form, which the project policy says to remove). If history-aware context retrieval is planned (e.g., extracting the last user turn from history instead of passing user_message separately), the parameter should be used now or removed entirely.

    Concrete action: Remove _history: &[ChatMessage] from the signature and the call site, or implement the intent (extract query from history tail when query is None).


    [Improvement] Tool schema/struct contract mismatch on filters
    Files: packages/agent/src/local_agent/tools.rs line ~214, packages/core/src/agent_params.rs line 30

    The filters field in def_search_nodes() still declares "additionalProperties": { "type": "string" } in the JSON Schema exposed to the model, while SearchNodesParams.filters was widened to HashMap<String, Value>. The tool schema is what the model uses to decide which JSON types to emit in its tool call. Since the schema says string-only, a well-behaved model will continue to wrap numbers in quotes — defeating the purpose of the coercion on the Rust side.

    The update description says "Always pass values as strings" in the tool description text, which is internally contradictory with the coercion code whose entire rationale is that models pass numeric Values. The right resolution depends on intent:

    • If the fix is purely defensive (catching models that ignore the description and emit numbers anyway): the current code is fine as-is, but the JSON Schema additionalProperties should also be widened to {} or {"oneOf": [{"type": "string"}, {"type": "number"}]} to remove the contradiction.
    • If the intent is to actively encourage numeric values: update both the schema and the description consistently.

    The existing test at line ~1856 only validates string deserialization. Add a test case with {"amount": 500} (integer) to verify the coercion path executes correctly end-to-end.


    Suggestions

    [Suggestion] Similarity threshold at 0.2 needs a workspace-scale safety valve
    File: packages/core/src/ops/context_ops.rs, constants SCHEMA_SIMILARITY_THRESHOLD / MAX_SEMANTIC_SCHEMAS

    The rationale for dropping from 0.4 to 0.2 is well-documented and empirically motivated (action-oriented phrasing produces noisier embeddings). The MAX_SEMANTIC_SCHEMAS = 5 cap is a reasonable guard. However the cap applies to the semantic search results only; the debounce-bypass loop in local_agent_service.rs (line ~1215) appends all schemas created in the last 5 minutes without a cap. In a session where a user rapidly creates several schemas (a batch-import script, for example), every schema created in the last 5 minutes will be injected into the next turn regardless of relevance. This could push the ENTITY TYPES section well past the 4000-char budget that format_for_prompt attempts to enforce (since the budget check happens on the formatted string, not on the count of injected schemas).

    Consider limiting the debounce-bypass injection to MAX_SEMANTIC_SCHEMAS - context.relevant_schemas.len() additional schemas (i.e., fill the remaining budget).


    [Suggestion] Script has hardcoded absolute paths and no daemon-ready health check
    File: scripts/run-nemo-vs-8b-matrix.sh, lines 6-11 and 42-49

    REPO, NS_BIN, and NODESPACED are hardcoded to /Users/malibio/.... Any other developer or CI runner will silently fail with a "no such file" error.

    The daemon-ready check at line 42 waits for the socket file to appear then adds a fixed sleep 1. This is a TOCTOU race: the socket can appear before seed-node insertion completes, so the sleep 1 is a latency guess. A more reliable check would be to attempt a lightweight RPC (e.g., $NS_BIN --socket "$SOCK" status) and retry until it succeeds, or to check for a "seeding complete" log line.

    These are dev-only scripts, so neither is blocking, but they limit shareability and can produce flaky matrix runs.


    Nitpicks

    Nit: packages/agent/src/local_agent/model_manager.rs — MINISTRAL_14B docstring says "Mistral's mid-tier edge model" and name is "Ministral 3 14B Instruct Q4_K_M". The "3" in the name looks like a copy-paste artifact from the 3B/8B family naming; the actual model line is "Ministral-3-*" (where 3 is the series, not the size), but the display name with "3 14B" reads oddly. Worth verifying the canonical Mistral naming before this entry is promoted.

    Nit: SCHEMA_CREATION_RULES and TOOL_STRATEGY_RULES are now long single-line strings with \n\ continuation. They are correct and readable in source, but the guidance duplication between agent_guidance.rs and skill_pipeline.rs (noted in the #1089 comment) has grown larger with this commit (SCHEMA SUCCESS/FAILURE appears in both). The existing tracking issue covers this — just flagging that the divergence increased.

    Nit: packages/agent/src/local_agent/tools.rs test at line ~1866 — filters.get("status").map(|s| s.as_str()) now returns Option<Option<&str>> because Value::as_str() returns Option<&str>. The assertion Some(Some("open")) is correct and the compiler accepted it, but the ergonomics are a signal that a typed HashMap<String, String> test helper or a direct .and_then(|v| v.as_str()) chain would make future tests less surprising.


    Areas of Strength

    • Context injection timing fix is correct: calling build_workspace_context before create_session ensures the schema context is set before the first turn processes, with no race condition (both calls are sequential await on the same task).
    • Guidance rule logic is sound. The FIELD RULES and ENUM FIELDS constants correctly encode the actual validation constraints the backend enforces, converting a never-self-correcting retry loop into a prompt-level constraint. The SCHEMA SUCCESS/FAILURE rule prevents the double-call pathology cleanly.
    • snake_case schema ID migration is internally consistent: normalize_schema_id, tests in both schema/mod.rs and node_service/mod.rs, the create_schema tool description, and the model guidance all agree on the new format. The greenfield stance (CLAUDE.md) makes this unambiguously safe.
    • Test update in prompt_assembler.rs — replacing the hardcoded expected string with format!("{}\n\n{}", SCHEMA_CREATION_RULES, TOOL_STRATEGY_RULES) is the correct fix and eliminates the drift risk that caused the test to be stale in the first place.
  2. malibio commented on Jun 7, 2026

    @malibio
    CollaboratorAuthor

    Review Findings Addressed

    All 🟡 Important findings and the 🟢 debounce cap suggestion addressed in commit 0060b9ce.

    ✅ Addressed

    Dead _history parameter — removed from build_workspace_context signature and call site. The meaningful fix (calling context build before create_session) was already correct; the dead parameter was the only artifact.

    filters JSON schema/struct mismatch — widened additionalProperties from {type: string} to {oneOf: [string, number]} so the tool schema matches what the Rust struct accepts. Updated description from "Always pass values as strings" (contradicted the coercion code) to "String and numeric values are both accepted." Added test search_nodes_params_filters_numeric_value_coerced verifying integer deserialization.

    Debounce-bypass schema cap — limited recent-schema injection to MAX_SCHEMAS - len(existing) remaining slots. Previously unbounded; now capped to 5 total regardless of batch creation volume.

    Stale test needles — updated two assertions that referenced removed phrases: "ALWAYS search first" → "ALWAYS search_nodes first", "NEVER use placeholder IDs" → "NEVER CLAIM ACTION WITHOUT TOOL RESULT". Updated catalog count 10 → 12.

    ⏭️ Skipped

    Matrix script hardcoded paths — dev-only tooling, not shipped. Low priority vs. current work.

    MINISTRAL_14B display name "3 14B" — needs canonical Mistral naming verification before changing; tracked in this issue.

    Double-Option test ergonomics — cosmetic, compiler-verified correct, deferred.

    Guidance duplication between agent_guidance.rs and skill_pipeline.rs — pre-existing issue tracked under #1089.

  3. malibio commented on Jun 8, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 134 files, 3844 tests passed

  4. self-assigned this
    on Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions