can1357/oh-my-pi · error · ToolError

Model registry is unavailable for inspect_image.

Error message

Model registry is unavailable for inspect_image.

What it means

inspect_image requires a model registry on the ToolSession to enumerate available models, resolve a vision-capable candidate, and obtain API keys. When session.modelRegistry is null/undefined the tool cannot proceed and throws this ToolError. This indicates the session was constructed without model-registry wiring rather than a user input problem.

Solutions

  1. Ensure the agent session is fully initialized so modelRegistry is populated (use the standard session bootstrap path).
  2. If embedding the SDK, explicitly construct/attach a model registry to the session before running tools.
  3. If writing tests, provide a session fixture with a model registry (real or mock).
  4. Report a bug if a normal `omp` run produces this — it means registry init failed silently.

Example fix

// before: session built without registry
const session = createToolSession({ /* no modelRegistry */ });
// after
const session = createToolSession({ modelRegistry: await createModelRegistry() });
Defensive patterns

Strategy: validation

Validate before calling

if (!session.modelRegistry) {
  throw new Error("Session not fully initialized: model registry missing");
}
// safe to call inspect_image now

Type guard

function hasModelRegistry(s: ToolSession): s is ToolSession & { modelRegistry: NonNullable<ToolSession["modelRegistry"]> } {
  return Boolean(s.modelRegistry);
}

Try / catch

try {
  await inspectImageTool.execute(id, params, signal);
} catch (e) {
  if (e instanceof ToolError && e.message.includes("registry is unavailable")) {
    // reinitialize the session or report an init bug
  } else throw e;
}

Prevention

When it happens

Trigger: Invoking inspect_image with a session whose modelRegistry property is unset — e.g. a ToolSession built in a test/embedding context, a headless/SDK path that skipped registry initialization, or a partial-init failure earlier in startup.

Common situations: Embedding the agent SDK without initializing the model registry; unit/integration harnesses that stub ToolSession; startup errors that silently skipped registry creation.

Related errors


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

Appendix: source

Thrown at packages/coding-agent/src/tools/inspect-image.ts:162

		this.description = prompt.render(inspectImageDescription);
	}

	async execute(
		_toolCallId: string,
		params: InspectImageParams,
		signal?: AbortSignal,
		_onUpdate?: AgentToolUpdateCallback<InspectImageToolDetails>,
		_context?: AgentToolContext,
	): Promise<AgentToolResult<InspectImageToolDetails>> {
		if (this.session.settings.get("images.blockImages")) {
			throw new ToolError(
				"Image submission is disabled by settings (images.blockImages=true). Disable it to use inspect_image.",
			);
		}

		const modelRegistry = this.session.modelRegistry;
		if (!modelRegistry) {
			throw new ToolError("Model registry is unavailable for inspect_image.");
		}

		const availableModels = modelRegistry.getAvailable();
		if (availableModels.length === 0) {
			throw new ToolError("No models available for inspect_image.");
		}

		const matchPreferences = getModelMatchPreferences(this.session.settings);
		const resolvePattern = (pattern: string | undefined): Model<Api> | undefined => {
			if (!pattern) return undefined;
			const expanded = expandRoleAlias(pattern, this.session.settings);
			return resolveModelFromString(expanded, availableModels, matchPreferences);
		};

		const activeModelPattern = this.session.getActiveModelString?.() ?? this.session.getModelString?.();
		let model: Model<Api> | undefined;
		let selectedPattern: string | undefined;
		for (const pattern of ["@vision", "@default", activeModelPattern]) {

View on GitHub (pinned to 9690622007)