earendil-works/pi · error · Error

Extension runtime not initialized. Action methods cannot be…

Error message

Extension runtime not initialized. Action methods cannot be called during extension loading.

What it means

Sentinel from the notInitialized stub in createExtensionRuntime: an extension action method (setModel, sendMessage, etc.) was invoked while the extension was still loading, before Runner.bindCore() replaced the throwing stubs with real implementations. Registration methods work during load; action methods do not.

Solutions

  1. Move action calls out of the extension's top-level/module-load code into event handlers or commands
  2. Defer actions until the extension's activate/event handlers run
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/core/extensions/loader.ts:181 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/172cc9ed9083a9a4. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/core/extensions/loader.ts:181

	extensionCacheGeneration++;
}

function useExtensionCacheCwd(cwd: string): ExtensionCacheToken {
	const resolvedCwd = resolvePath(cwd);
	if (extensionCacheCwd !== undefined && extensionCacheCwd !== resolvedCwd) {
		clearExtensionCache();
	}
	extensionCacheCwd = resolvedCwd;
	return { cwd: resolvedCwd, generation: extensionCacheGeneration };
}

/**
 * Create a runtime with throwing stubs for action methods.
 * Runner.bindCore() replaces these with real implementations.
 */
export function createExtensionRuntime(): ExtensionRuntime {
	const notInitialized = () => {
		throw new Error("Extension runtime not initialized. Action methods cannot be called during extension loading.");
	};
	const state: { staleMessage?: string } = {};
	const eventBusUnsubscribers = new Set<() => void>();
	const assertActive = () => {
		if (state.staleMessage) {
			throw new Error(state.staleMessage);
		}
	};

	const runtime: ExtensionRuntime = {
		sendMessage: notInitialized,
		sendUserMessage: notInitialized,
		appendEntry: notInitialized,
		setSessionName: notInitialized,
		getSessionName: notInitialized,
		setLabel: notInitialized,
		getActiveTools: notInitialized,
		getAllTools: notInitialized,

View on GitHub (pinned to 4af9d21d3b)