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
- Start a normal interactive session so the model registry is populated before opening the agents hub
- Ensure the component is constructed with a valid modelContext containing modelRegistry
- Initialize/await model context setup before triggering agent creation
- 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
- Only open the agents hub after the session is fully initialized
- In SDK/test embeddings, construct the component with a complete modelContext
- Await model context setup before exposing creation UI
- Guard integrations with a registry-existence check
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
- Provider ${providerName}: "api" is required when registering
- Provider ${providerName}, model ${modelDef.id}: no "api" spe
- No active debug session. Launch or attach first.
- No session - artifacts unavailable
- Unknown memory namespace: ${namespace}. Supported: ${MEMORY_
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/05d0cac308f48f4a.
Report an issue: GitHub.