Skip to content

OpenAI-compat path has no routing-reliability testing; Stage-2 candidate injection can silently suppress tool-calling on served models #1829

Closed

Description

@malibio

Overview

ADR-056 deliberately keeps the OpenAI-compatible path open for any user-configured model (Ollama, or any /v1-compatible server) — only the native in-process GGUF path is locked to E4B. That's an intentional design decision, not a gap to close by removing user-configured models.

What's actually missing: the OpenAI-compat path has a transport smoke test (packages/agent/tests/live_openai_compat_smoke.rs — discovery reaches the endpoint, one tool-calling turn completes) but no reliability testing for the two-stage routing flow #1815 shipped. That gap surfaced only because #1815's own diagnostic happened to include a non-native model as a comparison arm — not because anyone was checking.

Problem Statement

#1815 (PR #1826) found that mistral:7b over the OpenAI-compatible endpoint suppresses tool-calling on any injected Stage-2 candidate block, regardless of content — including a block containing only skill names, no instructions. The locked native model (E4B) is unaffected. Filed narrowly as #1828 ("check before any future model-lock change"), which undersells the actual gap: this isn't only relevant if the native lock changes. Any user pointing NodeSpace at a non-E4B model today, via the supported OpenAI-compat path, may hit this failure right now.

The existing smoke test cannot catch this class of failure — it validates that a turn completes with tools offered, not that routing's candidate-injection step doesn't silently break tool-calling for the served model.

Evidence

Four-arm diagnostic from #1815, native model vs. mistral:7b:

arm block injected at Stage 2 gemma-4-e4b (locked) mistral:7b
baseline none fires fires
Stage-1 only, no candidates none fires fires
routed + full instructions yes fires suppressed
routed + names only yes fires suppressed

Content-independent — the block's mere presence breaks tool-calling on this model, contradicting ADR-064 rule 4's mechanism (which predicted procedural content specifically, measured on the locked model).

Scope

  • Extend live_openai_compat_smoke.rs, or add a companion test, to exercise the routed path specifically — Stage-2 candidate injection with tools available — not just an unrouted tool-calling turn
  • Run the same four-arm pattern from Implement ADR-038 Stage-1 and Stage-2 gates; shipped loop is the rejected single-turn pull #1815 against whatever OpenAI-compat model(s) are reasonably available in CI/local dev, so this is a repeatable check rather than a one-off finding
  • Decide what NodeSpace does when routing is detected to suppress tool-calling for a served model — degrade to unrouted (Stage-1-only) behavior automatically, surface a warning, or document it as a known limitation of unsupported models
  • Document the finding's scope honestly in user-facing material for the OpenAI-compat path: routing reliability is not guaranteed for arbitrary served models, only for the locked native one

Out of scope

  • Removing mistral or any other model from the OpenAI-compat path — ADR-056 explicitly keeps this path open by design
  • Re-litigating the native model lock (E4B) — unaffected by this finding
  • Guaranteeing routing works on all possible served models — not achievable; the goal is detecting and handling the failure gracefully, not preventing it universally

Architecture Impact

Surfaces a real gap in ADR-056's "Ollama and OpenAI-compatible remain open paths" provision: openness without any routing-reliability check means users on that path can silently lose tool-calling the moment #1815's Stage-2 injection fires, with no signal that anything went wrong. Supersedes #1828, which named only the narrow "check before a future lock change" framing.

Activity

  1. malibio commented on Jul 30, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 171 test files passed, 4112 tests passed (Duration 46.8s). Clean.

  2. malibio commented on Jul 30, 2026

    @malibio
    CollaboratorAuthor

    Scope question before implementing

    Two decisions in this issue's scope list are open. Recording them here rather than deciding silently in the PR.

    1. Remediation depth (scope item 3)

    Scope item 3 asks what NodeSpace does when routing is detected to suppress tool-calling for a served model. Three candidate answers, in increasing footprint:

    A. Test + document only. Ship the four-arm routed reliability test and honest user-facing docs on the OpenAI-compat path's routing limits. No production code change. Defer the runtime-degradation decision to a follow-up issue.

    B. Test + docs + auto-degrade at runtime. Additionally: when a Stage-2 routed turn on a non-native model produces zero tool calls, retry the turn unrouted (Stage-1-only) and warn. Costs one extra generation on the failure path.

    C. Test + docs + startup probe. Additionally: probe each configured OpenAI-compat model once at discovery with a synthetic routed turn, cache the verdict, skip candidate injection for models that fail. Avoids per-turn retry cost; adds startup latency and a cache-invalidation surface.

    Proposing A, on the grounds that the evidence for B or C does not exist yet. The suppression is currently a single observation on a single model (mistral:7b). Both B and C encode a general remediation policy, and choosing between them sensibly requires the multi-model matrix that this issue's test is what produces. Building the remediation in the same PR as the measurement means picking a mechanism before seeing the data it should be designed against.

    Concretely: if the test shows the failure is universal across served non-native models, C (probe once) is clearly right. If it shows it is specific to mistral:7b, B (degrade on observed failure) is the cheaper fit. If it shows arm-dependence nobody predicted, neither is right yet. That is a real fork, and one measurement resolves it.

    2. Which models the four-arm test covers

    Proposing: auto-discover whatever /v1/models returns and run four arms against each, printing a per-model matrix, rather than hardcoding mistral:7b. Hardcoding reproduces the known finding and catches nothing new; it also skips on any dev box without that exact model pulled. Auto-discovery makes this the repeatable check scope item 2 asks for.

    The test asserts only that each served model's baseline arm fires — a model that cannot tool-call at all is a different failure and shouldn't be reported as a routing regression. The routed arms are reported as data, not assertions, because "this model suppresses under routing" is a finding about the model, not a NodeSpace regression to fail the build on.

    Local dev box currently serves mistral:7b, ornith:9b, gemma4:e4b — enough for a real first matrix.


    Proceeding with A + auto-discovery unless redirected.

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

    @malibio
    CollaboratorAuthor

    Answers

    1. Remediation depth — agreed, A. Right call for the reason given: B and C each encode a policy that only makes sense once the shape of the failure is known across more than one model. Building either now would be picking a mechanism to fit a sample size of one. Deferring to a follow-up issue is correct — file it as soon as the matrix exists, framed around whichever of "universal / model-specific / arm-dependent" the data actually shows, rather than pre-guessing which of B/C it'll be.

    2. Auto-discovery over hardcoding — agreed. Hardcoding mistral:7b reproduces one known data point and would silently stop testing anything the moment that model isn't pulled on whoever's box runs it. Auto-discovery is the only version of this that's actually the "repeatable check" the issue asks for rather than a regression pin on one already-known finding.

    One addition to the assert-vs-report split, not a change to it. Baseline-must-fire as an assertion, routed arms as reported data, is right — a model that can't tool-call at all is a different failure class and conflating the two would make the test fail for the wrong reason. But as scoped, a test where the only assertion never fails on the actual thing being investigated is a data-collection script wearing a test's clothes, and it'll bit-rot the moment nobody's reading its output. Two things to pin down before landing it:

    • Assert something about the shape of the routed results, even if not pass/fail per model. At minimum: the test fails if it discovers zero models (nothing to report is itself a config/harness problem, not a clean run), and it fails if a discovered model errors out entirely rather than producing a clean pass/suppress result for all four arms — same "harness failure vs. real finding" distinction this whole workstream has had to relearn repeatedly. A model that times out or throws should not silently disappear from the matrix looking identical to one that wasn't discovered.
    • Persist the per-run matrix somewhere diffable, even if informally (a comment on this issue each time it's run manually, or a checked-in fixture the CI-optional path writes to). Otherwise "auto-discover and report" degrades into "run it once, eyeball the printout, forget the result" — and the whole point of OpenAI-compat path has no routing-reliability testing; Stage-2 candidate injection can silently suppress tool-calling on served models #1829 existing is that this class of finding was previously only caught by accident.

    Proceed with A + auto-discovery as scoped, with those two additions folded in before this closes.

  5. malibio commented on Jul 30, 2026

    @malibio
    CollaboratorAuthor

    Matrix run — 2026-07-31

    Both additions folded in. Artifact is committed at packages/agent/tests/routing-matrix-latest.txt and regenerated on each run; posting it here too so runs are diffable from the issue.

    # endpoint: http://127.0.0.1:11434/v1
    # excluded (removed from the NodeSpace catalog): ornith:9b
    
    model             baseline    stage1_only routed_full routed_names
    mistral:7b        fires       fires       SUPPRESSED  SUPPRESSED
    gemma4:e4b        fires       fires       fires       fires
    

    The locked model is unaffected on every arm. On mistral:7b the block's presence is the variable, not its content — routed_names carries a bare skill name and still suppresses.

    On the assert-vs-report split

    Your point about a data-collection script wearing a test's clothes was right, and the specific failure you predicted was already latent: run_arm returned an empty Vec on generation error, which printed identically to a real suppression. A timed-out model would have appeared in the matrix as a finding.

    Fixed structurally rather than by adding a check — arm results are now a typed enum where Errored and Completed(vec![]) cannot be conflated by accident. Three assertions now fail the run, all of them harness/config failures rather than findings about a model:

    • any arm errored → the matrix is incomplete, so a green result would be misleading
    • zero measurable models discovered → nothing to report is itself a config problem
    • model count ≠ row count → guards the bookkeeping, so a model cannot silently fall through every branch and shrink the matrix

    Per-model suppression stays reported rather than asserted, unchanged.

    On Ornith

    Removed, and the docs were corrected — but the more useful catch is that my conclusion depended on it. I had written "suppression is not a native-vs-served property, therefore a mitigation keyed on that would be wrong," which was an argument resting on a model ADR-056 deleted. Stripped of it, the honest reading is the one now in ADR-056: one served model fails, none is confirmed clean, so neither generalization holds and #1830 cannot be decided until the matrix is wider. #1830 has been reframed around that as a prerequisite.

    The matrix now excludes removed-catalog models by name fragment, so a dev box serving one cannot silently readmit it. Two pre-existing unit fixtures that used ornith:9b / qwen2.5-3b as sample model-id strings were also updated — incidental to what they assert, but they were live references to a removed family.

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