musistudio/claude-code-router · error · Error

Local agent account credential was not found. Sign in again,

Error message

Local agent account credential was not found. Sign in again, then re-import the local login provider.

What it means

For local agent providers, the code loads the credential via localAgentProviderAccountCredential and requires a non-empty apiKey. If it is missing, the user must re-authenticate and re-import the local login provider.

Source

Thrown at packages/core/src/providers/account-service.ts:1450

    id: readString(value.id),
    label: readString(value.label),
    redeemable: readBoolean(value.redeemable),
    status: readString(value.status)
  };
  return detail.description || detail.effectiveAt || detail.expiresAt || detail.id || detail.label || detail.redeemable !== undefined || detail.status ? detail : undefined;
}

async function materializeProviderAccountRequest(
  config: AppConfig,
  provider: GatewayProviderConfig
): Promise<MaterializedProviderAccountRequest> {
  if (providerApiKey(provider) !== localAgentProviderApiKey) {
    return { provider };
  }

  const credential = await localAgentProviderAccountCredential(config, provider);
  if (!credential?.apiKey) {
    throw new Error("Local agent account credential was not found. Sign in again, then re-import the local login provider.");
  }

  return {
    headers: credential.headers,
    provider: {
      ...provider,
      api_key: credential.apiKey,
      apiKey: undefined,
      apikey: undefined
    }
  };
}

function providerAccountConnectorUsesProviderApiKey(
  connector: ProviderAccountStandardConnectorConfig | ProviderAccountHttpJsonConnectorConfig
): boolean {
  return (connector.auth ?? "provider-api-key") !== "none";
}

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Sign in again with the local agent CLI
  2. Re-import the local login provider so the credential is captured
  3. Retry the account operation
Defensive patterns

Strategy: fallback

Validate before calling

const cred = await localAgentProviderAccountCredential(config, provider);
if (!cred?.apiKey) { /* prompt re-login */ }

Try / catch

catch (e) { if (e.message.includes('Sign in again')) { await promptLocalAgentLogin(); await reimportProvider(); } else throw e; }

Prevention

When it happens

Trigger: Provider API key matches localAgentProviderApiKey but no local agent credential (or empty apiKey) is found in config — typically after the local login session expired or was cleared.

Common situations: Local agent CLI session logged out or its token file removed; config directory reset; version change moved where local credentials are stored.

Related errors


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