{"record":{"id":"1b938d900e9f2e07","repo":"musistudio/claude-code-router","slug":"local-agent-provider-was-not-found","errorCode":null,"errorMessage":"Local agent provider was not found.","messagePattern":"Local agent provider was not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/local-providers/service.ts","lineNumber":36,"sourceCode":"export { kimiAccessTokenExpired, kimiIdentityHeaders, readKimiAuth, resolveKimiAuth } from \"@ccr/core/agents/local-providers/kimi\";\nexport { readZcodeLocalProviderCredential, zcodeDefaultBaseUrl } from \"@ccr/core/agents/local-providers/zcode\";\nexport { localAgentProviderApiKey, type OAuthTokenSet } from \"@ccr/core/agents/local-providers/shared\";\n\nexport function getLocalAgentProviderCandidates(): LocalAgentProviderCandidate[] {\n  return [\n    codexCandidate(),\n    claudeCodeCandidate(),\n    grokCandidate(),\n    ...kimiCandidates(),\n    ...opencodeCandidates(),\n    zcodeCandidate()\n  ].filter((candidate) => candidate.status !== \"missing\");\n}\n\nexport async function importLocalAgentProvider(request: LocalAgentProviderImportRequest): Promise<LocalAgentProviderImportResult> {\n  const candidate = getLocalAgentProviderCandidates().find((item) => item.id === request.id);\n  if (!candidate) {\n    throw new Error(\"Local agent provider was not found.\");\n  }\n  if (!candidate.importable) {\n    throw new Error(candidate.detail || \"Local agent login is not importable.\");\n  }\n\n  if (candidate.kind === \"codex\") {\n    return importCodexProvider(candidate, request.providerNames ?? []);\n  }\n  if (candidate.kind === \"claude-code\") {\n    return importClaudeCodeProvider(candidate, request.providerNames ?? []);\n  }\n  if (candidate.kind === \"grok\") {\n    return importGrokProvider(candidate, request.providerNames ?? []);\n  }\n  if (candidate.kind === \"kimi\") {\n    return importKimiProvider(candidate, request.providerNames ?? []);\n  }\n  if (candidate.kind === \"opencode\") {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/agents/local-providers/service.ts#L18-L54","documentation":"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.","triggerScenarios":"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.","commonSituations":"UI holds a stale list after the user uninstalls a CLI; race between detection and import; hand-crafted id.","solutions":["Re-fetch the candidate list (getLocalAgentProviderCandidates) and use a current id.","Ensure the CLI (codex/claude-code/kimi/opencode/zcode) is installed and logged in.","Verify the request.id string exactly matches candidate.id."],"exampleFix":"// before\nawait importLocalAgentProvider({ id: staleId });\n// after\nconst candidates = getLocalAgentProviderCandidates().filter(c => c.status !== \"missing\");\nconst target = candidates.find(c => c.id === requestedId) ?? candidates[0];\nif (target) await importLocalAgentProvider({ id: target.id });","handlingStrategy":"type-guard","validationCode":"const candidates = getLocalAgentProviderCandidates().filter(c => c.status !== 'missing');\nif (!candidates.some(c => c.id === request.id)) refreshUI();","typeGuard":"function isKnownCandidate(id: string, candidates: LocalAgentProviderCandidate[]): boolean {\n  return candidates.some(c => c.id === id && c.status !== 'missing');\n}","tryCatchPattern":"catch (e) { if ((e as Error).message === 'Local agent provider was not found.') await reloadCandidates(); }","preventionTips":["Always import against a freshly fetched candidate list.","Handle removal races in UI state."],"tags":["local-provider","import","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}