Skip to content

ollama_integration test suite has ~17 failing tests due to empty tool-call responses from mistral:7b #1632

Closed

Description

@malibio

Overview

packages/agent/tests/ollama_integration.rs (gated behind --features testing, requires a live local Ollama server) currently has approximately 17 failing tests, all sharing the same failure mode: the model (mistral:7b) intermittently returns an empty response with no tool calls, where a tool call was expected by the test.

Problem Statement

Running the suite locally with Ollama running and mistral:7b loaded:

cargo test -p nodespace-agent --test ollama_integration --features testing

produces failures like:

thread 'test_pipeline_get_node_by_id' panicked at packages/agent/tests/ollama_integration.rs:1616:5:
Expected get_node for explicit ID lookup, got: []

and

thread 'test_pipeline_search_nodes_keyword' panicked at packages/agent/tests/ollama_integration.rs:1250:10:
send_message should succeed: Engine("model produced empty response with no tool calls")

and

thread 'test_ollama_inference_with_production_prompt' panicked at packages/agent/tests/ollama_integration.rs:345:5:
completion_tokens=0 — looks like context-window truncation (expected > 1). prompt_tokens=0. Check that num_ctx is being sent correctly.

Verified this is not caused by any in-progress work: the same failures reproduce identically on main at commit 4962856b (before any related changes), so this is pre-existing flakiness/regression in the test suite or model-serving path, not a new break.

Currently failing tests (as observed against main@4962856b, mistral:7b, Ollama running locally — some entries may be intermittent rather than deterministic, so a future investigation should re-run and confirm which are consistently failing vs. flaky):

  • test_ollama_inference_with_production_prompt
  • test_pipeline_delete_node
  • test_pipeline_get_node_by_id
  • test_pipeline_get_related_nodes
  • test_pipeline_multi_turn_session_persistence
  • test_pipeline_schema_creation
  • test_pipeline_schema_creation_project_task_relationship
  • test_pipeline_schema_creation_title_template_fields
  • test_pipeline_schema_creation_with_relationship
  • test_pipeline_search_nodes_keyword
  • test_pipeline_search_nodes_with_type_filter
  • test_pipeline_task_status_update
  • test_pipeline_update_node_content
  • test_skill_pipeline_graph_editing_real_model
  • test_skill_pipeline_node_creation_real_model
  • test_skill_pipeline_node_deletion_real_model
  • test_skill_pipeline_research_real_model

Related prior work

Proposed Solution

Not proposed here — this issue is filed to track investigation, not to prescribe a fix. Candidate angles for a future investigation:

  • Whether num_ctx / context-window sizing is actually being sent correctly to Ollama (the test_ollama_inference_with_production_prompt failure explicitly suspects this).
  • Whether the production system prompt (7800 chars, 14 tools per the test output) is too large or ambiguous for mistral:7b to reliably produce tool calls against.
  • Whether this is model-version/Ollama-version drift (a mistral:7b re-pull or Ollama update changing serving behavior) rather than a code change.
  • Whether these tests are simply too flaky for a 7B local model at this system prompt size, and need a smaller/more constrained test prompt to be reliable.

Acceptance Criteria

  • Root cause identified for the empty-tool-call-response failures
  • Failing tests from the list above are individually triaged: fixed, confirmed flaky-by-nature (with a documented reason), or the assertion adjusted if the expectation was wrong
  • Suite passes reliably (or documented flake tolerance) when re-run with cargo test -p nodespace-agent --test ollama_integration --features testing
  • No regression in the rest of the nodespace-agent test suite

Technical Specifications

Reference Files

  • Test suite: packages/agent/tests/ollama_integration.rs
  • Feature gate: packages/agent/Cargo.toml (testing feature, required-features = ["testing"] on this test binary)
  • Local agent engine: packages/agent/src/local_agent/ (system prompt assembly, tool-call parsing, ollama NDJSON reading)

Reproduction

# Ensure Ollama is running with mistral:7b loaded, then:
cargo test -p nodespace-agent --test ollama_integration --features testing

Non-Goals

  • Not proposing to add this suite to any CI gate — it requires a live local model server and is explicitly excluded from bun run test:all today via the testing feature gate.

Activity

  1. added
    bug
    on Jul 11, 2026
  2. malibio commented on Jul 11, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 4031 passed (159 test files), 44.48s

  3. self-assigned this
    on Jul 11, 2026
  4. malibio commented on Jul 11, 2026

    @malibio
    CollaboratorAuthor

    Root Cause Analysis

    Root-caused via direct Ollama API testing (bypassing all NodeSpace code) plus full test-harness reproduction. Summary:

    1. Tool-count ceiling (primary cause, ~13 of the 17 failing tests). mistral:7b reliably fails to emit structured tool_calls once ~6+ tools are offered in one turn — it narrates the intended call as prose/JSON-in-markdown instead. Deterministic (not flaky): confirmed identical across 2 full suite runs and 3-5 repeated raw API calls per scenario. Holds regardless of system prompt content (bare fallback prompt, no prompt, or the full 7800-char production prompt all fail identically). Verified model-size correlation: ministral-3:3b (3B) fails worse, mistral:7b (7B) fails, ornith:9b (9B) and mistral-nemo:12b (12B) both succeed reliably at the same 10-tool case.

    2. Non-deterministic test harness (contributing). resolve_engine() used first_ollama_model() — whichever model Ollama's /api/tags lists first, which depends on local pull order and isn't reproducible across machines. Fixed: now pins to mistral:7b explicitly.

    3. One incorrect assertion (test_skill_pipeline_organization_real_model, not in original failing list but surfaced once pinned): asserted the model should only call create_relationship/get_node, but the real Organization skill's tool_whitelist (seed_skill_nodes) legitimately includes search_nodes/search_semantic — needed to resolve a collection name to an ID before linking. Assertion was stricter than the skill definition it's meant to mirror. Fixed.

    4. GPU memory exhaustion (separate, transient issue also encountered). Independently hit ggml_metal_synchronize: Insufficient Memory (kIOGPUCommandBufferCallbackErrorOutOfMemory) when Ollama allocated a 32768-token KV cache under concurrent memory pressure on a 16GB machine — not a code bug, just a reproducibility hazard on memory-constrained dev machines. Not addressed in code (nothing to fix), noted for awareness.

    Resolution

    • Pinned resolve_engine() to mistral:7b (deterministic across machines).
    • Marked 13 tests #[ignore] with detailed reasons documenting the verified tool-count/structured-arg-complexity ceiling — these are real, valuable regression tests that will correctly re-activate if the underlying model/architecture changes; they're not deleted or silently skipped.
    • Fixed the one incorrect assertion.
    • Added a module-level doc comment summarizing the investigation and evidence for future readers.
    • Suite now passes reliably: 16 passed, 0 failed, 13 ignored (confirmed stable across repeated runs).
    • No regression in nodespace-agent's broader test suite (291 unit tests) or the full workspace test:all (4031 frontend + 979 Rust, all passing).

    Follow-up

    Filed #1634 to track the underlying production gap this surfaced: GraphToolExecutor::available_tools() sends the full unscoped tool set on every turn for the Ollama provider path, with no dynamic scoping — real mistral:7b-via-Ollama users can hit the same narration failure on ordinary requests. This is a genuine architecture decision (extend ADR-038's skill-mediated routing to the Ollama path, reduce baseline tool count, or document a recommended Ollama model) out of scope for this test-suite triage issue.

    Note: this does not implicate ADR-046 (Ministral 8B locked as the native llama.cpp path model) — that ADR's evidence and the #1370 agent tool-call matrix only evaluated the native path. mistral:7b via Ollama is a separate, real, user-selectable provider path (per #1370's model-picker design) that hadn't previously been evaluated against this specific failure mode.

  5. added 3 commits that reference this issue on Jul 11, 2026
  6. added 3 commits that reference this issue on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendbugtesting

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions