{"record":{"id":"a57b22b8b86a472d","repo":"mastra-ai/mastra","slug":"agent-fs-routing-model-required","errorCode":"AGENT_FS_ROUTING_MODEL_REQUIRED","errorMessage":"Agent \"${name}\": missing model in config.ts and no default. Provide a 'model' in agents/${name}/config.ts.","messagePattern":"Agent \"(.+?)\": missing model in config\\.ts and no default\\. Provide a 'model' in agents/(.+?)/config\\.ts\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/fs-routing/index.ts","lineNumber":317,"sourceCode":"    }\n    return config;\n  }\n\n  // Presence is the key being set, not the value being defined: codegen emits\n  // `instructions` only when the file exists, so a module that default-exports\n  // `undefined` has to read as a broken file rather than as no file at all.\n  // Own key only: an inherited one never came from a discovered file.\n  const instructions = resolveInstructions(\n    name,\n    config.instructions,\n    instructionsModule,\n    Object.hasOwn(entry, 'instructions'),\n    instructionsMd,\n    onWarn,\n  );\n\n  if (!config.model) {\n    throw new MastraError({\n      id: 'AGENT_FS_ROUTING_MODEL_REQUIRED',\n      domain: ErrorDomain.AGENT,\n      category: ErrorCategory.USER,\n      details: { agentName: name },\n      text: `Agent \"${name}\": missing model in config.ts and no default. Provide a 'model' in agents/${name}/config.ts.`,\n    });\n  }\n\n  const mergedTools = mergeTools(name, tools, config.tools, onWarn);\n  const mergedSkills = mergeSkills(name, skills, config.skills, onWarn);\n  const mergedWorkspace = mergeWorkspace(name, workspace, config, defaultWorkspaceBasePath, onWarn);\n  const mergedMemory = mergeMemory(name, memory, config.memory, onWarn);\n  const mergedAgents = mergeSubAgents(name, subagents, config.agents, mergedTools, depth, options);\n  const mergedInputProcessors = mergeProcessors(name, 'input', inputProcessors, config.inputProcessors, onWarn);\n  const mergedOutputProcessors = mergeProcessors(name, 'output', outputProcessors, config.outputProcessors, onWarn);\n  const mergedScorers = mergeScorers(name, scorers, config.scorers, onWarn);\n\n  const assembled = {","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/fs-routing/index.ts#L299-L335","documentation":"File-system agent routing assembles agents from agents/<name>/ directories. After merging config.ts values, assembleAtDepth requires a `model` — either defined in config.ts or supplied as an assembly default. If both are absent it throws this MastraError (ErrorCategory.USER).","triggerScenarios":"Building/serving an fs-routed agent whose agents/<name>/config.ts exports no `model` field and no default model was passed to the assembler.","commonSituations":"Newly scaffolded agent folders with only instructions.md, renaming a model constant out of config.ts, or upgrading to fs-routing from programmatic agents without porting the model config.","solutions":["Add a `model` field to agents/<name>/config.ts.","Or pass a default model to the fs-routing assembler so all agents inherit it.","Check config.ts for typos (e.g. `models` vs `model`) or a failing import that made the field undefined."],"exampleFix":"// agents/my-agent/config.ts — before\nexport const config = { instructions: 'You are helpful' };\n// after\nimport { openai } from '@ai-sdk/openai';\nexport const config = { instructions: 'You are helpful', model: openai('gpt-4o') };","handlingStrategy":"validation","validationCode":"import { config } from './agents/my-agent/config';\nif (!('model' in config) || !config.model) {\n  throw new Error('agents/my-agent/config.ts must export a non-empty `model`');\n}","typeGuard":"interface AgentConfig { model?: unknown; instructions?: string }\nfunction hasModel(c: AgentConfig): c is AgentConfig & { model: unknown } {\n  return !!c.model;\n}","tryCatchPattern":"import { MastraError } from '@mastra/core/mastra/error';\ntry {\n  assembleAgents(dir);\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'AGENT_FS_ROUTING_MODEL_REQUIRED') {\n    logger.error(`${e.details.agentName}: add a model to config.ts`);\n  }\n  throw e;\n}","preventionTips":["Scaffold new agents from a template that includes model in config.ts","Add a CI lint that every agents/*/config.ts exports a `model`","Watch for typos (`models`, `modelConfig`) and failed imports silently undefined-ing the field","Pass an explicit default model when assembling if agents may omit it"],"tags":["fs-routing","configuration","model"],"backgroundTag":"missing-agent-model-config","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}