{"record":{"id":"7da1906cd79a57f0","repo":"can1357/oh-my-pi","slug":"no-model-configured","errorCode":null,"errorMessage":"No model configured","messagePattern":"No model configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/agent.ts","lineNumber":1160,"sourceCode":"\t\tthis.#notifySteeringWaiters();\n\t\tthis.clearDeferredToolDirectives();\n\t}\n\n\t/** Send a prompt with an AgentMessage */\n\tasync prompt(message: AgentMessage | AgentMessage[], options?: AgentPromptOptions): Promise<void>;\n\tasync prompt(input: string, options?: AgentPromptOptions): Promise<void>;\n\tasync prompt(input: string, images?: ImageContent[], options?: AgentPromptOptions): Promise<void>;\n\tasync prompt(\n\t\tinput: string | AgentMessage | AgentMessage[],\n\t\timagesOrOptions?: ImageContent[] | AgentPromptOptions,\n\t\toptions?: AgentPromptOptions,\n\t) {\n\t\tif (this.#state.isStreaming) {\n\t\t\tthrow new AgentBusyError();\n\t\t}\n\n\t\tconst model = this.#state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tlet msgs: AgentMessage[];\n\t\tlet promptOptions: AgentPromptOptions | undefined;\n\t\tlet images: ImageContent[] | undefined;\n\n\t\tif (Array.isArray(input)) {\n\t\t\tmsgs = input;\n\t\t\tpromptOptions = imagesOrOptions as AgentPromptOptions | undefined;\n\t\t} else if (typeof input === \"string\") {\n\t\t\tif (Array.isArray(imagesOrOptions)) {\n\t\t\t\timages = imagesOrOptions;\n\t\t\t\tpromptOptions = options;\n\t\t\t} else {\n\t\t\t\tpromptOptions = imagesOrOptions;\n\t\t\t}\n\t\t\tconst content: Array<TextContent | ImageContent> = [{ type: \"text\", text: input }];\n\t\t\tif (images && images.length > 0) {\n\t\t\t\tcontent.push(...images);","sourceCodeStart":1142,"sourceCodeEnd":1178,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/agent/src/agent.ts#L1142-L1178","documentation":"Agent.prompt() throws this plain Error when this.#state.model is unset, checked immediately after the busy guard in packages/agent/src/agent.ts:1160. The agent runtime requires an LLM model to send the conversation to; without one there is nothing to call. The library deliberately fails fast at the public API boundary rather than deeper in the loop.","triggerScenarios":"Calling agent.prompt(...) (any overload: string, AgentMessage, or array) while this.#state.model is undefined/null — i.e. the Agent was constructed or reset without a model ever being set.","commonSituations":"Forgetting to pass a model (or model string) when constructing the Agent; constructing from config where the model key is missing or misnamed in a config file/env; calling prompt() on a fresh Agent whose setModel() was never invoked; SDK embedding where model resolution from a provider registry returned nothing.","solutions":["Set a model before prompting: construct the Agent with a model option or call the model setter (e.g. agent.setModel(model)) using a Model object from the AI package.","Verify your configuration actually supplies the model: check the config file / env var / options object key name for typos and that the value is non-empty.","If model resolution is dynamic, resolve the model from the provider catalog/registry first and assert it is defined before creating or prompting the Agent.","Guard the call site: check the agent's model state before prompt() and surface a clear user-facing 'configure a model' message instead of this raw error."],"exampleFix":"// before\nconst agent = new Agent({ tools }); // no model\nawait agent.prompt(\"hello\"); // throws: No model configured\n\n// after\nconst model = await resolveModel(\"claude-sonnet-4-5\");\nif (!model) throw new Error(\"Configure a model before using the agent\");\nconst agent = new Agent({ model, tools });\nawait agent.prompt(\"hello\");","handlingStrategy":"validation","validationCode":"function assertModelConfigured(agent: Agent): void {\n  if (!getModel(agent)) {\n    throw new Error(\"Agent has no model configured; set one before prompting\");\n  }\n}\nassertModelConfigured(agent);\nawait agent.prompt(\"hello\");","typeGuard":null,"tryCatchPattern":"try {\n  await agent.prompt(input);\n} catch (err) {\n  if (err instanceof Error && err.message === \"No model configured\") {\n    showConfigureModelUI();\n    return;\n  }\n  throw err;\n}","preventionTips":["Always construct the Agent with an explicit model option rather than setting it later.","Validate config/env for the model key at application startup, before any agent use.","Centralize Agent creation in one factory that guarantees a model is present.","Surface a 'no model configured' onboarding state in UIs instead of letting prompt() throw raw."],"tags":["configuration","model","agent","initialization"],"backgroundTag":"no-model-configured","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}