can1357/oh-my-pi · error

Model registry unavailable in current session.

Error message

Model registry unavailable in current session.

What it means

#runAgentCreationArchitect needs the session's model registry to list and refresh available models before spawning the architect sub-session. If this.#modelContext.modelRegistry is unset (e.g. the hub is rendered in a context without model registry wiring), it throws this error instead of proceeding.

Source

Thrown at packages/coding-agent/src/modes/components/agents-hub.ts:750

		this.#createSpec = null;
		this.#createStreamingText = "";
		this.#tui.requestRender();
		try {
			const spec = await this.#runAgentCreationArchitect(description);
			this.#createSpec = spec;
			this.#notice = null;
		} catch (error) {
			this.#createError = error instanceof Error ? error.message : String(error);
		} finally {
			this.#createGenerating = false;
			this.#tui.requestRender();
		}
	}

	async #runAgentCreationArchitect(description: string): Promise<GeneratedAgentSpec> {
		const modelRegistry = this.#modelContext.modelRegistry;
		if (!modelRegistry) {
			throw new Error("Model registry unavailable in current session.");
		}
		await modelRegistry.refresh();
		const modelPatterns = resolveConfiguredModelPatterns(
			this.#modelContext.activeModelPattern ??
				this.#modelContext.defaultModelPattern ??
				this.#settings.getModelRole("default"),
			this.#settings,
		);
		const { model } = resolveModelOverride(modelPatterns, modelRegistry, this.#settings);
		const selectedModel = model ?? modelRegistry.getAvailable()[0];
		if (!selectedModel) {
			throw new Error("No available model to generate agent specification.");
		}
		const systemPrompt = prompt.render(agentCreationArchitectPrompt, {});
		const userPrompt = prompt.render(agentCreationUserPrompt, { request: description });
		const { session } = await createAgentSession({
			cwd: this.#cwd,
			authStorage: modelRegistry.authStorage,

View on GitHub (pinned to 9690622007)

Solutions

  1. Start a normal interactive session so the model registry is populated before opening the agents hub
  2. Ensure the component is constructed with a valid modelContext containing modelRegistry
  3. Initialize/await model context setup before triggering agent creation
  4. Retry after session initialization completes

Example fix

// before
await hub.runAgentCreationArchitect(desc) // modelContext.modelRegistry === null
// after
if (!hub.modelContext?.modelRegistry) await session.initializeModelContext()
await hub.runAgentCreationArchitect(desc)
Defensive patterns

Strategy: type-guard

Validate before calling

if (!session.modelContext?.modelRegistry) {
  await session.initialize(); // or surface a clear setup error
}

Type guard

function hasModelRegistry(ctx: unknown): ctx is { modelRegistry: NonNullable<typeof ctx extends { modelRegistry: infer R } ? R : never> } {
  return typeof ctx === "object" && ctx !== null && "modelRegistry" in ctx && (ctx as any).modelRegistry != null;
}

Try / catch

try {
  await hub.runAgentCreationArchitect(desc);
} catch (err) {
  if (err instanceof Error && err.message.includes("Model registry unavailable")) {
    // re-open hub after session model context is ready
  } else throw err;
}

Prevention

When it happens

Trigger: Invoking the agent creation flow while this.#modelContext.modelRegistry is null/undefined — typically when the AgentsHubComponent was constructed without a model context or in a session type that does not supply one.

Common situations: Running the hub before the session fully initializes model context; embedding the component in tests or SDK usage without providing modelContext; session started in an offline/degraded mode where the registry was never attached.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/05d0cac308f48f4a. Report an issue: GitHub.