{"record":{"id":"8c9bc28509fa2e52","repo":"can1357/oh-my-pi","slug":"model-registry-is-unavailable-for-inspect-image","errorCode":null,"errorMessage":"Model registry is unavailable for inspect_image.","messagePattern":"Model registry is unavailable for inspect_image\\.","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/inspect-image.ts","lineNumber":162,"sourceCode":"\t\tthis.description = prompt.render(inspectImageDescription);\n\t}\n\n\tasync execute(\n\t\t_toolCallId: string,\n\t\tparams: InspectImageParams,\n\t\tsignal?: AbortSignal,\n\t\t_onUpdate?: AgentToolUpdateCallback<InspectImageToolDetails>,\n\t\t_context?: AgentToolContext,\n\t): Promise<AgentToolResult<InspectImageToolDetails>> {\n\t\tif (this.session.settings.get(\"images.blockImages\")) {\n\t\t\tthrow new ToolError(\n\t\t\t\t\"Image submission is disabled by settings (images.blockImages=true). Disable it to use inspect_image.\",\n\t\t\t);\n\t\t}\n\n\t\tconst modelRegistry = this.session.modelRegistry;\n\t\tif (!modelRegistry) {\n\t\t\tthrow new ToolError(\"Model registry is unavailable for inspect_image.\");\n\t\t}\n\n\t\tconst availableModels = modelRegistry.getAvailable();\n\t\tif (availableModels.length === 0) {\n\t\t\tthrow new ToolError(\"No models available for inspect_image.\");\n\t\t}\n\n\t\tconst matchPreferences = getModelMatchPreferences(this.session.settings);\n\t\tconst resolvePattern = (pattern: string | undefined): Model<Api> | undefined => {\n\t\t\tif (!pattern) return undefined;\n\t\t\tconst expanded = expandRoleAlias(pattern, this.session.settings);\n\t\t\treturn resolveModelFromString(expanded, availableModels, matchPreferences);\n\t\t};\n\n\t\tconst activeModelPattern = this.session.getActiveModelString?.() ?? this.session.getModelString?.();\n\t\tlet model: Model<Api> | undefined;\n\t\tlet selectedPattern: string | undefined;\n\t\tfor (const pattern of [\"@vision\", \"@default\", activeModelPattern]) {","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/inspect-image.ts#L144-L180","documentation":"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.","triggerScenarios":"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.","commonSituations":"Embedding the agent SDK without initializing the model registry; unit/integration harnesses that stub ToolSession; startup errors that silently skipped registry creation.","solutions":["Ensure the agent session is fully initialized so modelRegistry is populated (use the standard session bootstrap path).","If embedding the SDK, explicitly construct/attach a model registry to the session before running tools.","If writing tests, provide a session fixture with a model registry (real or mock).","Report a bug if a normal `omp` run produces this — it means registry init failed silently."],"exampleFix":"// before: session built without registry\nconst session = createToolSession({ /* no modelRegistry */ });\n// after\nconst session = createToolSession({ modelRegistry: await createModelRegistry() });","handlingStrategy":"validation","validationCode":"if (!session.modelRegistry) {\n  throw new Error(\"Session not fully initialized: model registry missing\");\n}\n// safe to call inspect_image now","typeGuard":"function hasModelRegistry(s: ToolSession): s is ToolSession & { modelRegistry: NonNullable<ToolSession[\"modelRegistry\"]> } {\n  return Boolean(s.modelRegistry);\n}","tryCatchPattern":"try {\n  await inspectImageTool.execute(id, params, signal);\n} catch (e) {\n  if (e instanceof ToolError && e.message.includes(\"registry is unavailable\")) {\n    // reinitialize the session or report an init bug\n  } else throw e;\n}","preventionTips":["Always construct sessions through the standard bootstrap that wires the model registry.","In tests/embedding, use session fixtures that include a model registry.","Fail fast at session creation if registry init fails instead of leaving it undefined."],"tags":["configuration","initialization","internal-state"],"backgroundTag":"missing-dependency-uninitialized","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}