jcode icon indicating copy to clipboard operation
jcode copied to clipboard

`provider-doctor` cannot diagnose a configured named profile, and its error message routes users in a circle

Open ianalitis opened this issue 3 months ago • 1 comments

Source commit: 008abc44b1653efa65ccf98acb3b7236ce8507e6 (upstream master, chore(release): prepare v0.81.3) Binary identity: jcode v0.81.5-dev (422da2bc0), SHA-256 ff2639739dc8b71c591cca8e02a3fb79255ef340bd7ce80bbb621ec9f9275ec8 Platform: macOS 26.6.2, Darwin 25.6.0, arm64, Apple M3 Pro

Summary

jcode provider-doctor describes itself as the way to "diagnose why a provider/model or the model picker is broken by walking the strict end-to-end checkpoints". It cannot be pointed at a user-configured named provider profile. Every invocation is rejected before any checkpoint runs.

The error message tells the user to run jcode provider-test-coverage to find valid ids. That command lists the profile, and then states in its own output that provider-doctor does not cover it. The suggested remedy confirms the limitation rather than resolving it, so a user following the tool's guidance ends where they started.

This is a diagnosability gap, not a routing failure. Inference through the profile works when invoked with --provider-profile.

Reproduction

# ~/.jcode/config.toml
[providers.mlx-serve]
provider_type = "openai-compatible"
base_url = "http://127.0.0.1:11234/v1"

All three forms fail:

$ jcode provider-doctor mlx-serve
Error: `mlx-serve` is not a known OpenAI-compatible provider. Run `jcode provider-test-coverage` to see provider ids, or check your spelling.
exit=1

$ jcode provider-doctor --provider-profile mlx-serve mlx-serve
Error: `mlx-serve` is not a known OpenAI-compatible provider. ...
exit=1

$ jcode provider-doctor mlx-serve --tier offline
Error: `mlx-serve` is not a known OpenAI-compatible provider. ...
exit=1

--tier offline is documented to "check wiring only" and still rejects the profile, so even the non-network path is unreachable.

Following the error's own instruction:

$ jcode provider-test-coverage | grep mlx-serve
  mlx-serve                 0/1     1 not ready (best 0/11, stuck before live catalog)
  0/11   mlx-serve / Qwen3.5-4B-MLX-4bit-...   stuck before `live catalog`; re-run the mlx-serve live suite (provider-doctor does not cover it yet); ...

The profile is known to the coverage tool. The parenthetical is the whole report: provider-doctor does not cover it yet.

Substituting the built-in generic id does not help, because it diagnoses a different target than the configured profile:

$ jcode provider-doctor openai-compatible
Error: no API key found for `openai-compatible` (looked in env `OPENAI_COMPAT_API_KEY` and `openai-compatible.env`). ...

A local endpoint needs no API key, so the generic slot's auth precondition fails for a profile that requires no auth at all.

Expected behavior

provider-doctor should accept an id from the [providers.*] config table and run its checkpoints against that profile's base_url and auth mode, including the no-auth local case. If full coverage is genuinely not implemented, the rejection should say so directly and name the supported alternative, rather than referring the user to a command that reports the same limitation.

The minimum useful fix is to make --tier offline work for configured named profiles, since wiring-only validation needs no provider-specific support.

Related: local models are foreclosed as a memory sidecar

Reported together because it shares the assumption that a model must map to a built-in provider. In crates/jcode-base/src/sidecar.rs:165, Sidecar::with_configured_model resolves agents.memory_model through provider_for_model and accepts only two results:

match crate::provider::provider_for_model(&model) {
    Some("openai") => (SidecarBackend::OpenAI, model, None),
    Some("claude") => (SidecarBackend::Claude, model, None),
    _ => {
        crate::logging::warn(&format!(
            "Ignoring unsupported memory sidecar model override '{}'; expected an OpenAI or Claude model",
        // ...
    }
}

Any OpenAI-compatible named profile model is warned about and silently replaced with the default. The memory sidecar is a bounded, high-volume, low-authority workload, which is the best possible fit for a local model, yet it is unreachable by construction. This one is a feature request, not a defect.

The constraint is structural rather than a missing branch. provider_for_model returns Option<&'static str> (crates/jcode-provider-core/src/models.rs:209), so it can only ever name a compiled-in provider. A user-configured profile id from [providers.*] is not a 'static string and cannot be represented in that return type at all. Honoring a named profile here therefore needs a signature change or a separate resolution path, not just a third match arm.

Duplicate check

Searched 1jehuang/jcode on 2026-08-31 for provider-doctor, provider-doctor named profile, memory_model local, and JCODE_NAMED_PROVIDER_PROFILE. No open issue covers either behavior. Issue #712 (closed) concerns auth-test clearing the profile environment variable, which is a different command and a different mechanism.

Notes on what was tested

Two claims were checked and withdrawn before this packet was written, and are recorded so the maintainer knows what was tested rather than assumed:

  • jcode model list does list all six configured local models, with or without JCODE_NAMED_PROVIDER_PROFILE set. Catalog visibility is not broken.
  • The claim that the environment variable successfully reached the local models was false. It never reached the local server; that is a separate report.

Related: #1121 (same profile subsystem, different command).

ianalitis avatar Aug 31 '26 16:08 ianalitis

Reproduced verbatim on current master, and the cause is a single lookup that only reads the built-in list.

$ jcode --version
jcode v0.99.1-dev (4ec4baf91)

$ jcode provider-doctor mlx-serve          # isolated JCODE_HOME, config with [providers.mlx-serve]
Error: `mlx-serve` is not a known OpenAI-compatible provider. Run `jcode provider-test-coverage` to see provider ids, or check your spelling.

$ jcode provider-doctor mlx-serve --tier offline
Error: `mlx-serve` is not a known OpenAI-compatible provider. ...

$ jcode provider-doctor --provider-profile mlx-serve mlx-serve
Error: `mlx-serve` is not a known OpenAI-compatible provider. ...

Same profile shape as the report ([providers.mlx-serve] type = "openai-compatible", base_url = "http://127.0.0.1:11234/v1", requires_api_key = false), same three rejections, still before any checkpoint.

Cause. src/cli/provider_doctor.rs:47 resolves the provider with openai_compatible_profile_by_id, which searches only the static catalog:

// crates/jcode-base/src/provider_catalog.rs:394
pub fn openai_compatible_profile_by_id(id: &str) -> Option<OpenAiCompatibleProfile> {
    openai_compatible_profiles().iter().copied().find(|profile| profile.id == normalized)
}

[providers.*] entries are a different type living in config().providers: BTreeMap<String, NamedProviderConfig>, and today only the routing path reads them (named_provider_profile_route_for_model, crates/jcode-base/src/provider/catalog_remote_routes.rs:345). Nothing in the doctor or coverage path consults them, so a configured profile is invisible to both by construction.

The circle is literal. The error says "run provider-test-coverage". That command decides its hint with:

// crates/jcode-base/src/live_tests.rs:1714
fn doctor_supports_provider(provider_id: &str) -> bool {
    provider_catalog::openai_compatible_profile_by_id(provider_id).is_some()
        || auth::doctor::native_doctor_supports_provider(provider_id)
}
// :2229
format!("re-run the {provider_id} live suite (provider-doctor does not cover it yet)")

Both sides ask the same static list, so the advice cannot ever resolve.

The API-key bullet is the same lookup. jcode provider-doctor openai-compatible demands OPENAI_COMPAT_API_KEY because the static generic profile has requires_api_key: true. The config already expresses the truth (requires_api_key = false); the doctor just never reads it, which is why a no-auth local endpoint hits an auth precondition that does not exist.

Fix, and how small it is. ResolvedOpenAiCompatibleProfile already exists with owned Strings (crates/jcode-provider-metadata/src/lib.rs:133), and run_provider_e2e (crates/jcode-provider-doctor/src/provider_e2e.rs:397) touches the &'static profile struct in only 11 places before resolving it to that owned type anyway. So:

  1. Take ResolvedOpenAiCompatibleProfile in run_provider_e2e; resolve the static profile at the CLI call site. Mechanical, 11 field reads.
  2. Add an adapter from NamedProviderConfig to ResolvedOpenAiCompatibleProfile (api_base = base_url, api_key_env/env_file from config, requires_api_key.unwrap_or(true), default_model), and try it in provider_doctor.rs after the static lookup misses.
  3. Point doctor_supports_provider at the same resolver so the coverage hint stops contradicting itself.

Recommendation on scope: do --tier offline first. It needs no network and no key, so it proves the wiring (base_url reachable, model listed) for exactly the local-endpoint case in this report, and it is the part of the fix that cannot regress live behavior.

This is a real diagnosability gap, not a design limitation: everything needed to check a local endpoint is already in config. It needs a maintainer decision on whether named-profile doctor support is in scope for this cycle, which is what the needs-decision label says.


— Jcode agent (automated triage), on behalf of @1jehuang

ianalitis avatar Oct 25 '26 01:10 ianalitis