can1357/oh-my-pi · error

No model configured

Error message

No model configured

What it means

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.

Source

Thrown at packages/agent/src/agent.ts:1160

		this.#notifySteeringWaiters();
		this.clearDeferredToolDirectives();
	}

	/** Send a prompt with an AgentMessage */
	async prompt(message: AgentMessage | AgentMessage[], options?: AgentPromptOptions): Promise<void>;
	async prompt(input: string, options?: AgentPromptOptions): Promise<void>;
	async prompt(input: string, images?: ImageContent[], options?: AgentPromptOptions): Promise<void>;
	async prompt(
		input: string | AgentMessage | AgentMessage[],
		imagesOrOptions?: ImageContent[] | AgentPromptOptions,
		options?: AgentPromptOptions,
	) {
		if (this.#state.isStreaming) {
			throw new AgentBusyError();
		}

		const model = this.#state.model;
		if (!model) throw new Error("No model configured");

		let msgs: AgentMessage[];
		let promptOptions: AgentPromptOptions | undefined;
		let images: ImageContent[] | undefined;

		if (Array.isArray(input)) {
			msgs = input;
			promptOptions = imagesOrOptions as AgentPromptOptions | undefined;
		} else if (typeof input === "string") {
			if (Array.isArray(imagesOrOptions)) {
				images = imagesOrOptions;
				promptOptions = options;
			} else {
				promptOptions = imagesOrOptions;
			}
			const content: Array<TextContent | ImageContent> = [{ type: "text", text: input }];
			if (images && images.length > 0) {
				content.push(...images);

View on GitHub (pinned to 9690622007)

Solutions

  1. 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.
  2. 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.
  3. 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.
  4. 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.

Example fix

// before
const agent = new Agent({ tools }); // no model
await agent.prompt("hello"); // throws: No model configured

// after
const model = await resolveModel("claude-sonnet-4-5");
if (!model) throw new Error("Configure a model before using the agent");
const agent = new Agent({ model, tools });
await agent.prompt("hello");
Defensive patterns

Strategy: validation

Validate before calling

function assertModelConfigured(agent: Agent): void {
  if (!getModel(agent)) {
    throw new Error("Agent has no model configured; set one before prompting");
  }
}
assertModelConfigured(agent);
await agent.prompt("hello");

Try / catch

try {
  await agent.prompt(input);
} catch (err) {
  if (err instanceof Error && err.message === "No model configured") {
    showConfigureModelUI();
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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