Budibase/budibase · error · HTTPError
Agent is not properly configured: missing AI config
Error message
Agent is not properly configured: missing AI config
What it means
assertAgentHasValidConfig validates that an agent references an AI config before it can run. If agent.aiconfig is falsy, it throws a 422 HTTPError indicating the agent is not properly configured. This is a pre-flight guard so agents fail fast with a clear message instead of failing deep inside model calls.
Source
Thrown at packages/server/src/sdk/workspace/ai/agents/utils.ts:465
return {
successResults,
successNames,
semanticFailureNames,
semanticFailureResults,
}
}
export function formatIncompleteToolCallError(
incompleteTools: IncompleteToolCall[]
): string {
const toolNames = incompleteTools.map(t => t.toolName).join(", ")
return `The AI model failed to complete tool execution${toolNames ? ` for: ${toolNames}` : ""}. This may be due to a compatibility issue with the selected model. Please try a different model or try again.`
}
export const assertAgentHasValidConfig = async (agent: Agent) => {
if (!agent.aiconfig) {
throw new HTTPError(
"Agent is not properly configured: missing AI config",
422
)
}
const aiConfig = await sdk.ai.configs.find(agent.aiconfig)
if (!aiConfig) {
throw new HTTPError(
`Agent is not properly configured: AI config "${agent.aiconfig}" not found`,
422
)
}
}
View on GitHub (pinned to a81a902e9a)
Solutions
- Assign a valid AI config to the agent (set agent.aiconfig to an existing config ID) and save it.
- In the UI, complete agent setup by choosing a model/AI config before invoking the agent.
- Catch the 422 HTTPError and prompt the user to configure the agent rather than retrying.
Example fix
// before
await runAgent(agent) // 422: missing AI config
// after
if (!agent.aiconfig) {
agent.aiconfig = existingConfigId
await sdk.agents.update(agent)
}
await runAgent(agent) Defensive patterns
Strategy: validation
Validate before calling
const isAgentConfigured = (agent: Agent): boolean => !!agent.aiconfig
if (!isAgentConfigured(agent)) {
throw new HTTPError("Select an AI config for this agent first", 422)
}
await assertAgentHasValidConfig(agent) Type guard
const hasAiConfig = (agent: Agent): agent is Agent & { aiconfig: string } =>
typeof agent.aiconfig === "string" && agent.aiconfig.length > 0 Try / catch
try {
await assertAgentHasValidConfig(agent)
} catch (err) {
if (err instanceof HTTPError && err.status === 422 && err.message.includes("missing AI config")) {
// redirect user to agent configuration screen
}
} Prevention
- Make AI config selection a required step in agent creation flows.
- Pre-validate aiconfig presence before any agent invocation.
- Block 'run/test' buttons in the UI until a config is chosen.
When it happens
Trigger: Invoking an agent (chat/run flows that call assertAgentHasValidConfig) where the Agent document was saved without selecting an AI config, leaving aiconfig undefined.
Common situations: Agents created before AI config setup was completed; aiconfig field dropped by API clients omitting it; agents imported/copied without their config reference; configs deleted leaving agents pointing at nothing (related but distinct from 467).
Related errors
- LLM not available
- Agent is not properly configured: AI config "${agent.aiconfi
- No license key found
- Workspace DB not found - self-host users using cloud don't h
- CouchDB username not set
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/17d7d54f3dee15ec.
Report an issue: GitHub.