{"record":{"id":"278ffce9d2ab3c38","repo":"ruvnet/ruflo","slug":"agent-config-must-include-id-name-and-type","errorCode":null,"errorMessage":"Agent config must include id, name, and type","messagePattern":"Agent config must include id, name, and type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/integration/src/agentic-flow-agent.ts","lineNumber":313,"sourceCode":"   */\n  private delegationEnabled: boolean = false;\n\n  /**\n   * Extended configuration\n   */\n  private extendedConfig: AgentConfig;\n\n  /**\n   * Create a new AgenticFlowAgent instance\n   *\n   * @param config - Agent configuration\n   */\n  constructor(config: AgentConfig) {\n    super();\n\n    // Validate required fields\n    if (!config.id || !config.name || !config.type) {\n      throw new Error('Agent config must include id, name, and type');\n    }\n\n    this.id = config.id;\n    this.name = config.name;\n    this.type = config.type;\n    this.config = config;\n    this.extendedConfig = config;\n    this.createdAt = new Date();\n    this.lastActivity = new Date();\n\n    // Initialize metrics\n    this.metrics = {\n      tasksCompleted: 0,\n      tasksFailed: 0,\n      avgTaskDuration: 0,\n      errorCount: 0,\n      uptime: 0,\n    };","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/agentic-flow-agent.ts#L295-L331","documentation":"Thrown by the AgenticFlowAgent constructor (v3/@claude-flow/integration/src/agentic-flow-agent.ts:313) when the AgentConfig lacks a truthy id, name, or type. These three fields are mandatory because they identify the agent in the swarm, in events, and in routing.","triggerScenarios":"new AgenticFlowAgent({}) or a config built from unvalidated JSON/env where id/name/type is missing, empty string, or undefined; destructuring mistakes that rename the keys; configs deserialized from YAML where the keys are nested one level too deep.","commonSituations":"Agent definitions loaded from a config file that drifted from the schema; programmatic agent factories with optional parameters leaking through; copy-pasting an agent template and forgetting to change the id.","solutions":["Provide non-empty id, name, and type in the AgentConfig literal passed to the constructor.","Validate agent definition objects at load time (config file, API payload) with a schema check before constructing agents.","Add defaults in your factory (e.g. id = `agent-${crypto.randomUUID()}`) when a field is genuinely optional in your domain.","Check for empty strings too — the guard is truthiness, so '' fails exactly like undefined."],"exampleFix":"// before\nconst agent = new AgenticFlowAgent({ name: 'coder' } as AgentConfig);\n\n// after\nconst agent = new AgenticFlowAgent({\n  id: `coder-${Date.now()}`,\n  name: 'coder',\n  type: 'coder',\n  ...rest,\n});","handlingStrategy":"type-guard","validationCode":"function requireAgentFields(cfg: unknown): asserts cfg is { id: string; name: string; type: string } {\n  const c = cfg as Record<string, unknown>;\n  for (const k of ['id', 'name', 'type']) {\n    if (typeof c[k] !== 'string' || (c[k] as string).length === 0) {\n      throw new Error(`agent config missing ${k}`);\n    }\n  }\n}","typeGuard":"function isValidAgentConfig(c: unknown): c is { id: string; name: string; type: string } {\n  return !!c && typeof c === 'object' &&\n    typeof (c as any).id === 'string' && (c as any).id.length > 0 &&\n    typeof (c as any).name === 'string' && (c as any).name.length > 0 &&\n    typeof (c as any).type === 'string' && (c as any).type.length > 0;\n}","tryCatchPattern":"try {\n  agent = new AgenticFlowAgent(cfg);\n} catch (e) {\n  if ((e as Error).message === 'Agent config must include id, name, and type') {\n    throw new ConfigError('agent definition incomplete', cfg);\n  }\n  throw e;\n}","preventionTips":["Validate agent definitions at the config-file boundary with a schema (zod/io-ts) before constructing.","Generate ids in your factory (crypto.randomUUID()) instead of relying on input.","Remember empty strings fail the truthiness check just like missing keys."],"tags":["validation","constructor","agent-config","missing-field"],"backgroundTag":"missing-required-field","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}