eyaltoledano/claude-task-master · error · Error
BaseAIProvider cannot be instantiated directly
Error message
BaseAIProvider cannot be instantiated directly
What it means
BaseAIProvider is an abstract base class for all AI providers. Instantiating it directly is a programming error because it has no provider implementation (no API client, no name semantics beyond the class name), so the constructor throws to enforce subclassing.
Source
Thrown at src/ai-providers/base-provider.js:130
return baseSchema;
}
const sanitizedSchema = sanitizeIntegerConstraints(baseSchema.jsonSchema);
if (typeof jsonSchemaHelper === 'function') {
return jsonSchemaHelper(sanitizedSchema, { validate: baseSchema.validate });
}
return { ...baseSchema, jsonSchema: sanitizedSchema };
};
/**
* Base class for all AI providers
*/
export class BaseAIProvider {
constructor() {
if (this.constructor === BaseAIProvider) {
throw new Error('BaseAIProvider cannot be instantiated directly');
}
// Each provider must set their name
this.name = this.constructor.name;
// Cache proxy agent to avoid creating multiple instances
this._proxyAgent = null;
/**
* Whether this provider needs explicit schema in JSON mode
* Can be overridden by subclasses
* @type {boolean}
*/
this.needsExplicitJsonSchema = false;
/**
* Whether this provider supports temperature parameter
* Can be overridden by subclassesView on GitHub (pinned to c0c98d367c)
Solutions
- Instantiate a concrete provider class that extends BaseAIProvider
- Check your provider factory/registry maps names to actual provider classes
- In tests, create a minimal subclass for testing base behavior
Example fix
// before
const provider = new BaseAIProvider();
// after
import { AzureProvider } from './azure.js';
const provider = new AzureProvider(); Defensive patterns
Strategy: type-guard
Validate before calling
if (ProviderClass === BaseAIProvider) throw new Error('Use a concrete provider subclass'); Type guard
function isConcreteProvider(Cls) { return typeof Cls === 'function' && Cls !== BaseAIProvider && Cls.prototype instanceof BaseAIProvider; } Try / catch
try {
const provider = new ProviderClass();
} catch (err) {
if (err.message.includes('cannot be instantiated directly')) {
console.error('Resolve a concrete provider class from the provider registry');
} else throw err;
} Prevention
- Use the provider factory/registry rather than instantiating classes directly
- Map provider name strings to classes with a lookup table with a safe default
- In tests, subclass BaseAIProvider to test base behavior
When it happens
Trigger: Executing `new BaseAIProvider()` directly instead of instantiating a concrete provider subclass (e.g., new AzureProvider(), new OpenAIProvider()).
Common situations: Dynamic provider resolution falling back to the base class; typos in provider class names; tests or factories instantiating the wrong class.
Related errors
- MCP provider requires session object
- The Grok CLI model function cannot be called with the new ke
- Base URL is required for OpenAI-compatible providers. Please
- Invalid provider hint received: ${providerHint}
- ${this.name} API key is required
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/a5175739a5c112c3.
Report an issue: GitHub.