n8n-io/n8n · error · Error
Agent "${this.name}" requires a model
Error message
Agent "${this.name}" requires a model What it means
Thrown by Agent.build() when modelConfig has not been set. An agent cannot run without a language model — the model is the core engine that produces tool-call decisions and final responses. The build method validates this invariant before constructing the runtime.
Source
Thrown at packages/@n8n/agents/src/sdk/agent.ts:962
},
});
}
private async cleanupRuntime(active: ActiveRuntime): Promise<void> {
if (!this.activeRuntimes.delete(active)) return;
active.bus.dispose();
await active.runtime.dispose();
}
private toMessages(input: string | AgentMessage[]): AgentMessage[] {
if (Array.isArray(input)) return input;
return [{ role: 'user', content: [{ type: 'text', text: input }] }];
}
/** @internal Validate configuration and produce an AgentRuntime. Overridden by the execution engine. */
protected async build(): Promise<AgentRuntimeConfig> {
if (!this.modelConfig) {
throw new Error(`Agent "${this.name}" requires a model`);
}
if (!this.instructionsText) {
throw new Error(`Agent "${this.name}" requires instructions`);
}
const finalTools = [...this.tools];
const configuredDeferredTools = [...this.deferredTools];
if (this.workspaceInstance) {
const wsTools = this.workspaceInstance.getTools();
finalTools.push(...wsTools);
}
const finalStaticTools = finalTools;
const finalDeferredTools = configuredDeferredTools;
// Validate checkpoint requirement from static tools and known MCP approval config
// before attempting any network connections (allows fast failure).View on GitHub (pinned to 5ac6606e81)
Solutions
- Call agent.model(yourModel) before running or building the agent.
- Ensure the model configuration is set unconditionally, not behind a conditional that might be skipped.
- Add a startup assertion that modelConfig is set before build.
Example fix
// before
const agent = new Agent('my-agent').instructions('You are helpful.');
await agent.run('Hello');
// after
const agent = new Agent('my-agent')
.model(myModel)
.instructions('You are helpful.');
await agent.run('Hello'); Defensive patterns
Strategy: validation
Validate before calling
if (!agentModel) {
throw new Error('Cannot build agent without a model');
}
agent.model(agentModel); Prevention
- Always call agent.model(yourModel) before run() or build().
- Set the model unconditionally, not behind a conditional that might be skipped.
- Add a pre-build assertion that checks modelConfig is set.
When it happens
Trigger: Calling agent.run() or agent.build() without first calling agent.model(modelConfig). Also possible if .model() was called with undefined or a value that did not set modelConfig.
Common situations: Building an agent programmatically where the model is conditionally set (e.g. based on an env var) and the condition was not met. Copying agent setup code and forgetting the model line. Passing a model provider that returns undefined for the current configuration.
Related errors
- Agent "${this.name}" requires instructions
- Tools Agent requires Chat Model which supports Tools calling
- Invalid memory configuration. Use: new Memory() for in-proce
- toolCallConcurrency must be a positive integer or Infinity
- Agent "${this.name}" has tools requiring approval or suspend
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/43eb872143f6794e.
Report an issue: GitHub.