musistudio/claude-code-router · error · Error

Local agent provider was not found.

Error message

Local agent provider was not found.

What it means

importLocalAgentProvider was called with a request.id that matches no candidate returned by getLocalAgentProviderCandidates(). The id is unknown or the candidate list changed since it was rendered.

Source

Thrown at packages/core/src/agents/local-providers/service.ts:36

export { kimiAccessTokenExpired, kimiIdentityHeaders, readKimiAuth, resolveKimiAuth } from "@ccr/core/agents/local-providers/kimi";
export { readZcodeLocalProviderCredential, zcodeDefaultBaseUrl } from "@ccr/core/agents/local-providers/zcode";
export { localAgentProviderApiKey, type OAuthTokenSet } from "@ccr/core/agents/local-providers/shared";

export function getLocalAgentProviderCandidates(): LocalAgentProviderCandidate[] {
  return [
    codexCandidate(),
    claudeCodeCandidate(),
    grokCandidate(),
    ...kimiCandidates(),
    ...opencodeCandidates(),
    zcodeCandidate()
  ].filter((candidate) => candidate.status !== "missing");
}

export async function importLocalAgentProvider(request: LocalAgentProviderImportRequest): Promise<LocalAgentProviderImportResult> {
  const candidate = getLocalAgentProviderCandidates().find((item) => item.id === request.id);
  if (!candidate) {
    throw new Error("Local agent provider was not found.");
  }
  if (!candidate.importable) {
    throw new Error(candidate.detail || "Local agent login is not importable.");
  }

  if (candidate.kind === "codex") {
    return importCodexProvider(candidate, request.providerNames ?? []);
  }
  if (candidate.kind === "claude-code") {
    return importClaudeCodeProvider(candidate, request.providerNames ?? []);
  }
  if (candidate.kind === "grok") {
    return importGrokProvider(candidate, request.providerNames ?? []);
  }
  if (candidate.kind === "kimi") {
    return importKimiProvider(candidate, request.providerNames ?? []);
  }
  if (candidate.kind === "opencode") {

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Re-fetch the candidate list (getLocalAgentProviderCandidates) and use a current id.
  2. Ensure the CLI (codex/claude-code/kimi/opencode/zcode) is installed and logged in.
  3. Verify the request.id string exactly matches candidate.id.

Example fix

// before
await importLocalAgentProvider({ id: staleId });
// after
const candidates = getLocalAgentProviderCandidates().filter(c => c.status !== "missing");
const target = candidates.find(c => c.id === requestedId) ?? candidates[0];
if (target) await importLocalAgentProvider({ id: target.id });
Defensive patterns

Strategy: type-guard

Validate before calling

const candidates = getLocalAgentProviderCandidates().filter(c => c.status !== 'missing');
if (!candidates.some(c => c.id === request.id)) refreshUI();

Type guard

function isKnownCandidate(id: string, candidates: LocalAgentProviderCandidate[]): boolean {
  return candidates.some(c => c.id === id && c.status !== 'missing');
}

Try / catch

catch (e) { if ((e as Error).message === 'Local agent provider was not found.') await reloadCandidates(); }

Prevention

When it happens

Trigger: RPC import request with a stale/incorrect id, or the CLI tool was uninstalled so its candidate now has status 'missing' and is filtered out.

Common situations: UI holds a stale list after the user uninstalls a CLI; race between detection and import; hand-crafted id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/1b938d900e9f2e07. Report an issue: GitHub.